Files
accounted/app/(dashboard)/clients/NewClientCompanyButton.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

62 lines
1.9 KiB
TypeScript

'use client'
import { useState } from 'react'
import { useRouter } from 'next/navigation'
import { useTranslations } from 'next-intl'
import { Plus } from 'lucide-react'
import { Button } from '@/components/ui/button'
import {
Dialog,
DialogContent,
DialogDescription,
DialogFooter,
DialogHeader,
DialogTitle,
} from '@/components/ui/dialog'
/**
* "Nytt klientbolag" (WL-15): header primary action on the cockpit, rendered
* only for byrå owner/admin (the page checks; the create RPC enforces the
* same gate in the database). Confirm up front (design convention 10): the
* dialog states that the company is added to the byrå's agreement (+1 on the
* monthly invoice) BEFORE routing into today's company creation flow with
* the explicit byrå team binding (/companies/new-client).
*/
export default function NewClientCompanyButton() {
const t = useTranslations('clients')
const router = useRouter()
const [open, setOpen] = useState(false)
const [navigating, setNavigating] = useState(false)
return (
<>
<Button onClick={() => setOpen(true)}>
<Plus className="mr-2 h-4 w-4" />
{t('new_client_company')}
</Button>
<Dialog open={open} onOpenChange={setOpen}>
<DialogContent>
<DialogHeader>
<DialogTitle>{t('new_client_company')}</DialogTitle>
<DialogDescription>{t('added_to_agreement')}</DialogDescription>
</DialogHeader>
<DialogFooter>
<Button variant="outline" onClick={() => setOpen(false)} disabled={navigating}>
{t('cancel')}
</Button>
<Button
disabled={navigating}
onClick={() => {
setNavigating(true)
router.push('/companies/new-client')
}}
>
{t('continue')}
</Button>
</DialogFooter>
</DialogContent>
</Dialog>
</>
)
}