'use client' import { useState } from 'react' import Link from 'next/link' import { useTranslations } from 'next-intl' import { Badge } from '@/components/ui/badge' import { Button } from '@/components/ui/button' import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, } from '@/components/ui/dialog' import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, } from '@/components/ui/dropdown-menu' import { AlertTriangle, ArrowLeft, Loader2, MoreVertical, Trash2, Undo2 } from 'lucide-react' import { formatDate } from '@/lib/utils' import { periodLabelOf, type RunDetail } from './types' const STATUS_VARIANTS: Record = { draft: 'secondary', review: 'warning', approved: 'default', paid: 'success', booked: 'success', corrected: 'outline', } interface RunHeaderProps { run: RunDetail canWrite: boolean actionLoading: string | null employeeCount: number onDelete: () => void onCorrect: () => void } export function RunHeader({ run, canWrite, actionLoading, employeeCount, onDelete, onCorrect }: RunHeaderProps) { const t = useTranslations('salary_run') const tSalary = useTranslations('salary') const [correctOpen, setCorrectOpen] = useState(false) const periodLabel = periodLabelOf(run) const statusKey = `status_${run.status}` const showMenu = canWrite && (run.status === 'draft' || run.status === 'booked') return (

{t('title', { period: periodLabel })}

{tSalary(statusKey)}
{/* Inline property row — Linear-style dot-separated metadata. */}
{t('payment_date_label')} {formatDate(run.payment_date)} · {t('header_employees', { count: employeeCount })} {run.is_correction && run.corrects_run_id && ( <> · {t('correction_badge')} {t('corrects_link', { period: periodLabel })} )} {run.status === 'corrected' && run.corrected_by_run_id && ( <> · {t('corrected_by_link')} )}
{showMenu && ( {run.status === 'draft' && ( {t('action_delete_draft')} )} {run.status === 'booked' && ( setCorrectOpen(true)}> {t('action_correct')} )} )}
{/* Correction confirm — storno per BFL 5 kap. 5 §, nothing is deleted. */} {t('correct_dialog_title')} {t('correct_dialog_body', { period: periodLabel })} {run.agi_generated_at && ( {t('correct_dialog_agi_warning')} )}
) }