From fbe29a5cdc5f6305cb81f9a93c9c94982f323396 Mon Sep 17 00:00:00 2001 From: makearmy Date: Mon, 29 Sep 2025 19:39:37 -0400 Subject: [PATCH] build bug fixes --- app/rigs/page.tsx | 52 +++++++++++++++++++++++++++++++---------------- 1 file changed, 34 insertions(+), 18 deletions(-) diff --git a/app/rigs/page.tsx b/app/rigs/page.tsx index 08a67007..b7d34289 100644 --- a/app/rigs/page.tsx +++ b/app/rigs/page.tsx @@ -13,24 +13,40 @@ export default async function Page() { } const DIRECTUS = (process.env.DIRECTUS_URL || "").replace(/\/$/, ""); - const res = await fetch( - `${DIRECTUS}/items/user_rig_type?fields=id,name&sort=sort`, - { - headers: { - Authorization: `Bearer ${ma_at}`, - Accept: "application/json", - "Cache-Control": "no-store", - }, - cache: "no-store", + let rigTypes: Opt[] = []; + + try { + const res = await fetch( + `${DIRECTUS}/items/user_rig_type?fields=id,name&sort=sort`, + { + headers: { + Authorization: `Bearer ${ma_at}`, + Accept: "application/json", + "Cache-Control": "no-store", + }, + cache: "no-store", + } + ); + + if (res.ok) { + const json = await res.json(); + rigTypes = (json?.data ?? []).map((r: any) => ({ + id: r.id, + label: r.name ?? String(r.id), + })); + } else { + // Optional: log server-side for debugging + // console.error("Failed to fetch user_rig_type", res.status); + rigTypes = []; } + } catch { + rigTypes = []; + } + + return ( +
+

Rigs

+ +
); - - // Be resilient: if this fails, just show no options so the page still builds - const json = res.ok ? await res.json().catch(() => ({ data: [] })) : { data: [] }; - const rigTypes: Opt[] = (json?.data ?? []).map((r: any) => ({ - id: r.id, - label: r.name ?? String(r.id), - })); - - return ; }