Files
accounted/app/companies/new-client/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

44 lines
1.6 KiB
TypeScript

import { createClient } from '@/lib/supabase/server'
import { redirect } from 'next/navigation'
import OnboardingBackdrop from '@/components/onboarding/OnboardingBackdrop'
import OnboardingJourney from '@/components/onboarding/journey/OnboardingJourney'
import { isScbConfigured } from '@/lib/parties/scb/config'
import { getByraMembership } from '@/lib/clients/fetch-client-overview'
export const dynamic = 'force-dynamic'
/**
* Client company creation from the byrå cockpit (WL-15): exactly today's
* creation journey (company form, fiscal year, voucher series defaults), but
* bound EXPLICITLY to the byrå team so the new company lands under the byrå
* (companies.team_id = byrå team), the team sync grants the whole byrå
* access, and the trial-suppression trigger keys on the byrå binding.
*
* Server-gated to byrå team owner/admin (creation is a commercial act: +1 on
* the byrå's invoice). The create_company_with_owner RPC enforces the same
* gate in the database, so a member cannot bypass this page via PostgREST.
*/
export default async function NewClientCompanyPage() {
const supabase = await createClient()
const { data: { user } } = await supabase.auth.getUser()
if (!user) {
redirect('/login')
}
const membership = await getByraMembership(supabase, user.id)
if (!membership) {
redirect('/')
}
if (membership.role !== 'owner' && membership.role !== 'admin') {
redirect('/clients')
}
return (
<div className="min-h-screen bg-background">
<OnboardingBackdrop />
<OnboardingJourney teamId={membership.teamId} mode="add" companySearchEnabled={isScbConfigured()} />
</div>
)
}