Group settings into four panels and give balances one home

Settings becomes Barn & familj, Saldon, Kalender & språk and
Undantag & röda dagar, each saving on its own. A BalanceFlow
component owns fetching from Försäkringskassan and manual entry for
every parent, used by the Saldon panel and by the onboarding wizard,
which now runs without the app chrome. The red-days list and the
day-override form merge into one exceptions view, the vacation table
becomes wrapping rows that fit a phone, and the BankID modal speaks
translated status lines instead of emoji.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XBRLomdLK9jF7wU7a8AA6H
This commit is contained in:
2026-09-20 06:30:46 +02:00
parent 80b4f1cb52
commit b3fe2ac645
26 changed files with 2297 additions and 1142 deletions
+15 -1
View File
@@ -2,11 +2,21 @@ import { useCallback, useEffect, useState } from 'react'
import * as api from '@/services/api'
import { useLatestRequest } from './useLatestRequest'
import type { ParentBalanceInitial } from '@/components/modals/ParentBalanceForm'
import type { ParentalLeaveFetch } from '@/types'
interface UseLatestBalanceResult {
initial: ParentBalanceInitial | undefined
/** The full saved record — `source`/`fetchedAt`/`daysLeft`/`totalDays`
* that `initial` (deliberately scoped to just `ParentBalanceForm`'s
* prefill fields) doesn't carry. `null` while loading or when nothing has
* been saved yet; consumers that show a status line (`BalanceFlow`'s
* per-member row) read this instead of `initial`. */
raw: ParentalLeaveFetch | null
isLoading: boolean
error: string | null
/** Re-runs the fetch — used after an FK scrape completes so a row already
* on screen picks up the newly persisted balance without a remount. */
refresh: () => Promise<void>
}
/**
@@ -30,6 +40,7 @@ export function useLatestBalance(
childId: string | null,
): UseLatestBalanceResult {
const [initial, setInitial] = useState<ParentBalanceInitial | undefined>(undefined)
const [raw, setRaw] = useState<ParentalLeaveFetch | null>(null)
const [isLoading, setIsLoading] = useState(false)
const [error, setError] = useState<string | null>(null)
const { start, isCurrent } = useLatestRequest()
@@ -38,6 +49,7 @@ export function useLatestBalance(
const requestId = start()
if (!personalDataUuid || !childId) {
setInitial(undefined)
setRaw(null)
setError(null)
return
}
@@ -59,10 +71,12 @@ export function useLatestBalance(
}
: undefined,
)
setRaw(response)
} catch (err) {
if (!isCurrent(requestId)) return
setError(err instanceof Error ? err.message : 'Failed to load parental leave balance')
setInitial(undefined)
setRaw(null)
} finally {
if (isCurrent(requestId)) setIsLoading(false)
}
@@ -72,5 +86,5 @@ export function useLatestBalance(
void fetch()
}, [fetch])
return { initial, isLoading, error }
return { initial, raw, isLoading, error, refresh: fetch }
}