Files
accounted/components/reports/ReportLibrary.tsx
T
Jakob WennbergandClaude Opus 4.8 2da9c71eb3 UI badge cleanup + /chart-of-accounts route + loop skills (#850)
Bundles three separable concerns:

- style(ui): badge audit + cleanup across 45 files — real-status chips use Badge variants (raw Tailwind colors dropped), non-status count/type/label chips demoted to muted text, clustered badges consolidated; 20 unused imports removed.
- feat(bookkeeping): Kontoplan moved to a dedicated /chart-of-accounts route (nav + command palette wired); /bookkeeping shows the journal list only.
- chore(skills): loop-* automation skills + design-scan workflow under .claude/.

fix(reports): restored the destructive count badge on blocking errors in the periodisk sammanställning (EC Sales List) — a genuine status cue the audit had wrongly flattened; flagged by the PR reviewer and Swedish compliance bot, now clean.

All CI green; compliance bots report no findings.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-01 14:29:23 +02:00

72 lines
2.2 KiB
TypeScript

'use client'
import { useTranslations } from 'next-intl'
import { ChevronRight } from 'lucide-react'
import {
DataList,
DataListMeta,
DataListPrimary,
DataListRow,
} from '@/components/ui/data-list'
import { Badge } from '@/components/ui/badge'
import { getLibrarySections, type ReportDescriptor } from '@/lib/reports/catalog'
import type { EntityType } from '@/types'
/**
* The report library — the calm landing for /reports. Reports grouped by
* accounting taxonomy, each section a single DataList. One report = one row =
* one destination; no data preview, so the landing stays a fast index.
*/
export function ReportLibrary({
entityType,
hasEmployees,
onOpen,
}: {
entityType?: EntityType
hasEmployees?: boolean
onOpen: (slug: string) => void
}) {
const t = useTranslations('reports')
const sections = getLibrarySections(entityType, hasEmployees)
return (
<div className="space-y-8">
{sections.map((section) => (
<div key={section.category} className="space-y-3">
<h2 className="text-sm font-medium uppercase tracking-wider text-muted-foreground">
{t(section.labelKey)}
</h2>
<DataList>
{section.items.map((item) => (
<DataListRow
key={item.slug}
onClick={() => onOpen(item.slug)}
trailing={
<>
<EntityBadge item={item} />
{item.params === 'calendar' && (
<Badge variant="secondary">{t('calendar_badge')}</Badge>
)}
<ChevronRight className="h-4 w-4 text-muted-foreground" />
</>
}
>
<DataListPrimary>{t(item.labelKey)}</DataListPrimary>
<DataListMeta>{t(item.descKey)}</DataListMeta>
</DataListRow>
))}
</DataList>
</div>
))}
</div>
)
}
function EntityBadge({ item }: { item: ReportDescriptor }) {
if (item.entityType === 'enskild_firma')
return <span className="text-xs text-muted-foreground">EF</span>
if (item.entityType === 'aktiebolag')
return <span className="text-xs text-muted-foreground">AB</span>
return null
}