loops wizard: stop pulling bearer.ts into the client bundle
Same trap the pre-existing topology import comment warned about: importing from @/lib/api/team or @/lib/api/structure drags http.ts → bearer.ts (uses next/headers, server-only) into the client bundle and Turbopack refuses to build. Replace fetchClaws / fetchTeams / fetchOrgs with plain fetch() to /api/team/claws, /api/teams, /api/orgs. Types are inlined where they were only used for the shape of the JSON response.
This commit is contained in:
@@ -14,7 +14,17 @@ import { useEffect, useMemo, useState } from "react";
|
||||
import { Building2, User, Users } from "lucide-react";
|
||||
|
||||
import type { Agent } from "@/lib/api/schemas";
|
||||
import { fetchOrgs, fetchTeams, type GroupSummary } from "@/lib/api/structure";
|
||||
// Do NOT import @/lib/api/structure — pulls bearer.ts (next/headers,
|
||||
// server-only) into the client bundle and breaks the production build.
|
||||
// Call /api/teams and /api/orgs with plain fetch instead.
|
||||
|
||||
interface GroupSummary {
|
||||
id: string;
|
||||
name: string;
|
||||
kind: string;
|
||||
status: string;
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
const mono =
|
||||
"ui-monospace, SFMono-Regular, SF Mono, Menlo, Monaco, Consolas, monospace";
|
||||
@@ -50,8 +60,13 @@ export function LoopStaffingStep({
|
||||
let cancelled = false;
|
||||
(async () => {
|
||||
try {
|
||||
const [t, o] = await Promise.all([fetchTeams(), fetchOrgs()]);
|
||||
const [tRes, oRes] = await Promise.all([
|
||||
fetch("/api/teams"),
|
||||
fetch("/api/orgs"),
|
||||
]);
|
||||
if (cancelled) return;
|
||||
const t = tRes.ok ? ((await tRes.json()) as GroupSummary[]) : [];
|
||||
const o = oRes.ok ? ((await oRes.json()) as GroupSummary[]) : [];
|
||||
setTeams(t);
|
||||
setOrgs(o);
|
||||
} catch (e) {
|
||||
|
||||
Reference in New Issue
Block a user