'use client' import { useState } from 'react' import { useTranslations } from 'next-intl' import { Input } from '@/components/ui/input' import { Label } from '@/components/ui/label' import { roundOre } from '@/lib/money' import { formatCurrency } from '@/lib/utils' // Deliberately narrow (data minimisation): the form only ever needs the two // share-capital fields, not the whole CompanySettings object. interface ShareCapitalFormProps { settings: { aktiekapital?: number | null antal_aktier?: number | null } } /** * Registered share capital per Bolagsverket, feeding the statutory * aktiekapital note in the annual report. Kvotvärde (ABL 1 kap 6 §: * aktiekapital / antal aktier) is derived, never entered. */ export function ShareCapitalForm({ settings }: ShareCapitalFormProps) { const t = useTranslations('settings_company') const [aktiekapital, setAktiekapital] = useState( settings.aktiekapital != null ? String(settings.aktiekapital) : '', ) const [antalAktier, setAntalAktier] = useState( settings.antal_aktier != null ? String(settings.antal_aktier) : '', ) const capital = Number(aktiekapital) const shares = Number(antalAktier) // Mirror UpdateSettingsSchema: whole-krona capital > 0, positive integer // share count. No preview for values the server would reject. const kvotvarde = Number.isSafeInteger(capital) && capital > 0 && Number.isSafeInteger(shares) && shares > 0 ? roundOre(capital / shares) : null return (

{t('share_capital_heading')}

setAktiekapital(e.target.value)} />

{t('aktiekapital_help')}

setAntalAktier(e.target.value)} />

{t('antal_aktier_help')}

{kvotvarde !== null && (

{t('kvotvarde_display', { value: formatCurrency(kvotvarde) })}

)}
) }