feat(cc-050): Workspace Settings page
This commit is contained in:
parent
dbd93d0be2
commit
f9c0b71c4d
1 changed files with 64 additions and 0 deletions
64
src/app/dashboard/settings/workspaces/page.tsx
Normal file
64
src/app/dashboard/settings/workspaces/page.tsx
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
'use client';
|
||||
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import { apiFetch } from '../../../../lib/api';
|
||||
import type { TenantMembership } from '../../../../lib/api';
|
||||
import { useSession } from '../../../../components/session-provider';
|
||||
|
||||
export default function WorkspacesPage() {
|
||||
const { activeTenant } = useSession();
|
||||
const tenantId = activeTenant?.tenantId ?? '';
|
||||
|
||||
const { data: me, isLoading } = useQuery({
|
||||
queryKey: ['me-workspaces'],
|
||||
queryFn: () => apiFetch<{ userId: string; tenants: TenantMembership[] }>('/v1/me', { tenantId }),
|
||||
staleTime: 60_000,
|
||||
});
|
||||
|
||||
const tenantList = me?.tenants ?? [];
|
||||
|
||||
return (
|
||||
<div className="max-w-3xl space-y-6">
|
||||
<div>
|
||||
<h1 className="font-display text-2xl font-semibold text-ink">Workspace-uri</h1>
|
||||
<p className="mt-1 text-sm text-ink-faint">
|
||||
Toate workspace-urile la care ai acces ({tenantList.length}).
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{isLoading ? (
|
||||
<p className="text-sm text-ink-faint">Se încarcă…</p>
|
||||
) : tenantList.length === 0 ? (
|
||||
<div className="card p-10 text-center">
|
||||
<p className="text-sm text-ink-faint">Niciun workspace găsit.</p>
|
||||
</div>
|
||||
) : (
|
||||
<ul className="space-y-3">
|
||||
{tenantList.map((t) => {
|
||||
const isActive = t.tenantId === tenantId;
|
||||
return (
|
||||
<li key={t.tenantId} className={`card p-5 ${isActive ? 'border border-bronze-deep' : ''}`}>
|
||||
<div className="flex items-start justify-between gap-4">
|
||||
<div className="min-w-0">
|
||||
<div className="flex items-center gap-2">
|
||||
<p className="font-semibold text-ink">{t.tenantName}</p>
|
||||
{isActive && (
|
||||
<span className="rounded-full bg-bronze-wash px-2 py-0.5 text-[10px] font-semibold text-bronze-deep">
|
||||
Activ
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
<p className="mt-0.5 font-mono text-[11px] text-ink-faint">{t.tenantId}</p>
|
||||
</div>
|
||||
<span className="shrink-0 rounded-full bg-paper-sunken px-2.5 py-1 text-xs font-medium capitalize text-ink-faint">
|
||||
{t.role}
|
||||
</span>
|
||||
</div>
|
||||
</li>
|
||||
);
|
||||
})}
|
||||
</ul>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Loading…
Reference in a new issue