'use client' import { useTranslations } from 'next-intl' import { Deadline } from '@/types' import { cn } from '@/lib/utils' import { isDeadlineOverdue } from '@/lib/calendar/utils' import { HOVER_REVEAL_CLASS, QUIET_LINK_CLASS } from '@/components/ui/dry-table' import { deadlineDateLabel } from './DeadlineRow' import { Pencil } from 'lucide-react' /** * System tax deadlines that legally share the skattekonto date ("den 12:e"): * for a small monthly-moms employer, moms + AGI (+ debiterad preliminärskatt) * all fall due the same day. Rendering them as one grouped row instead of * 2-3 identical-date rows keeps the list scannable. */ export const SKATTEKONTO_GROUP_TYPES = new Set([ 'moms_monthly', 'moms_quarterly', 'moms_yearly', 'f_skatt', 'arbetsgivardeklaration', 'skatteinbetalning', ]) export function isSkattekontoDeadline(d: Deadline): boolean { return ( !d.is_completed && d.source === 'system' && d.tax_deadline_type !== null && SKATTEKONTO_GROUP_TYPES.has(d.tax_deadline_type) ) } interface DeadlineGroupRowProps { /** Two or more skattekonto deadlines sharing the same due_date. */ deadlines: Deadline[] onEdit?: (deadline: Deadline) => void /** "Markera klar": the list confirms before toggling. */ onRequestToggle: (deadline: Deadline) => void } /** * One thread row for all skattekonto obligations on a shared due date * (concept scene 17 row language): the date renders once, each obligation is * a sub-row with its own quiet "Markera klar". */ export function DeadlineGroupCard({ deadlines, onEdit, onRequestToggle }: DeadlineGroupRowProps) { const t = useTranslations('deadlines') const first = deadlines[0] const overdue = deadlines.some(isDeadlineOverdue) return (
{deadlineDateLabel(first.due_date)} · {t('group_skattekonto_title')}
{t('group_same_day', { count: deadlines.length })}
{deadline.title}
{onEdit && ( )}