Files
accounted/components/onboarding/Step1EntityType.tsx
T
Jakob Wennberg b800dcd403 style(ui): system-wide UX/UI polish pass — design-system conformance + copy cleanup (#835)
* style(ui): system-wide UX/UI polish pass — design-system conformance + copy cleanup

Multi-agent scan of all 404 UI files against the locked design system, then
141 verified surgical fixes across 109 files (net -32 lines):

- Remove forbidden elevation/motion: shadow-* and rounded-xl on cards, active:scale
  bounce, hover:shadow on list items, transition-all -> transition-colors.
- Drop font-medium from single-weight Hedvig display headings/numerals.
- Replace raw rainbow Tailwind status colors with Badge variants / brand tokens /
  neutral surfaces (achromatic chrome, semantic colors stay data-only).
- Route raw dates through formatDate(), hand-rolled currency through formatCurrency(),
  add tabular-nums to financial figures; text-gray-* -> text-foreground tokens.
- Swap hand-rolled skeletons for the Skeleton primitive; off-scale spacing -> token scale.
- Fix copy: mislabeled "Leverantörsfakturor" -> "Utgifter" on bank-import outflow total,
  collapse no-op identical-branch ternaries, broken Swedish diacritics (mojibake),
  correct mismatch-password toast, correct supplier currency-field label.
- Remove PII-leaking debug console.log on register, stray console.logs.

Verified: tsc clean on all changed files, eslint clean, production build passes.

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

* fix(auth): sanitize residual error logs in register flow

Follow-up to PR review (compliance swarm V16 / GDPR Art.5(1)(f)): the
remaining console.error calls in the register flow passed raw error
objects, which Supabase may populate with PII (email) in nested fields.
Log only sanitized message strings instead.

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

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-30 13:14:13 +02:00

134 lines
4.3 KiB
TypeScript

'use client'
import { useState } from 'react'
import { useTranslations } from 'next-intl'
import { Button } from '@/components/ui/button'
import { Card } from '@/components/ui/card'
import { Badge } from '@/components/ui/badge'
import { Loader2, ArrowRight, Building2, User, Check } from 'lucide-react'
import { cn } from '@/lib/utils'
import type { EntityType } from '@/types'
interface Step1Props {
initialData: { entity_type?: EntityType }
onNext: (data: { entity_type: EntityType }) => void
isSaving: boolean
}
export default function Step1EntityType({ initialData, onNext, isSaving }: Step1Props) {
const t = useTranslations('onboarding')
const [selected, setSelected] = useState<EntityType | undefined>(initialData.entity_type)
// "Enskild firma" and "Aktiebolag" are statutory legal entity types — kept
// in Swedish in both locales.
const entityOptions: {
value: EntityType | string
label: string
description: string
icon: typeof Building2
disabled?: boolean
}[] = [
{
value: 'enskild_firma',
label: 'Enskild firma',
description: t('step1_ef_description'),
icon: User,
},
{
value: 'aktiebolag',
label: 'Aktiebolag',
description: t('step1_ab_description'),
icon: Building2,
},
]
const handleNext = () => {
if (!selected) {
const msg = 'step 1: fortsätt clicked without entity type selected'
console.error('[onboarding]', msg)
fetch('/api/log', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ message: msg }) }).catch(() => {})
return
}
onNext({ entity_type: selected })
}
return (
<div className="space-y-8">
<div className="grid gap-3">
{entityOptions.map((option) => {
const Icon = option.icon
const isSelected = selected === option.value
return (
<button
key={option.value}
type="button"
disabled={option.disabled}
onClick={() => !option.disabled && setSelected(option.value as EntityType)}
className="text-left w-full"
>
<Card
className={cn(
'relative p-4 transition-colors',
option.disabled
? 'opacity-50 cursor-not-allowed'
: 'cursor-pointer hover:border-primary/50',
isSelected && 'border-primary ring-2 ring-primary/20'
)}
>
<div className="flex items-start gap-4">
<div className={cn(
'p-2 rounded-lg',
isSelected ? 'bg-primary/10' : 'bg-muted/50'
)}>
<Icon className={cn(
'h-5 w-5',
isSelected ? 'text-primary' : 'text-muted-foreground'
)} />
</div>
<div className="flex-1">
<div className="flex items-center gap-2">
<span className="font-medium">{option.label}</span>
{option.disabled && (
<Badge variant="secondary" className="text-xs">{t('coming_soon')}</Badge>
)}
</div>
<p className="text-sm text-muted-foreground mt-0.5">
{option.description}
</p>
</div>
{isSelected && (
<div className="flex-shrink-0 p-1 rounded-full bg-primary text-primary-foreground">
<Check className="h-3.5 w-3.5" />
</div>
)}
</div>
</Card>
</button>
)
})}
</div>
<div className="flex flex-col-reverse sm:flex-row sm:justify-end gap-3">
<Button
onClick={handleNext}
disabled={!selected || isSaving}
size="lg"
className="w-full sm:w-auto"
>
{isSaving ? (
<>
<Loader2 className="mr-2 h-4 w-4 animate-spin" />
{t('saving')}
</>
) : (
<>
{t('continue')}
<ArrowRight className="ml-2 h-4 w-4" />
</>
)}
</Button>
</div>
</div>
)
}