d54b43f80f
* fix(invoices): anchor the PDF logo to the top-left of its header cell The logo box is always the full 240x80pt reserved area (any larger logo is clamped to exactly that), so objectFit: 'contain' placed the image inside it with the default 50% 50% centering. A wide banner logo fills the width and lands on the left margin, but a near-square logo scaled down to the 80pt height cap is only ~117pt wide and got pushed ~60pt in from the margin, which reads as a misaligned logo and forced companies to reshape their artwork. Anchor the image top-left so every aspect ratio starts at the margin. Covered by a test that renders the real PDF and reads the image placement matrix out of the content stream, for both a wide and a near-square logo. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * feat(invoices): show the real delivery outcome in the send history "Skickad" only meant the email provider accepted the message, so a bounced invoice looked identical to one that arrived. Resend reports the outcome asynchronously; that report now lands on the delivery row and drives the history: green is reserved for a confirmed delivery, bounce/blocked reads red, delayed and spam-marked read amber, and an accepted-but-unconfirmed send is neutral instead of falsely green. The report arrives on a signed webhook and may only touch the three new provider status columns of an already sent, unredacted row: the WORM trigger proves nothing else changed, and a lower ranked or older report can never downgrade an observed failure. The provider reason text can quote the failing address, so it is masked on read and cleared by the daily PII redaction job. Timestamps also formatted in Europe/Stockholm instead of falling back to the runtime zone, which rendered a 14:05 send as 12:05 on Vercel. Delivery reports are per message, never per recipient: Resend sends one event for the whole message, so splitting a send per recipient would be the only way to get finer granularity, at the cost of CC. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * feat(stripe): make the integration feed-only Stripe sync now only imports balance transactions into the transactions inbox, like any bank feed; nothing auto-books. The event/settlement sync (lib/sync.ts, lib/payouts.ts) stays in the repo but is no longer wired to any route or cron: the 15-min sync cron is removed from vercel.json. Payment links on invoice send are unchanged; their payments arrive as feed rows and are matched manually. - /sync runs only syncStripeBalanceTransactions; response is { success, transactions } - connecting via OAuth enables the nightly feed by default (toggle stays as opt-out) - panel: needs-review section and plumbing removed, copy rewritten to transactions-first (sv + en), toast reports fetched/imported/linked and calls out an empty result instead of silent all-zeros Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * fix(api): return the article currency from the v1 article list The dashboard, importer, export and MCP article surfaces all learned to carry a non-SEK article price (#1166, #1183, #1184), but the v1 projection still omitted currency. An API or agent caller therefore read price_excl_vat with nothing marking it as EUR and would copy the number straight onto a SEK invoice line, at a nine-to-one error. Adds currency to the projection, the response shape and the example, plus a pitfall stating the price is not always SEK and that this endpoint does no FX conversion. Additive field only; no migration (articles.currency already exists). Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * feat(settings): replace the settings modal with a routed panel sheet Settings now renders as a sheet that fills the main panel, sliding up over the page the user came from and back down on close, with the sidebar and frame left visible and usable. Behind it sits one shared master-detail surface: underline search across every section and subsection, the grouped section rail, and the active section as a direct-editing accordion. All 11 sections are decomposed into subsections, and the legacy *SettingsContent components compose the same pieces so the stacked and accordion layouts cannot drift. The sheet is the only presentation, on every entry path. The intercepting route handles in-app navigation and closes by popping the history entry, landing back on the page underneath. @settingsModal/default.tsx handles cold loads (refresh, deep link, new tab), where interception never fires; nothing is mounted underneath there, so it closes to the dashboard. Both branch on one shared predicate, isSheetSection, together with the settings layout, which must render nothing for those sections or the surface would stack twice behind the sheet and run every section's fetches twice. Closing is deliberate rather than incidental: the X, Esc, or navigating away. The dialog is non-modal so the sidebar's account popover and company switcher keep working with settings up, and an outside click no longer dismisses it. Sections land fully collapsed, and the scroll position of the page behind survives opening and closing the sheet. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * feat: enhance article management and settings UI - Add PATCH test for toggling article active state without other fields. - Remove unused MessageCircle icon from DashboardContent. - Refactor AccountingFrameworkForm to use SettingsFieldRow for better help text display. - Update CompanyInfoForm, DimensionsToggle, and various settings forms to replace description with help text. - Remove redundant headings and intros in several settings components to streamline UI. - Improve help text for various settings in English and Swedish translations. - Update structured error messages for better clarity on article deletion. * refactor(ArticleDetailPage): remove unused imports and duplicate state variable * fix(settings): own deep-linked settings routes by route list, not nav visibility Review fixes from the settings panel sheet work: * isSheetSection reads the full settings route list so a hidden-but-deep-linked section (assistant before BankID, banking in sandbox, api without MCP) is claimed by the sheet instead of rendering the legacy shell around an empty panel * keep 503 on the Resend delivery webhook when the signing secret is unset, with a test pinning the behaviour * stripe callback route test coverage Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * refactor: update salary, tax, and templates settings components - Refactored SalarySettingsContent to use a form wrapper and improved payment settings UI. - Enhanced TaxSettingsContent with new signals for EU sales, KU obligations, and ROT/RUT deductions. - Updated TemplatesSettingsContent to remove legacy comments and improve readability. - Simplified navigation items by removing unnecessary constants and directly using hrefs. - Cleaned up translation files by removing deprecated keys and adding new descriptions for clarity. --------- Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
259 lines
8.6 KiB
TypeScript
259 lines
8.6 KiB
TypeScript
'use client'
|
|
|
|
import { ChevronDown } from 'lucide-react'
|
|
import { cn } from '@/lib/utils'
|
|
import { HelpPopover } from '@/components/ui/help-popover'
|
|
|
|
/**
|
|
* The Fönster settings language (founder-approved concept 2026-07-25):
|
|
* flat hairline rows with an uppercase micro-label on the left and the
|
|
* control on the right, section titles in the display serif, groups under
|
|
* eyebrow labels, and every explanation collapsed behind a "?" popover
|
|
* (UI-migration convention 7 applied at row level).
|
|
*
|
|
* All settings sections compose these primitives; do not hand-roll row
|
|
* layouts or inline help paragraphs in section components.
|
|
*/
|
|
|
|
interface SettingsSectionHeaderProps {
|
|
title: string
|
|
/** One quiet line under the title. Longer guidance belongs in row help. */
|
|
intro?: React.ReactNode
|
|
/** Right-aligned header action (e.g. "Förhandsvisa faktura", "Skapa nyckel"). */
|
|
action?: React.ReactNode
|
|
}
|
|
|
|
export function SettingsSectionHeader({ title, intro, action }: SettingsSectionHeaderProps) {
|
|
return (
|
|
<header>
|
|
<div className="flex items-baseline justify-between gap-4">
|
|
<h2 className="font-display text-xl tracking-tight">{title}</h2>
|
|
{action ? <div className="flex shrink-0 items-center gap-3">{action}</div> : null}
|
|
</div>
|
|
{intro ? (
|
|
<p className="mt-1 max-w-[56ch] text-xs leading-relaxed text-muted-foreground">{intro}</p>
|
|
) : null}
|
|
</header>
|
|
)
|
|
}
|
|
|
|
interface SettingsGroupProps {
|
|
label?: string
|
|
/** Group-level help ("?" right after the eyebrow) for guidance that spans the rows. */
|
|
help?: React.ReactNode
|
|
children: React.ReactNode
|
|
className?: string
|
|
}
|
|
|
|
export function SettingsGroup({ label, help, children, className }: SettingsGroupProps) {
|
|
return (
|
|
<section className={cn('pt-8 first:pt-6', className)}>
|
|
{label ? (
|
|
<p className="flex items-center gap-2 px-1 text-[11px] font-medium uppercase tracking-wider text-muted-foreground">
|
|
<span>{label}</span>
|
|
{help ? <HelpPopover className="shrink-0">{help}</HelpPopover> : null}
|
|
</p>
|
|
) : null}
|
|
<div>{children}</div>
|
|
</section>
|
|
)
|
|
}
|
|
|
|
interface SettingsRowProps {
|
|
label: React.ReactNode
|
|
/** Ties the label to a control; renders a <label> instead of a <span>. */
|
|
htmlFor?: string
|
|
/** Row help content: goes behind a "?" next to the label, never inline. */
|
|
help?: React.ReactNode
|
|
/** 'center' for toggles/selects/chips, 'baseline' for text inputs. */
|
|
align?: 'center' | 'baseline'
|
|
/** Drop the hairline (last row before a fold/reveal). */
|
|
borderless?: boolean
|
|
children: React.ReactNode
|
|
className?: string
|
|
}
|
|
|
|
export function SettingsRow({
|
|
label,
|
|
htmlFor,
|
|
help,
|
|
align = 'center',
|
|
borderless = false,
|
|
children,
|
|
className,
|
|
}: SettingsRowProps) {
|
|
const labelClass = 'text-[11px] font-medium uppercase tracking-wider text-muted-foreground'
|
|
return (
|
|
<div
|
|
className={cn(
|
|
'flex flex-col gap-1 px-1 py-3 md:flex-row md:gap-4',
|
|
align === 'center' ? 'md:items-center' : 'md:items-baseline',
|
|
!borderless && 'border-b border-border',
|
|
className,
|
|
)}
|
|
>
|
|
<div className="flex w-full shrink-0 items-center gap-2 md:w-44">
|
|
{htmlFor ? (
|
|
<label htmlFor={htmlFor} className={labelClass}>
|
|
{label}
|
|
</label>
|
|
) : (
|
|
<span className={labelClass}>{label}</span>
|
|
)}
|
|
{help ? <HelpPopover className="shrink-0">{help}</HelpPopover> : null}
|
|
</div>
|
|
<div className="flex min-w-0 flex-1 flex-wrap items-center gap-x-3 gap-y-1 text-sm">
|
|
{children}
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
/** Right-aligned slot inside a row (quiet actions, secondary values). */
|
|
export function SettingsRowEnd({ children, className }: { children: React.ReactNode; className?: string }) {
|
|
return <div className={cn('ml-auto flex shrink-0 items-center gap-3', className)}>{children}</div>
|
|
}
|
|
|
|
/** Muted secondary text inside a row. */
|
|
export function SettingsRowNote({ children, className }: { children: React.ReactNode; className?: string }) {
|
|
return <span className={cn('text-xs text-muted-foreground', className)}>{children}</span>
|
|
}
|
|
|
|
/**
|
|
* Flat text input: borderless with a dashed underline on hover and a solid
|
|
* one on focus. Sized by the row, not by a box.
|
|
*/
|
|
export function SettingsInput({ className, ...rest }: React.InputHTMLAttributes<HTMLInputElement>) {
|
|
return (
|
|
<input
|
|
{...rest}
|
|
className={cn(
|
|
'min-w-0 flex-1 rounded-none border-0 border-b border-dashed border-transparent bg-transparent px-0 py-1 text-sm text-foreground',
|
|
'placeholder:text-muted-foreground/60 hover:border-border',
|
|
'focus:outline-none focus:border-solid focus:border-foreground/50',
|
|
'disabled:cursor-not-allowed disabled:border-transparent disabled:opacity-60',
|
|
className,
|
|
)}
|
|
/>
|
|
)
|
|
}
|
|
|
|
/** Flat textarea sibling of SettingsInput. */
|
|
export function SettingsTextarea({ className, ...rest }: React.TextareaHTMLAttributes<HTMLTextAreaElement>) {
|
|
return (
|
|
<textarea
|
|
{...rest}
|
|
className={cn(
|
|
'min-w-0 flex-1 resize-y rounded-none border-0 border-b border-dashed border-transparent bg-transparent px-0 py-1 text-sm text-foreground',
|
|
'placeholder:text-muted-foreground/60 hover:border-border',
|
|
'focus:outline-none focus:border-solid focus:border-foreground/50',
|
|
'disabled:cursor-not-allowed disabled:border-transparent disabled:opacity-60',
|
|
className,
|
|
)}
|
|
/>
|
|
)
|
|
}
|
|
|
|
/** Flat native select with a quiet chevron. */
|
|
export function SettingsSelect({
|
|
className,
|
|
wrapperClassName,
|
|
children,
|
|
...rest
|
|
}: React.SelectHTMLAttributes<HTMLSelectElement> & { wrapperClassName?: string }) {
|
|
return (
|
|
<span className={cn('relative inline-flex max-w-full items-center', wrapperClassName)}>
|
|
<select
|
|
{...rest}
|
|
className={cn(
|
|
'max-w-full cursor-pointer appearance-none truncate rounded-none border-0 border-b border-dashed border-transparent bg-transparent py-1 pl-0 pr-6 text-sm text-foreground',
|
|
'hover:border-border focus:outline-none focus-visible:border-solid focus-visible:border-foreground/50',
|
|
'disabled:cursor-not-allowed disabled:opacity-60',
|
|
className,
|
|
)}
|
|
>
|
|
{children}
|
|
</select>
|
|
<ChevronDown
|
|
aria-hidden="true"
|
|
className="pointer-events-none absolute right-1 h-3.5 w-3.5 text-muted-foreground"
|
|
/>
|
|
</span>
|
|
)
|
|
}
|
|
|
|
interface SettingsRevealProps {
|
|
open: boolean
|
|
/** Indent revealed rows behind a left hairline (gated sub-settings). */
|
|
indent?: boolean
|
|
children: React.ReactNode
|
|
}
|
|
|
|
/** Animated reveal for settings gated behind a toggle (momsreg → momsblock). */
|
|
export function SettingsReveal({ open, indent = true, children }: SettingsRevealProps) {
|
|
return (
|
|
<div
|
|
inert={!open}
|
|
className={cn(
|
|
'grid transition-[grid-template-rows] duration-300 motion-reduce:transition-none',
|
|
open ? 'grid-rows-[1fr]' : 'grid-rows-[0fr]',
|
|
)}
|
|
>
|
|
<div className="min-h-0 overflow-hidden">
|
|
<div className={cn(indent && 'ml-3 border-l border-border pl-4')}>{children}</div>
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
interface SettingsSegProps<T extends string> {
|
|
value: T
|
|
onChange: (value: T) => void
|
|
options: Array<{ value: T; label: React.ReactNode }>
|
|
'aria-label': string
|
|
disabled?: boolean
|
|
}
|
|
|
|
/** Quiet segmented control (theme, language, plan interval, sv/en texts). */
|
|
export function SettingsSeg<T extends string>({
|
|
value,
|
|
onChange,
|
|
options,
|
|
'aria-label': ariaLabel,
|
|
disabled,
|
|
}: SettingsSegProps<T>) {
|
|
return (
|
|
<div role="group" aria-label={ariaLabel} className="inline-flex items-center gap-1 rounded-lg bg-muted/70 p-1">
|
|
{options.map((o) => (
|
|
<button
|
|
key={o.value}
|
|
type="button"
|
|
disabled={disabled}
|
|
aria-pressed={o.value === value}
|
|
onClick={() => onChange(o.value)}
|
|
className={cn(
|
|
'rounded-md px-3 py-1 text-xs transition-colors duration-150 disabled:cursor-not-allowed disabled:opacity-60',
|
|
o.value === value
|
|
? 'border border-border bg-card font-medium text-foreground'
|
|
: 'text-muted-foreground hover:text-foreground',
|
|
)}
|
|
>
|
|
{o.label}
|
|
</button>
|
|
))}
|
|
</div>
|
|
)
|
|
}
|
|
|
|
/** Terracotta-tinted trailing block for destructive actions. */
|
|
export function SettingsDangerZone({ label, children }: { label: string; children: React.ReactNode }) {
|
|
return (
|
|
<section className="mt-10 border-t border-destructive/30 pt-3">
|
|
<p className="px-1 text-[11px] font-medium uppercase tracking-wider text-destructive/80">
|
|
{label}
|
|
</p>
|
|
<div>{children}</div>
|
|
</section>
|
|
)
|
|
}
|