d63d2aecf0
UI cleanup: removed AI-slop (redundant suppliers subtitle, decorative Sparkles glyph), decluttered the article-detail header (single status badge + muted type · #number), standardized the invoice icon Receipt→ReceiptText (no $ in a SEK app), and matched ReportExportMenu trigger size to the primary CTA on list pages. Bookkeeping: surfaced year-end closing in Rapporter (catalog descriptor) and dropped the redundant header button; refactored JournalEntryList to DataList primitives + chunked /api/documents/counts in 50-ID batches (large pages previously 400'd); added optional fraction-digit overrides to formatCurrency. The fiscal-year lock indicator is preserved as a labeled Låst/Stängt badge in FiscalYearSelector. All PR-bot findings triaged as false positives (unused import, formatCurrency öre, lock indicator) or intentional design (year-end placement, empty-state messaging). CI green. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
76 lines
2.2 KiB
TypeScript
76 lines
2.2 KiB
TypeScript
'use client'
|
|
|
|
import { Download, FileSpreadsheet, FileText, Table } from 'lucide-react'
|
|
import { useTranslations } from 'next-intl'
|
|
import { Button } from '@/components/ui/button'
|
|
import {
|
|
DropdownMenu,
|
|
DropdownMenuContent,
|
|
DropdownMenuItem,
|
|
DropdownMenuTrigger,
|
|
} from '@/components/ui/dropdown-menu'
|
|
|
|
/** pdf/xlsx for reports; csv is additionally used by register exports. */
|
|
export type ExportMenuFormat = 'pdf' | 'xlsx' | 'csv'
|
|
|
|
export interface ReportExportItem {
|
|
format: ExportMenuFormat
|
|
href: string
|
|
}
|
|
|
|
/**
|
|
* The single "Exportera" affordance for a report. Replaces the scattered
|
|
* per-format download buttons that used to float inside report card bodies.
|
|
* `children` lets a report append a sibling action (e.g. the VAT review agent).
|
|
*/
|
|
export function ReportExportMenu({
|
|
items,
|
|
children,
|
|
size = 'sm',
|
|
}: {
|
|
items?: ReportExportItem[]
|
|
children?: React.ReactNode
|
|
size?: 'default' | 'sm'
|
|
}) {
|
|
const t = useTranslations('reports')
|
|
const hasItems = !!items && items.length > 0
|
|
if (!hasItems && !children) return null
|
|
|
|
return (
|
|
<div className="flex items-center justify-end gap-2">
|
|
{hasItems && (
|
|
<DropdownMenu>
|
|
<DropdownMenuTrigger asChild>
|
|
<Button variant="outline" size={size}>
|
|
<Download className="h-4 w-4 mr-2" />
|
|
{t('export')}
|
|
</Button>
|
|
</DropdownMenuTrigger>
|
|
<DropdownMenuContent align="end">
|
|
{items!.map((item) => (
|
|
<DropdownMenuItem
|
|
key={item.href}
|
|
onSelect={() => window.open(item.href, '_blank')}
|
|
>
|
|
{item.format === 'pdf' ? (
|
|
<FileText className="h-4 w-4 mr-2" />
|
|
) : item.format === 'csv' ? (
|
|
<Table className="h-4 w-4 mr-2" />
|
|
) : (
|
|
<FileSpreadsheet className="h-4 w-4 mr-2" />
|
|
)}
|
|
{item.format === 'pdf'
|
|
? t('download_pdf')
|
|
: item.format === 'csv'
|
|
? t('download_csv')
|
|
: t('download_excel')}
|
|
</DropdownMenuItem>
|
|
))}
|
|
</DropdownMenuContent>
|
|
</DropdownMenu>
|
|
)}
|
|
{children}
|
|
</div>
|
|
)
|
|
}
|