From 387c70bf5684a02e3ab101a6785e7bf9be514f42 Mon Sep 17 00:00:00 2001 From: makearmy Date: Mon, 29 Sep 2025 19:42:51 -0400 Subject: [PATCH] build bug fixes --- app/portal/rigs/page.tsx | 39 ++++++++++++++++++++-- app/rigs/page.tsx | 72 ++++++++++++++-------------------------- 2 files changed, 61 insertions(+), 50 deletions(-) diff --git a/app/portal/rigs/page.tsx b/app/portal/rigs/page.tsx index 129a6bc9..060f39f0 100644 --- a/app/portal/rigs/page.tsx +++ b/app/portal/rigs/page.tsx @@ -1,13 +1,46 @@ // app/portal/rigs/page.tsx +import { cookies } from "next/headers"; +import { redirect } from "next/navigation"; import RigsSwitcher from "@/components/portal/RigsSwitcher"; -export const metadata = { title: "MakerDash • Rigs" }; +type Opt = { id: string | number; label: string }; + +export default async function Page() { + const jar = await cookies(); // Next 15: async cookies() + const ma_at = jar.get("ma_at")?.value; + if (!ma_at) redirect("/auth/sign-in?next=/portal/rigs"); + + const DIRECTUS = (process.env.DIRECTUS_URL || "").replace(/\/$/, ""); + 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), + })); + } + } catch { + // fall back to empty + } -export default function RigsPortalPage() { return (

Rigs

- +
); } diff --git a/app/rigs/page.tsx b/app/rigs/page.tsx index b7d34289..f7bf1a9f 100644 --- a/app/rigs/page.tsx +++ b/app/rigs/page.tsx @@ -1,52 +1,30 @@ -// app/portal/rigs/page.tsx -import { cookies } from "next/headers"; -import { redirect } from "next/navigation"; -import RigsSwitcher from "@/components/portal/RigsSwitcher"; - -type Opt = { id: string | number; label: string }; - -export default async function Page() { - const jar = await cookies(); // Next 15: async - const ma_at = jar.get("ma_at")?.value; - if (!ma_at) { - redirect("/auth/sign-in?next=/portal/rigs"); - } - - const DIRECTUS = (process.env.DIRECTUS_URL || "").replace(/\/$/, ""); - 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 = []; - } +// app/rigs/page.tsx +import RigBuilderServer from "./RigBuilderServer"; +import RigsListClient from "./RigsListClient"; +export default function Page() { return ( -
-

Rigs

- +
+
+

Rigs

+

+ Manage rigs used when submitting settings. +

+
+ +
+ {/* Left: existing rigs */} +
+

My Rigs

+ +
+ + {/* Right: create a new rig (server-provided rig types) */} +
+

Create Rig

+ +
+
); }