Files
accounted/components/reports/ReportExportMenu.tsx
T
Jakob Wennberg cb7b31819b feat(vat): Momsdeklaration as Stegen - stepper, flat steps, house toolbar (#1154)
* feat(vat): Momsdeklaration as Stegen (horizontal stepper, one step at a time)

The founder-picked concept variant for Moms: the four pipeline sections
(kontrollera, granska, bokfor, lamna in) become a clickable horizontal
stepper with honest per-step status subs (fel/varningar from the
pre-flight checks, att betala/aterfa from ruta 49, bokford/utkast lifted
from the settlement proposal via a new optional onStatus callback on
VatBookingCard) and one step's content rendered at a time with quiet
Nasta-links. Errors land on step 1, otherwise Granska. SkatteverketPanel
moves inside steg 4 next to the manual filing card when a declaration
exists; the no-data states keep it standalone. A period switch resets the
step choice. All checks, booking, drilldowns, exports and the SKV submit
flow are untouched.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* polish(vat): de-box the Stegen step contents to the concept language

Founder review: the stepper was new but the step contents kept the old
card chrome. Now flat on the panel throughout: the period picker is a
quiet toolbar row (no card, no labels), Granska renders as a centered
document column with sans eyebrow group heads and ruta 49 as an
emphasized document foot, the pre-flight checks are hairline rows with
quiet Korrigera links instead of boxed alerts and outline buttons,
VatBookingCard and VatManualFilingCard lose their cards (notes become
flat muted/attn lines), and SkatteverketPanel's card shells become flat
sections with sans uppercase eyebrows. All logic, flows and dialogs
untouched.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* polish(vat): black Exportera, no page-level Fraga Anna, clear Nasta buttons

Founder feedback on Stegen: the toolbar keeps only Exportera and it
wears the primary pill (ReportExportMenu gains an optional variant prop,
outline stays the default everywhere else); the AgentSparkleButton
leaves the page (the global assistant bubble remains); the Nasta step
links become white outline pill buttons so the forward path reads as
clearly as the export action. All other buttons on the page already
follow the house variants (primary/outline/ghost/quiet links).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-07-24 18:32:53 +02:00

86 lines
2.6 KiB
TypeScript

'use client'
import { Download, FileCode, 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; xml is the
* Skatteverket eSKD momsdeklaration file.
*/
export type ExportMenuFormat = 'pdf' | 'xlsx' | 'csv' | 'xml'
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',
variant = 'outline',
}: {
items?: ReportExportItem[]
children?: React.ReactNode
size?: 'default' | 'sm'
/** Trigger style; the VAT Stegen page uses the primary pill. */
variant?: 'outline' | 'default'
}) {
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={variant} 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" />
) : item.format === 'xml' ? (
<FileCode 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')
: item.format === 'xml'
? t('download_xml')
: t('download_excel')}
</DropdownMenuItem>
))}
</DropdownMenuContent>
</DropdownMenu>
)}
{children}
</div>
)
}