* feat: add user locale preference to user_preferences table
- Introduced a new column 'locale' in the user_preferences table to store per-user UI language preferences.
- Added a CHECK constraint to ensure only supported locales ('sv', 'en') are allowed.
- Triggered a schema reload notification for the changes.
chore: declare CSS module support in TypeScript
- Added a declaration for CSS modules in globals.d.ts to enable TypeScript support for importing CSS files.
* feat: add Swish as an invoice payment method in company settings
259 lines
13 KiB
TypeScript
259 lines
13 KiB
TypeScript
'use client'
|
|
|
|
import Link from 'next/link'
|
|
import { useTranslations } from 'next-intl'
|
|
import {
|
|
ArrowRight,
|
|
CheckCircle2,
|
|
FileCheck,
|
|
FileText,
|
|
Landmark,
|
|
ArrowRightLeft,
|
|
ShieldCheck,
|
|
} from 'lucide-react'
|
|
import { cn } from '@/lib/utils'
|
|
import { ENABLED_EXTENSION_IDS } from '@/lib/extensions/_generated/enabled-extensions'
|
|
import { getBranding } from '@/lib/branding/service'
|
|
|
|
const branding = getBranding()
|
|
|
|
interface NewUserChecklistProps {
|
|
onFreshStart: () => void
|
|
className?: string
|
|
/**
|
|
* Whether the active user already has a Skatteverket OAuth connection.
|
|
* When true the Skatteverket step renders as completed instead of as a CTA.
|
|
*/
|
|
hasSkatteverketConnected?: boolean
|
|
}
|
|
|
|
export default function NewUserChecklist({
|
|
onFreshStart,
|
|
className,
|
|
hasSkatteverketConnected,
|
|
}: NewUserChecklistProps) {
|
|
const t = useTranslations('new_user_checklist')
|
|
const hasMigration = ENABLED_EXTENSION_IDS.has('arcim-migration')
|
|
const hasBanking = ENABLED_EXTENSION_IDS.has('enable-banking')
|
|
const hasSkatteverket = ENABLED_EXTENSION_IDS.has('skatteverket')
|
|
|
|
return (
|
|
<div className={cn('min-h-[75vh] flex flex-col items-center justify-center px-4 sm:px-0 stagger-enter', className)}>
|
|
<div className="w-full max-w-2xl">
|
|
{/* Header */}
|
|
<div className="text-center mb-8 md:mb-12">
|
|
<h1 className="font-display text-2xl md:text-3xl font-medium tracking-tight">
|
|
{t('welcome', { appName: branding.appName.toLowerCase() })}
|
|
</h1>
|
|
<p className="text-muted-foreground text-sm md:text-base leading-relaxed max-w-md mx-auto mt-3">
|
|
{t('intro')}
|
|
</p>
|
|
</div>
|
|
|
|
{/* Step 1: Migrate bookkeeping */}
|
|
<div className="mb-6 md:mb-8">
|
|
<div className="flex items-center gap-3 mb-4">
|
|
<span className="h-7 w-7 rounded-full bg-foreground text-background flex items-center justify-center text-xs font-semibold flex-shrink-0 tabular-nums">
|
|
1
|
|
</span>
|
|
<h2 className="font-display text-base font-medium tracking-tight">
|
|
{t('step1_title')}
|
|
</h2>
|
|
</div>
|
|
|
|
<div className="space-y-3 ml-0 sm:ml-10">
|
|
{hasMigration && (
|
|
<Link
|
|
href="/import?mode=migration"
|
|
className="group block p-4 sm:p-5 rounded-xl border border-primary/20 bg-primary/[0.02] hover:bg-primary/[0.05] hover:border-primary/40 transition-all duration-150 active:scale-[0.99]"
|
|
>
|
|
<div className="flex items-start gap-3 sm:gap-4">
|
|
<div className="p-2 sm:p-2.5 rounded-lg bg-primary/[0.08] group-hover:bg-primary/[0.12] transition-colors flex-shrink-0">
|
|
<ArrowRightLeft className="h-4 w-4 sm:h-5 sm:w-5 text-primary" />
|
|
</div>
|
|
<div className="flex-1 min-w-0">
|
|
<p className="font-medium group-hover:text-primary transition-colors text-sm sm:text-base">
|
|
{t('migrate_title')}
|
|
</p>
|
|
<p className="text-xs sm:text-sm text-muted-foreground mt-1 sm:mt-1.5 leading-relaxed underline decoration-foreground/20 underline-offset-2">
|
|
{t('migrate_description')}
|
|
</p>
|
|
<div className="flex flex-wrap gap-1.5 sm:gap-2 mt-2.5 sm:mt-3">
|
|
{([
|
|
{ name: 'Fortnox', logo: '/logos/fortnox.svg' },
|
|
{ name: 'Visma', logo: '/logos/visma.jpeg' },
|
|
{ name: 'Bokio', logo: '/logos/bokio.png' },
|
|
{ name: 'Björn Lundén', logo: '/logos/bjornlunden.png' },
|
|
{ name: 'Briox', logo: '/logos/Briox_logo.png' },
|
|
] as const).map(provider => (
|
|
<div key={provider.name} className="flex items-center gap-1 sm:gap-1.5 rounded border border-border/60 bg-muted/30 px-1.5 sm:px-2 py-0.5 sm:py-1">
|
|
<img src={provider.logo} alt={provider.name} className="h-3.5 w-3.5 sm:h-4 sm:w-4 shrink-0 rounded-sm object-contain" />
|
|
<span className="text-[10px] sm:text-[11px] font-medium text-muted-foreground">{provider.name}</span>
|
|
</div>
|
|
))}
|
|
</div>
|
|
</div>
|
|
<ArrowRight className="h-4 w-4 text-muted-foreground/40 group-hover:text-primary/60 mt-1 flex-shrink-0 transition-colors" />
|
|
</div>
|
|
</Link>
|
|
)}
|
|
|
|
<Link
|
|
href="/import?mode=sie"
|
|
className="group block p-4 sm:p-5 rounded-xl border border-border/60 hover:border-primary/40 hover:bg-primary/[0.02] transition-all duration-150 active:scale-[0.99]"
|
|
>
|
|
<div className="flex items-start gap-3 sm:gap-4">
|
|
<div className="p-2 sm:p-2.5 rounded-lg bg-muted/60 group-hover:bg-primary/[0.08] transition-colors flex-shrink-0">
|
|
<FileText className="h-4 w-4 sm:h-5 sm:w-5 text-muted-foreground group-hover:text-primary transition-colors" />
|
|
</div>
|
|
<div className="flex-1 min-w-0">
|
|
<p className="font-medium group-hover:text-primary transition-colors text-sm sm:text-base">
|
|
{t('sie_title')}
|
|
</p>
|
|
<p className="text-xs sm:text-sm text-muted-foreground mt-1 sm:mt-1.5 leading-relaxed">
|
|
{t('sie_description')}
|
|
</p>
|
|
</div>
|
|
<ArrowRight className="h-4 w-4 text-muted-foreground/40 group-hover:text-primary/60 mt-1 flex-shrink-0 transition-colors" />
|
|
</div>
|
|
</Link>
|
|
</div>
|
|
</div>
|
|
|
|
{/* Step 2: Connect bank */}
|
|
<div className="mb-6 md:mb-8">
|
|
<div className="flex items-center gap-3 mb-4">
|
|
<span className="h-7 w-7 rounded-full bg-foreground text-background flex items-center justify-center text-xs font-semibold flex-shrink-0 tabular-nums">
|
|
2
|
|
</span>
|
|
<h2 className="font-display text-base font-medium tracking-tight">
|
|
{t('step2_title')}
|
|
</h2>
|
|
</div>
|
|
|
|
<div className="ml-0 sm:ml-10">
|
|
<Link
|
|
href={hasBanking ? '/import?mode=psd2' : '/import?mode=bank'}
|
|
className="group block p-4 sm:p-5 rounded-xl border border-border/60 hover:border-primary/40 hover:bg-primary/[0.02] transition-all duration-150 active:scale-[0.99]"
|
|
>
|
|
<div className="flex items-start gap-3 sm:gap-4">
|
|
<div className="p-2 sm:p-2.5 rounded-lg bg-muted/60 group-hover:bg-primary/[0.08] transition-colors flex-shrink-0">
|
|
<Landmark className="h-4 w-4 sm:h-5 sm:w-5 text-muted-foreground group-hover:text-primary transition-colors" />
|
|
</div>
|
|
<div className="flex-1 min-w-0">
|
|
<p className="font-medium group-hover:text-primary transition-colors text-sm sm:text-base">
|
|
{t('bank_title')}
|
|
</p>
|
|
<p className="text-xs sm:text-sm text-muted-foreground mt-1 sm:mt-1.5 leading-relaxed">
|
|
{hasBanking
|
|
? t('bank_description_psd2')
|
|
: t('bank_description_file')}
|
|
</p>
|
|
</div>
|
|
<ArrowRight className="h-4 w-4 text-muted-foreground/40 group-hover:text-primary/60 mt-1 flex-shrink-0 transition-colors" />
|
|
</div>
|
|
</Link>
|
|
</div>
|
|
</div>
|
|
|
|
{/* Step 3: Connect Skatteverket — only when the extension is enabled.
|
|
Optional: connecting here lets gnubok submit moms + AGI and read
|
|
skattekonto saldo, but the user can skip and do it later from
|
|
/settings/skatteverket. The OAuth flow returns to the dashboard
|
|
via return_to=/, which clears the gate via the same path the
|
|
user would take naturally. */}
|
|
{hasSkatteverket && (
|
|
<div className="mb-8 md:mb-12">
|
|
<div className="flex items-center gap-3 mb-4">
|
|
<span className={cn(
|
|
'h-7 w-7 rounded-full flex items-center justify-center text-xs font-semibold flex-shrink-0 tabular-nums',
|
|
hasSkatteverketConnected
|
|
? 'bg-emerald-100 text-emerald-700 dark:bg-emerald-900/40 dark:text-emerald-300'
|
|
: 'bg-foreground text-background',
|
|
)}>
|
|
{hasSkatteverketConnected
|
|
? <CheckCircle2 className="h-4 w-4" />
|
|
: '3'}
|
|
</span>
|
|
<h2 className="font-display text-base font-medium tracking-tight">
|
|
{t('step3_title')}
|
|
</h2>
|
|
<span className="text-xs text-muted-foreground">{t('optional_suffix')}</span>
|
|
</div>
|
|
|
|
<div className="ml-0 sm:ml-10">
|
|
{hasSkatteverketConnected ? (
|
|
<div className="block p-4 sm:p-5 rounded-xl border border-emerald-500/30 bg-emerald-500/[0.04]">
|
|
<div className="flex items-start gap-3 sm:gap-4">
|
|
<div className="p-2 sm:p-2.5 rounded-lg bg-emerald-500/[0.10] flex-shrink-0">
|
|
<FileCheck className="h-4 w-4 sm:h-5 sm:w-5 text-emerald-700 dark:text-emerald-400" />
|
|
</div>
|
|
<div className="flex-1 min-w-0">
|
|
<p className="font-medium text-sm sm:text-base text-emerald-900 dark:text-emerald-200">
|
|
{t('skatteverket_connected_title')}
|
|
</p>
|
|
<p className="text-xs sm:text-sm text-muted-foreground mt-1 sm:mt-1.5 leading-relaxed">
|
|
{t('skatteverket_connected_description')}
|
|
</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
) : (
|
|
// eslint-disable-next-line @next/next/no-html-link-for-pages -- /api route, not a Next page
|
|
<a
|
|
// Plain anchor — the authorize endpoint 302-redirects to
|
|
// skatteverket.se; <Link> would route via Next's client
|
|
// router which doesn't follow cross-origin redirects.
|
|
href="/api/extensions/ext/skatteverket/authorize?return_to=/"
|
|
className="group block p-4 sm:p-5 rounded-xl border border-border/60 hover:border-primary/40 hover:bg-primary/[0.02] transition-all duration-150 active:scale-[0.99]"
|
|
>
|
|
<div className="flex items-start gap-3 sm:gap-4">
|
|
<div className="p-2 sm:p-2.5 rounded-lg bg-muted/60 group-hover:bg-primary/[0.08] transition-colors flex-shrink-0">
|
|
<FileCheck className="h-4 w-4 sm:h-5 sm:w-5 text-muted-foreground group-hover:text-primary transition-colors" />
|
|
</div>
|
|
<div className="flex-1 min-w-0">
|
|
<p className="font-medium group-hover:text-primary transition-colors text-sm sm:text-base">
|
|
{t('skatteverket_connect_title')}
|
|
</p>
|
|
<p className="text-xs sm:text-sm text-muted-foreground mt-1 sm:mt-1.5 leading-relaxed">
|
|
{t('skatteverket_connect_description', { appName: branding.appName.toLowerCase() })}
|
|
</p>
|
|
</div>
|
|
<ArrowRight className="h-4 w-4 text-muted-foreground/40 group-hover:text-primary/60 mt-1 flex-shrink-0 transition-colors" />
|
|
</div>
|
|
</a>
|
|
)}
|
|
</div>
|
|
</div>
|
|
)}
|
|
|
|
{/* Escape hatch */}
|
|
<div className="space-y-5">
|
|
<div className="flex items-center gap-4">
|
|
<div className="flex-1 h-px bg-border/60" />
|
|
<span className="text-xs text-muted-foreground">{t('or_separator')}</span>
|
|
<div className="flex-1 h-px bg-border/60" />
|
|
</div>
|
|
|
|
<div className="text-center">
|
|
<button
|
|
onClick={onFreshStart}
|
|
className="text-sm text-muted-foreground hover:text-foreground transition-colors inline-flex items-center gap-1.5 group"
|
|
>
|
|
{t('fresh_start')}
|
|
<ArrowRight className="h-3.5 w-3.5 group-hover:translate-x-0.5 transition-transform" />
|
|
</button>
|
|
</div>
|
|
|
|
<div className="flex items-center justify-center gap-2 pt-2">
|
|
<ShieldCheck className="h-3.5 w-3.5 text-muted-foreground/40" />
|
|
<p className="text-xs text-muted-foreground/50">
|
|
{t('security_note')}
|
|
</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|