import { UpsolveWorkspace } from '@upsolve-labs/react';
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs';
interface WorkspaceConfig {
id: string;
name: string;
description: string;
permissions: TenantEditingPermissions;
isCustomOnly?: boolean;
}
export function MultiWorkspaceApp({ userToken }: { userToken: string }) {
// Configure your workspaces
const workspaces: WorkspaceConfig[] = [
{
id: 'd982f3d1-d145-43b5-bbfe-1c3322bd43fb',
name: 'Sales Analytics',
description: 'Revenue, pipeline, and performance metrics',
permissions: {
addChart: true,
addFilter: true,
createChart: false, // Read-only for sales team
editCharts: false,
removeChart: false,
},
},
{
id: '8a620645-bad4-40d4-823b-7fb57aeb9f98',
name: 'Marketing Insights',
description: 'Campaign performance and customer engagement',
permissions: {
addChart: true,
addFilter: true,
createChart: true,
editCharts: true,
removeChart: true,
},
},
{
id: 'c48ce638-0c2c-44ff-8d35-2a5616f167e2',
name: 'Custom Reports',
description: 'Your personal analytics workspace',
permissions: {
addChart: true,
addFilter: true,
createChart: true,
editCharts: true,
removeChart: true,
},
isCustomOnly: true, // This is a Custom Only workspace
},
];
return (
<div className="h-screen flex flex-col">
<header className="border-b p-4">
<h1 className="text-2xl font-bold">Company Analytics</h1>
</header>
<Tabs defaultValue={workspaces[0].id} className="flex-1">
<div className="border-b">
<TabsList className="w-full justify-start">
{workspaces.map((workspace) => (
<TabsTrigger
key={workspace.id}
value={workspace.id}
className="relative"
>
{workspace.name}
{workspace.isCustomOnly && (
<span className="ml-2 text-xs bg-purple-100 text-purple-800 px-2 py-0.5 rounded">
Personal
</span>
)}
</TabsTrigger>
))}
</TabsList>
</div>
{workspaces.map((workspace) => (
<TabsContent
key={workspace.id}
value={workspace.id}
className="flex-1 m-0"
>
<div className="h-full flex flex-col">
{/* Optional: Add description banner */}
{workspace.description && (
<div className="bg-gray-50 border-b px-4 py-2 text-sm text-gray-600">
{workspace.description}
</div>
)}
<div className="flex-1">
<UpsolveWorkspace
workspaceId={workspace.id}
tenantJWT={userToken}
tenantEditingPermissions={workspace.permissions}
tabPlacement="top"
theme="light"
/>
</div>
</div>
</TabsContent>
))}
</Tabs>
</div>
);
}