Files
accounted/components/ui/empty-state.tsx
T
Jakob Wennberg 5cb8c3c1e4 feat: support contact links and SIE import UX polish (#138)
* feat: event log, pending operations, and MCP staging

- Event log system: persist bus events to event_log table for external
  automation platforms. Batch insert for transaction.synced. Daily
  cleanup cron at 02:00 UTC.
- Pending operations: MCP write tools (categorize, create customer,
  create invoice) now stage to pending_operations instead of executing
  directly. Users review and commit/reject from /pending in the web UI.
- Granskning page: card-based review UI with expandable previews,
  commit/reject dialogs. Only shown in nav when pending ops exist.
- Commit route re-executes using core lib functions (no extension
  imports). Guards against stale state (double-commit, deleted entities).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* feat: stage new MCP write tools after main merge

Add staging for 4 new write tools from #133:
- mark_invoice_paid, send_invoice, mark_invoice_sent,
  match_transaction_invoice
- Expand pending_operations CHECK constraint
- Add commit executors with full execution logic
- Add UI labels and generic preview component
- Remove confirm parameter from categorize (single-call staging)
- Fix UUID in pending op title (fetch transaction description)
- Hide Granskning nav when no pending ops

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: address PR review feedback

- Fix TS build error: use `select('*, customer:customers(*)')` for
  match_transaction_invoice to avoid array type inference
- Add status guard to commitSendInvoice (prevents duplicate sends)
- Replace auth.admin.getUserById with user email from session auth
- Restore optimistic lock check in commitMatchTransactionInvoice
- Fix tool description typo: expense_software → expense_office

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* feat: add support contact links and improve SIE import UX

Add a SupportLink component with a contact dialog throughout the app
(nav, help page, settings, MFA, error pages, empty states). Improve
SIE import flow with phased loading states, structured skip breakdowns,
and an elapsed-time counter. Fix MFA enroll stale factor cleanup and
URL encoding for settings return path.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: address PR review — open redirect, XSS, test cleanup, fallback email

- Validate returnTo is a relative path in MFA enroll (prevents open redirect)
- Add afterEach import to event-log-handler tests (fixes handler leak)
- HTML-escape user-supplied subject and message in support email body
- Replace hardcoded personal email with support@gnubok.se fallback

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 11:14:17 +01:00

188 lines
4.9 KiB
TypeScript

'use client'
import * as React from 'react'
import Link from 'next/link'
import { Button } from '@/components/ui/button'
import { cn } from '@/lib/utils'
import {
Receipt,
Users,
ArrowLeftRight,
Camera,
Building2,
FileText,
Calendar,
Plus,
type LucideIcon,
} from 'lucide-react'
import { SupportLink } from '@/components/ui/support-link'
interface EmptyStateProps {
icon?: LucideIcon
title: string
description: string
actionLabel?: string
actionHref?: string
onAction?: () => void
secondaryActionLabel?: string
secondaryActionHref?: string
supportHint?: boolean
className?: string
children?: React.ReactNode
}
/**
* EmptyState - Visar ett vänligt meddelande när det inte finns någon data
*/
export function EmptyState({
icon: Icon,
title,
description,
actionLabel,
actionHref,
onAction,
secondaryActionLabel,
secondaryActionHref,
supportHint,
className,
children,
}: EmptyStateProps) {
return (
<div className={cn('flex flex-col items-center justify-center py-12 px-4 text-center', className)}>
{Icon && (
<div className="mb-6">
<div className="p-5 rounded-full bg-muted">
<Icon className="h-8 w-8 text-muted-foreground" />
</div>
</div>
)}
<h3 className="text-lg font-medium mb-2">{title}</h3>
<p className="text-sm text-muted-foreground max-w-sm mb-6 text-balance">{description}</p>
{supportHint && (
<div className="mb-6">
<SupportLink variant="muted" subject="Behöver hjälp att komma igång">
Behöver du hjälp? Kontakta support
</SupportLink>
</div>
)}
{(actionLabel || children) && (
<div className="flex flex-col sm:flex-row items-center gap-3">
{actionHref && actionLabel && (
<Link href={actionHref}>
<Button>
<Plus className="mr-2 h-4 w-4" />
{actionLabel}
</Button>
</Link>
)}
{onAction && actionLabel && (
<Button onClick={onAction}>
<Plus className="mr-2 h-4 w-4" />
{actionLabel}
</Button>
)}
{secondaryActionHref && secondaryActionLabel && (
<Link href={secondaryActionHref}>
<Button variant="outline">{secondaryActionLabel}</Button>
</Link>
)}
{children}
</div>
)}
</div>
)
}
// Förkonfigurerade tomma tillstånd för vanliga sidor
export function EmptyInvoices() {
return (
<EmptyState
icon={Receipt}
title="Inga fakturor ännu"
description="Skapa din första faktura på under 60 sekunder. Vi fyller i dina uppgifter automatiskt."
actionLabel="Skapa faktura"
actionHref="/invoices/new"
secondaryActionLabel="Lägg till kund först"
secondaryActionHref="/customers/new"
/>
)
}
export function EmptyCustomers({ onAction }: { onAction?: () => void } = {}) {
return (
<EmptyState
icon={Users}
title="Inga kunder ännu"
description="Lägg till dina kunder för att enkelt skapa fakturor och hålla koll på betalningar."
actionLabel="Lägg till kund"
actionHref={onAction ? undefined : '/customers/new'}
onAction={onAction}
/>
)
}
export function EmptyTransactions() {
return (
<EmptyState
icon={ArrowLeftRight}
title="Inga transaktioner"
description="Importera kontoutdrag från din bank för att automatiskt bokföra och få koll på ekonomin."
actionLabel="Importera transaktioner"
actionHref="/import"
supportHint
/>
)
}
export function EmptyReceipts() {
return (
<EmptyState
icon={Camera}
title="Inga kvitton"
description="Ta en bild på ett kvitto för automatisk avläsning och bokföring. Vi sköter resten!"
actionLabel="Skanna kvitto"
actionHref="/receipts/scan"
/>
)
}
export function EmptyDeadlines() {
return (
<EmptyState
icon={Calendar}
title="Inga kommande deadlines"
description="Bra jobbat! Du har inga omedelbara deadlines att ta hand om."
/>
)
}
export function NoBankConnected() {
return (
<EmptyState
icon={Building2}
title="Inga transaktioner importerade"
description="Importera kontoutdrag från din bank för att automatiskt bokföra och få bättre koll på ekonomin."
actionLabel="Importera transaktioner"
actionHref="/import"
supportHint
/>
)
}
export function EmptyReports() {
return (
<EmptyState
icon={FileText}
title="Inga rapporter tillgängliga"
description="Rapporter genereras automatiskt när du har tillräckligt med data. Börja med att skapa fakturor eller importera transaktioner."
actionLabel="Skapa faktura"
actionHref="/invoices/new"
secondaryActionLabel="Importera transaktioner"
secondaryActionHref="/import"
/>
)
}