chore: repo-wide bloat sweep, remove dead code and fold duplicate helpers (#2150)

* chore: repo-wide bloat sweep, remove dead code and fold duplicate helpers

Remove 33 dead files, ~270 unreferenced exports/types, 13 dead i18n
namespaces and 4 unused dependencies; fold byte-identical helper copies
into one canonical home each (lib/utils chunk/sleep/utcDateStamp,
lib/dates/iso, lib/invariants/uuid, lib/xml/escape, lib/reports/sru/format,
lib/pdf/number-text, lib/browser/panel-request, lib/api/v1/body +
v1ValidationError rolled out to ~55 v1 routes, booking-template schemas).

No behaviour change: v1 bodies and status codes, MCP tool schemas, DB
writes and money math are untouched. Naive ore rounding was deliberately
not swapped for roundOre; see DECISIONS.md 2026-09-02 for the full list
of things left alone on purpose.

tsc, lint, 19588 unit tests and check:guards green; antipattern baseline
ratcheted (naive-ore-round 622 -> 620, hand-rolled-invariant 115 -> 113).

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

* test(transactions): import RawTransaction from @/types after the ingest re-export removal

CI's type ratchet (check:types, full tsconfig) caught the one test file
that still imported the type through lib/transactions/ingest.

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

---------

Co-authored-by: Jakob Wennberg <311770904+jakobwennberg-oss@users.noreply.github.com>
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
Jakob Wennberg
2026-09-02 11:51:16 +02:00
committed by GitHub
co-authored by Claude Fable 5.1 Jakob Wennberg
parent 18cbc4c30a
commit f266c386f3
359 changed files with 1796 additions and 11199 deletions
-73
View File
@@ -6,12 +6,7 @@ import { useTranslations } from 'next-intl'
import { Button } from '@/components/ui/button'
import { cn } from '@/lib/utils'
import {
ReceiptText,
Users,
ArrowLeftRight,
Building2,
FileText,
Calendar,
Plus,
TrendingUp,
type LucideIcon,
@@ -105,20 +100,6 @@ export function EmptyState({
// Preset empty states for common pages
export function EmptyInvoices({ onAction }: { onAction?: () => void } = {}) {
const t = useTranslations('empty')
return (
<EmptyState
icon={ReceiptText}
title={t('preset_invoices_title')}
description={t('preset_invoices_description')}
actionLabel={t('preset_invoices_action')}
actionHref={onAction ? undefined : '/invoices?new=1'}
onAction={onAction}
/>
)
}
export function EmptyCustomers({ onAction }: { onAction?: () => void } = {}) {
const t = useTranslations('empty')
return (
@@ -133,60 +114,6 @@ export function EmptyCustomers({ onAction }: { onAction?: () => void } = {}) {
)
}
export function EmptyTransactions() {
const t = useTranslations('empty')
return (
<EmptyState
icon={ArrowLeftRight}
title={t('preset_transactions_title')}
description={t('preset_transactions_description')}
actionLabel={t('preset_transactions_action')}
actionHref="/import"
supportHint
/>
)
}
export function EmptyDeadlines() {
const t = useTranslations('empty')
return (
<EmptyState
icon={Calendar}
title={t('preset_deadlines_title')}
description={t('preset_deadlines_description')}
/>
)
}
export function NoBankConnected() {
const t = useTranslations('empty')
return (
<EmptyState
icon={Building2}
title={t('preset_no_bank_title')}
description={t('preset_no_bank_description')}
actionLabel={t('preset_no_bank_action')}
actionHref="/import"
supportHint
/>
)
}
export function EmptyReports() {
const t = useTranslations('empty')
return (
<EmptyState
icon={FileText}
title={t('preset_reports_title')}
description={t('preset_reports_description')}
actionLabel={t('preset_reports_action')}
actionHref="/invoices?new=1"
secondaryActionLabel={t('preset_reports_secondary')}
secondaryActionHref="/import"
/>
)
}
/**
* Byrå cockpit: no client companies yet. A preset, not a bare <EmptyState
* icon={TrendingUp} />, because the only caller is a Server Component: a
-21
View File
@@ -1,21 +0,0 @@
import { Upload } from 'lucide-react'
import { Button } from '@/components/ui/button'
import Link from 'next/link'
interface FallbackPromptProps {
message: string
linkHref: string
linkLabel: string
}
export function FallbackPrompt({ message, linkHref, linkLabel }: FallbackPromptProps) {
return (
<div className="flex items-center gap-3 rounded-lg border border-border bg-muted/50 p-4">
<Upload className="h-5 w-5 shrink-0 text-muted-foreground" />
<p className="flex-1 text-sm text-muted-foreground">{message}</p>
<Button variant="outline" size="sm" asChild>
<Link href={linkHref}>{linkLabel}</Link>
</Button>
</div>
)
}
-147
View File
@@ -1,147 +0,0 @@
"use client"
import * as React from "react"
import * as DialogPrimitive from "@radix-ui/react-dialog"
import { X } from "lucide-react"
import { cn } from "@/lib/utils"
const Sheet = DialogPrimitive.Root
const SheetTrigger = DialogPrimitive.Trigger
const SheetClose = DialogPrimitive.Close
const SheetPortal = DialogPrimitive.Portal
const SheetOverlay = React.forwardRef<
React.ElementRef<typeof DialogPrimitive.Overlay>,
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay>
>(({ className, ...props }, ref) => (
<DialogPrimitive.Overlay
ref={ref}
className={cn(
"fixed inset-0 z-50 bg-black/50 dark:bg-black/60 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
className
)}
{...props}
/>
))
SheetOverlay.displayName = DialogPrimitive.Overlay.displayName
type SheetSide = "top" | "right" | "bottom" | "left"
const sideClasses: Record<SheetSide, string> = {
top:
"inset-x-0 top-0 border-b data-[state=open]:slide-in-from-top data-[state=closed]:slide-out-to-top",
right:
"inset-y-0 right-0 h-full w-3/4 border-l sm:max-w-sm data-[state=open]:slide-in-from-right data-[state=closed]:slide-out-to-right",
bottom:
"inset-x-0 bottom-0 border-t data-[state=open]:slide-in-from-bottom data-[state=closed]:slide-out-to-bottom",
left:
"inset-y-0 left-0 h-full w-3/4 border-r sm:max-w-sm data-[state=open]:slide-in-from-left data-[state=closed]:slide-out-to-left",
}
interface SheetContentProps
extends React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content> {
side?: SheetSide
}
const SheetContent = React.forwardRef<
React.ElementRef<typeof DialogPrimitive.Content>,
SheetContentProps
>(({ className, children, side = "right", onInteractOutside, ...props }, ref) => (
<SheetPortal>
<SheetOverlay />
<DialogPrimitive.Content
ref={ref}
// Same companion-overlay guard as DialogContent: a portaled panel
// marked data-dialog-companion counts as an inside interaction.
onInteractOutside={(event) => {
onInteractOutside?.(event)
const target = event.target
if (target instanceof Element && target.closest('[data-dialog-companion]')) {
event.preventDefault()
}
}}
className={cn(
"fixed z-50 flex flex-col gap-4 bg-background p-6 transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-200 data-[state=open]:duration-300",
sideClasses[side],
className
)}
{...props}
>
{children}
<DialogPrimitive.Close className="absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none">
<X className="h-4 w-4" />
<span className="sr-only">Close</span>
</DialogPrimitive.Close>
</DialogPrimitive.Content>
</SheetPortal>
))
SheetContent.displayName = DialogPrimitive.Content.displayName
const SheetHeader = ({
className,
...props
}: React.HTMLAttributes<HTMLDivElement>) => (
<div
className={cn("flex flex-col space-y-1.5 text-left", className)}
{...props}
/>
)
SheetHeader.displayName = "SheetHeader"
const SheetFooter = ({
className,
...props
}: React.HTMLAttributes<HTMLDivElement>) => (
<div
className={cn(
"flex flex-col-reverse gap-2 sm:flex-row sm:justify-end sm:space-x-2 sm:gap-0",
className
)}
{...props}
/>
)
SheetFooter.displayName = "SheetFooter"
const SheetTitle = React.forwardRef<
React.ElementRef<typeof DialogPrimitive.Title>,
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title>
>(({ className, ...props }, ref) => (
// data-ph-unmask: sheet titles are static i18n chrome in session replays;
// a title carrying user data adds data-ph-mask at the call site.
<DialogPrimitive.Title
ref={ref}
data-ph-unmask=""
className={cn("break-words text-base tracking-tight", className)}
{...props}
/>
))
SheetTitle.displayName = DialogPrimitive.Title.displayName
const SheetDescription = React.forwardRef<
React.ElementRef<typeof DialogPrimitive.Description>,
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Description>
>(({ className, ...props }, ref) => (
<DialogPrimitive.Description
ref={ref}
data-ph-unmask=""
className={cn("break-words text-sm text-muted-foreground", className)}
{...props}
/>
))
SheetDescription.displayName = DialogPrimitive.Description.displayName
export {
Sheet,
SheetPortal,
SheetOverlay,
SheetTrigger,
SheetClose,
SheetContent,
SheetHeader,
SheetFooter,
SheetTitle,
SheetDescription,
}