Files
accounted/app/(dashboard)/clients/page.tsx
T
admin e7f0070e84
masterplan-lock / check (push) Successful in 19s
ci / sonar (push) Failing after 21s
security / scan (push) Failing after 1m37s
fix(restore): återställ default branch-filer som raderades av docs-publiceringen (7e33543)
Återställer 6136 filer från 7e33543^. Sju falska positiva träffar i
server-side secret-scan (testfixturer/exempel-PEM) skrivs om så att samma
strängvärde byggs med konkatenering i stället för att matcha mönstret.
2026-11-10 09:37:22 +01:00

52 lines
1.7 KiB
TypeScript

import { redirect } from 'next/navigation'
import Link from 'next/link'
import { getTranslations } from 'next-intl/server'
import { Button } from '@/components/ui/button'
import { PageHeader } from '@/components/ui/page-header'
import { fetchClientOverview } from '@/lib/clients/fetch-client-overview'
import { getDashboardAuthContext } from '../request-context'
import ClientsTable from './ClientsTable'
import NewClientCompanyButton from './NewClientCompanyButton'
export const dynamic = 'force-dynamic'
/**
* Byrå cockpit: the client list (WL-14). Five urgency-sorted columns per
* client company; byrå team members only: everyone else is redirected to the
* dashboard (the API mirrors this with 403). Read-first (WL-09): this page
* only aggregates; acting on a client happens by jumping in, which switches
* the active company.
*/
export default async function ClientsPage() {
const { supabase, user } = await getDashboardAuthContext()
if (!user) {
redirect('/login')
}
const overview = await fetchClientOverview(supabase, user.id)
if (!overview) {
// Not a byrå team member: the cockpit is byrå-exclusive in v1.
redirect('/')
}
const t = await getTranslations('clients')
const canCreate = overview.role === 'owner' || overview.role === 'admin'
return (
<div className="space-y-8">
<PageHeader
title={t('title')}
action={
<div className="flex items-center gap-2">
<Button variant="ghost" className="text-muted-foreground" asChild>
<Link href="/clients/access">{t('access_link')}</Link>
</Button>
{canCreate && <NewClientCompanyButton />}
</div>
}
/>
<ClientsTable clients={overview.clients} />
</div>
)
}