'use client' import { useTranslations } from 'next-intl' import { Copy, Loader2 } from 'lucide-react' import { Dialog, DialogContent, DialogHeader, DialogTitle, } from '@/components/ui/dialog' import JournalEntryForm, { type FormLine } from '@/components/bookkeeping/JournalEntryForm' export interface CopyPrefill { sourceId: string sourceVoucherLabel: string lines: FormLine[] description: string notes: string } interface Props { open: boolean onOpenChange: (open: boolean) => void /** Fired after a verifikat is created/saved as draft. */ onCreated: () => void /** When set, the form is pre-filled from a copied verifikat. */ copyPrefill?: CopyPrefill | null /** True while the copy source is being fetched. */ isLoading?: boolean } /** * "Ny verifikat" as a modal — the dialog you type a manual voucher into, * instead of an inline tab. Wraps the standalone JournalEntryForm; the form's * own review/confirm dialogs stack on top of this one. */ export default function NewJournalEntryDialog({ open, onOpenChange, onCreated, copyPrefill, isLoading, }: Props) { const t = useTranslations('bookkeeping') return ( e.preventDefault()} onInteractOutside={(e) => e.preventDefault()} > {t('new_entry_dialog_title')} {isLoading ? (
{t('loading_source_voucher')}
) : ( <> {copyPrefill && (

{t('copy_banner_title', { label: copyPrefill.sourceVoucherLabel || t('copy_banner_unknown_label'), })}

{t('copy_banner_body')}

)} )}
) }