all the haul

This commit is contained in:
2026-04-07 23:56:31 +00:00
parent 87cce83030
commit 24f303355b
244 changed files with 33743 additions and 11249 deletions
+24 -1
View File
@@ -3,6 +3,25 @@ import { handleApiError } from "$lib/optima-api/errorHandler";
import { checkPermissions } from "$lib/permissions";
import type { PageServerLoad } from "./$types";
function withTimeoutFallback<T>(
promise: Promise<T>,
timeoutMs: number,
fallback: T,
): Promise<T> {
return new Promise<T>((resolve) => {
const timer = setTimeout(() => resolve(fallback), timeoutMs);
promise
.then((value) => {
clearTimeout(timer);
resolve(value);
})
.catch(() => {
clearTimeout(timer);
resolve(fallback);
});
});
}
export const load: PageServerLoad = async ({ locals, url }) => {
const accessToken = locals.session?.accessToken;
if (!accessToken) {
@@ -68,7 +87,11 @@ export const load: PageServerLoad = async ({ locals, url }) => {
optima.sales
.fetchOpportunityTypes(accessToken)
.catch(() => ({ data: [] })),
optima.sales.fetchMetrics(accessToken).catch(() => null),
withTimeoutFallback(
optima.sales.fetchMetrics(accessToken).catch(() => null),
2500,
null,
),
]);
const opportunities =