da859d7236
* refactor(ui): normalize dense pages to the locked design system Sweep of the info-dense surfaces against .claude/rules/design.md; no behavior changes, classNames and primitive adoption only. - Replace hand-rolled h1s with PageHeader (import, suppliers, kpi, salary/employees, skattekonto, settings layout) and drop the one double title (SalarySettingsContent under the settings h1) - Replace hand-rolled empty states with EmptyState (skattekonto, banking/api-keys/oauth/counterparty settings) and hand-rolled pulse divs with Skeleton (deadlines, report view loaders) - Remove semantic colors used as chrome: amber/emerald banners in AGIPanel and SkatteverketPanel, success/warning tints in kassaflodesanalys, arsredovisning and import become neutral surfaces with the tint kept on the icon only - Full-opacity borders everywhere (border-border/30-60, border-destructive/20-40, border-foreground/30, text-destructive/80) - Snap off-scale spacing (p-5 to p-6, p-2.5 to p-3, gap/mt-x.5 to scale values); KPI metric tiles p-6 to p-4 per the tile rule - Remove the mobile Select that duplicated the invoices status Tabs (TabsList already scrolls horizontally); single Tabs now serves both breakpoints - supplier-invoices: shared formatCurrency instead of a local formatAmount helper; skattekonto: formatDate/formatDateLong/ formatDateTime instead of raw dates and toLocaleString - arsredovisning flerarsoversikt converted to the Table primitive with right-aligned tabular-nums cells - Settings: CardTitle text-base on section cards, one heading idiom in AccountSettingsContent, h3 to h2 in CompanyProfileView Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * refactor(i18n): trim text bloat and fix an untranslated sv string - Fix invoice_credit.create_failed_fallback: sv catalog carried the English "Failed to create credit note"; now "Kunde inte skapa kreditfaktura". Translate new_user_checklist.step3_title in en - Drop descriptions that paraphrase their own title (design.md forbidden pattern): invoice_detail.credited_description, invoice_credit.original_card_description, invoice_editor customer/notes card descriptions (keys deleted from both catalogs, zero remaining usages); the transaction booking DialogDescription becomes sr-only so screen readers keep it - Trim redundant sentences from settings_salary.info_payroll_scope, settings_backup.intro, ext_cloud_backup_long_description, settings.name_description, salary_payments.open_payments_note and shorten invoice_credit.reason_card_description; statutory BFL/tax prose untouched - Normalize toast punctuation (dimensions/self_billing created_description lose the trailing period like their siblings) - common.delete "Radera" to "Ta bort" (zero live call sites; Radera stays reserved for irreversible account/company deletion) Catalogs verified key-identical (4795 keys each) and JSON-parseable. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
99 lines
3.6 KiB
TypeScript
99 lines
3.6 KiB
TypeScript
'use client'
|
|
|
|
import { useTranslations } from 'next-intl'
|
|
import { Button } from '@/components/ui/button'
|
|
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'
|
|
import { Calculator, Loader2 } from 'lucide-react'
|
|
import { formatCurrency } from '@/lib/utils'
|
|
|
|
export interface EntryPreviewLine {
|
|
account_number: string
|
|
line_description: string
|
|
debit_amount: number | null
|
|
credit_amount: number | null
|
|
}
|
|
|
|
export interface EntryPreview {
|
|
description: string
|
|
lines: EntryPreviewLine[]
|
|
}
|
|
|
|
export interface PreviewData {
|
|
salaryEntry: EntryPreview | null
|
|
avgifterEntry: EntryPreview | null
|
|
vacationEntry: EntryPreview | null
|
|
pensionEntry?: EntryPreview | null
|
|
}
|
|
|
|
interface RunJournalPreviewProps {
|
|
preview: PreviewData
|
|
// When provided (draft + write access), a "Beräkna om" button renders in the
|
|
// header — recalculation sits on the output it refreshes.
|
|
onRecalculate?: () => void
|
|
recalculating?: boolean
|
|
}
|
|
|
|
export function RunJournalPreview({ preview, onRecalculate, recalculating }: RunJournalPreviewProps) {
|
|
const t = useTranslations('salary_run')
|
|
|
|
const entries = [
|
|
preview.salaryEntry,
|
|
preview.avgifterEntry,
|
|
preview.vacationEntry,
|
|
preview.pensionEntry,
|
|
].filter(Boolean) as EntryPreview[]
|
|
|
|
return (
|
|
<Card>
|
|
<CardHeader className="flex flex-row items-center justify-between gap-3 space-y-0">
|
|
<CardTitle className="text-base">{t('journal_preview_title')}</CardTitle>
|
|
{onRecalculate && (
|
|
<Button variant="outline" size="sm" onClick={onRecalculate} disabled={recalculating}>
|
|
{recalculating ? (
|
|
<Loader2 className="mr-2 h-4 w-4 animate-spin" />
|
|
) : (
|
|
<Calculator className="mr-2 h-4 w-4" />
|
|
)}
|
|
{t('action_recalculate')}
|
|
</Button>
|
|
)}
|
|
</CardHeader>
|
|
<CardContent className="space-y-6">
|
|
{entries.length === 0 ? (
|
|
<p className="text-sm text-muted-foreground">{t('journal_preview_nollkorning')}</p>
|
|
) : (
|
|
entries.map((entry, idx) => (
|
|
<div key={idx} className="space-y-2">
|
|
<h4 className="text-sm font-medium">{entry.description}</h4>
|
|
<table className="w-full text-xs">
|
|
<thead className="[&_th]:font-medium [&_th]:text-[11px] [&_th]:uppercase [&_th]:tracking-wider [&_th]:text-muted-foreground">
|
|
<tr className="border-b">
|
|
<th className="text-left py-1">{t('journal_th_account')}</th>
|
|
<th className="text-left py-1">{t('journal_th_description')}</th>
|
|
<th className="text-right py-1">{t('journal_th_debit')}</th>
|
|
<th className="text-right py-1">{t('journal_th_credit')}</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{entry.lines.map((line, li) => (
|
|
<tr key={li} className="border-t border-border">
|
|
<td className="py-1.5 tabular-nums font-mono">{line.account_number}</td>
|
|
<td className="py-1.5 text-muted-foreground">{line.line_description}</td>
|
|
<td className="py-1.5 text-right tabular-nums">
|
|
{line.debit_amount ? formatCurrency(line.debit_amount) : ''}
|
|
</td>
|
|
<td className="py-1.5 text-right tabular-nums">
|
|
{line.credit_amount ? formatCurrency(line.credit_amount) : ''}
|
|
</td>
|
|
</tr>
|
|
))}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
))
|
|
)}
|
|
</CardContent>
|
|
</Card>
|
|
)
|
|
}
|