e42da5c32b
* refactor: remove unnecessary secondary action from EmptyInvoices component * feat: add direct provider layer and provider_consents migration Replace Arcim Sync gateway dependency with direct provider clients for Fortnox, Visma, Briox, Bokio, and Björn Lundén. Adds OAuth config, rate limiting, retry logic, data fetching, and consent storage via new provider_consents/tokens/otc tables. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * refactor: migrate arcim extension to direct provider APIs Replace Arcim Sync gateway calls with direct provider API access. Use FortnoxClient.getText() for SIE endpoints that return plain text instead of JSON. OAuth callback now returns HTML with postMessage to communicate with the opener window instead of redirecting. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: use OAuth popup window instead of new tab Open provider login in a centered popup that auto-closes on completion via postMessage, keeping the user on a single tab. Falls back to redirect flow if popup is blocked. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * feat: add connection status, consent reuse, and SIE duplicate detection - Add listConsents() to query active consents by company - Add GET /status route returning consents, SIE import history, and entity counts - /connect reuses existing accepted consent instead of creating duplicates, and cleans up abandoned (status 0) consents - /status only returns accepted (status 1) consents - /sie-data checks each file's SHA-256 hash against sie_imports to report per-file import status (alreadyImported, importedAt) - /sie-data blocks on SIE validation failure (mirrors manual upload) - /import-sie validates unmapped accounts and auto-activates missing BAS accounts in chart_of_accounts (mirrors manual upload) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * feat: show active connections, SIE file status, and smart re-sync UI - ProviderStep shows active connections with last import date, entity counts, "Synka igen" button, and disconnect option - Already-connected providers greyed out in selection grid - OptionsStep shows per-fiscal-year import status (imported vs new) - SIE toggle disabled with explanation when all files already imported - handleStartMigration skips already-imported SIE files - Auto-skip mapping step and disable SIE on re-sync when up to date - Result step hides empty "0 importerade" rows and shows "Allt är uppdaterat" when nothing new was fetched - OptionRow supports disabled state Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: adjust COMING_SOON_PROVIDERS based on NODE_ENV for development and production * Removed duplicate * Removed duplicate * refactor: redesign reports page navigation from grid boxes to bordered card layout Replace the 4-column grid of uneven TabsList boxes with a CSS grid card using auto-sized columns separated by 1px border dividers. All sections now share equal height via items-stretch, with clear visual separation between groups. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * chore: trigger Vercel deployment * Update supabase/migrations/20260402010000_provider_consents.sql Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> * Update lib/providers/rate-limiter.ts Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> * chore: re-trigger checks after migration sync --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
186 lines
4.8 KiB
TypeScript
186 lines
4.8 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"
|
|
/>
|
|
)
|
|
}
|
|
|
|
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"
|
|
/>
|
|
)
|
|
}
|