import { createSignal, createResource, Show, For } from 'solid-js'; import { A, useSearchParams } from '@solidjs/router'; import ProfileWidget from '~/components/dashboard/ProfileWidget'; async function fetchRuntimeConfig(roleKey: string) { const RUST_API_URL = import.meta.env.VITE_RUST_API_URL || 'http://localhost:8080'; // Try to lookup Role ID first const roleRes = await fetch(`${RUST_API_URL}/api/admin/roles/${roleKey}`); if (!roleRes.ok) throw new Error("Role not found"); const role = await roleRes.json(); // Then fetch Dashboard config for that role const configRes = await fetch(`${RUST_API_URL}/api/admin/dashboard-config/${role.id}?audience=EXTERNAL`); if (!configRes.ok) throw new Error("Dashboard config not found"); const dashboardConfig = await configRes.json(); return dashboardConfig.config_json; // Returns `{ sidebar: [...], widgets: [...] }` } export default function WorkspaceLayout(props: { children?: any }) { const [searchParams] = useSearchParams(); const rawRoleKey = searchParams.roleKey; const roleKey = () => (Array.isArray(rawRoleKey) ? rawRoleKey[0] : rawRoleKey) || 'PHOTOGRAPHER'; const [config] = createResource(roleKey, fetchRuntimeConfig); return (
{/* Sidebar rendered magically from Rust Config */} {/* Main Content Area */}
{(widget: any) => (

{widget.title}

Dynamic Widget Module

)}
{/* Profile Settings specifically for this Role */} {props.children}
); }