Link planned days to their wish, fix the age-4 cap, drop the planning goal
Three changes that together unblock treating a calendar period as one editable object. Migration 008 adds `planned_leave_day.wish_id` (nullable, ON DELETE SET NULL) so a persisted day knows which `leave_wish` produced it, `is_pinned` to mark a day the user hand-edited, and `leave_wish.target_days` so a period drawn on a calendar need not be a whole number of weeks. Apply-time identity still keys on day_type/is_dubbeldag only, so a wish_id-only difference is a metadata update rather than a collision. The age-4 savable ceiling was applying the per-child figure of 96 to each parent's pool, modelling a two-parent family as able to save 192 days past the child's fourth birthday. `resolve_age4_savable_cap` is now the single place that decides 48 (couple with two parents) versus 96 (everyone else), and both AnalyticsService and the allocator read it. Migration 009 drops `workspace.planning_goal` and `leave_wish.goal_override`. The allocator's tier-3 policy collapses to one rule; `salary_type` still branches, since that reflects what a vacation day actually costs a parent rather than a user preference.
This commit is contained in:
@@ -36,7 +36,7 @@ describe('Dashboard', () => {
|
||||
vi.mocked(useAuth).mockReturnValue(makeAuthContextValue())
|
||||
vi.mocked(useWorkspace).mockReturnValue(
|
||||
makeWorkspaceContextValue({
|
||||
workspace: { id: 'ws-1', name: 'Test Workspace', planningGoal: 'balanced', planningMode: 'solo', createdAt: '2026-01-01' },
|
||||
workspace: { id: 'ws-1', name: 'Test Workspace', planningMode: 'solo', createdAt: '2026-01-01' },
|
||||
workspaceId: 'ws-1',
|
||||
children: [{ id: 'c-1', name: 'Child 1', birth_date: '2022-01-01' }],
|
||||
selectedChildId: 'c-1',
|
||||
@@ -107,7 +107,7 @@ describe('Dashboard', () => {
|
||||
it('renders loading spinner initially', () => {
|
||||
vi.mocked(useWorkspace).mockReturnValue(
|
||||
makeWorkspaceContextValue({
|
||||
workspace: { id: 'ws-1', name: 'Test Workspace', planningGoal: 'balanced', planningMode: 'solo', createdAt: '2026-01-01' },
|
||||
workspace: { id: 'ws-1', name: 'Test Workspace', planningMode: 'solo', createdAt: '2026-01-01' },
|
||||
workspaceId: 'ws-1',
|
||||
children: [{ id: 'c-1', name: 'Child 1', birth_date: '2022-01-01' }],
|
||||
selectedChildId: 'c-1',
|
||||
@@ -123,7 +123,7 @@ describe('Dashboard', () => {
|
||||
it('shows add child form when no children', () => {
|
||||
vi.mocked(useWorkspace).mockReturnValue(
|
||||
makeWorkspaceContextValue({
|
||||
workspace: { id: 'ws-1', name: 'Test Workspace', planningGoal: 'balanced', planningMode: 'solo', createdAt: '2026-01-01' },
|
||||
workspace: { id: 'ws-1', name: 'Test Workspace', planningMode: 'solo', createdAt: '2026-01-01' },
|
||||
workspaceId: 'ws-1',
|
||||
children: [],
|
||||
selectedChildId: null,
|
||||
@@ -160,7 +160,7 @@ describe('Dashboard', () => {
|
||||
it('disables FK fetch button when no child selected', () => {
|
||||
vi.mocked(useWorkspace).mockReturnValue(
|
||||
makeWorkspaceContextValue({
|
||||
workspace: { id: 'ws-1', name: 'Test Workspace', planningGoal: 'balanced', planningMode: 'solo', createdAt: '2026-01-01' },
|
||||
workspace: { id: 'ws-1', name: 'Test Workspace', planningMode: 'solo', createdAt: '2026-01-01' },
|
||||
workspaceId: 'ws-1',
|
||||
children: [{ id: 'c-1', name: 'Child 1', birth_date: '2022-01-01' }],
|
||||
selectedChildId: null,
|
||||
@@ -281,7 +281,7 @@ describe('Dashboard', () => {
|
||||
|
||||
vi.mocked(useWorkspace).mockReturnValue(
|
||||
makeWorkspaceContextValue({
|
||||
workspace: { id: 'ws-1', name: 'Test Workspace', planningGoal: 'balanced', planningMode: 'solo', createdAt: '2026-01-01' },
|
||||
workspace: { id: 'ws-1', name: 'Test Workspace', planningMode: 'solo', createdAt: '2026-01-01' },
|
||||
workspaceId: 'ws-1',
|
||||
children: [],
|
||||
selectedChildId: null,
|
||||
@@ -318,7 +318,7 @@ describe('Dashboard', () => {
|
||||
|
||||
vi.mocked(useWorkspace).mockReturnValue(
|
||||
makeWorkspaceContextValue({
|
||||
workspace: { id: 'ws-1', name: 'Test Workspace', planningGoal: 'balanced', planningMode: 'solo', createdAt: '2026-01-01' },
|
||||
workspace: { id: 'ws-1', name: 'Test Workspace', planningMode: 'solo', createdAt: '2026-01-01' },
|
||||
workspaceId: 'ws-1',
|
||||
children: [],
|
||||
selectedChildId: null,
|
||||
@@ -351,7 +351,7 @@ describe('Dashboard', () => {
|
||||
|
||||
vi.mocked(useWorkspace).mockReturnValue(
|
||||
makeWorkspaceContextValue({
|
||||
workspace: { id: 'ws-1', name: 'Test Workspace', planningGoal: 'balanced', planningMode: 'solo', createdAt: '2026-01-01' },
|
||||
workspace: { id: 'ws-1', name: 'Test Workspace', planningMode: 'solo', createdAt: '2026-01-01' },
|
||||
workspaceId: 'ws-1',
|
||||
children: [],
|
||||
selectedChildId: null,
|
||||
@@ -412,7 +412,7 @@ describe('Dashboard', () => {
|
||||
it('disables manual fetch button when no child selected', () => {
|
||||
vi.mocked(useWorkspace).mockReturnValue(
|
||||
makeWorkspaceContextValue({
|
||||
workspace: { id: 'ws-1', name: 'Test Workspace', planningGoal: 'balanced', planningMode: 'solo', createdAt: '2026-01-01' },
|
||||
workspace: { id: 'ws-1', name: 'Test Workspace', planningMode: 'solo', createdAt: '2026-01-01' },
|
||||
workspaceId: 'ws-1',
|
||||
children: [{ id: 'c-1', name: 'Child 1', birth_date: '2022-01-01' }],
|
||||
selectedChildId: null,
|
||||
|
||||
@@ -125,7 +125,6 @@ describe('Plan', () => {
|
||||
workspace: {
|
||||
id: 'ws-1',
|
||||
name: 'Test Workspace',
|
||||
planningGoal: 'balanced',
|
||||
planningMode: 'couple',
|
||||
createdAt: '2026-01-01',
|
||||
},
|
||||
@@ -167,7 +166,6 @@ describe('Plan', () => {
|
||||
workspace: {
|
||||
id: 'ws-1',
|
||||
name: 'Test Workspace',
|
||||
planningGoal: 'balanced',
|
||||
planningMode: 'couple',
|
||||
createdAt: '2026-01-01',
|
||||
},
|
||||
|
||||
@@ -117,7 +117,6 @@ describe('Settings', () => {
|
||||
workspace: {
|
||||
id: 'ws-1',
|
||||
name: 'Test Workspace',
|
||||
planningGoal: 'balanced',
|
||||
planningMode: 'solo',
|
||||
createdAt: '2026-01-01',
|
||||
},
|
||||
@@ -164,7 +163,6 @@ describe('Settings', () => {
|
||||
vi.mocked(api.updateWorkspace).mockResolvedValue({
|
||||
id: 'ws-1',
|
||||
name: 'Test Workspace',
|
||||
planningGoal: 'balanced',
|
||||
planningMode: 'solo',
|
||||
createdAt: '2026-01-01',
|
||||
})
|
||||
@@ -190,7 +188,6 @@ describe('Settings', () => {
|
||||
workspace: {
|
||||
id: 'ws-1',
|
||||
name: 'Test Workspace',
|
||||
planningGoal: 'balanced',
|
||||
planningMode: 'solo',
|
||||
createdAt: '2026-01-01',
|
||||
},
|
||||
@@ -283,14 +280,13 @@ describe('Settings', () => {
|
||||
expect(screen.getByTestId('planning-mode-solo')).toBeChecked()
|
||||
})
|
||||
|
||||
it('saves the selected planning mode together with the planning goal', async () => {
|
||||
it('saves the selected planning mode', async () => {
|
||||
renderSettings()
|
||||
fireEvent.click(screen.getByTestId('planning-mode-couple'))
|
||||
fireEvent.click(screen.getByTestId('save-planning-goal-button'))
|
||||
|
||||
await waitFor(() =>
|
||||
expect(api.updateWorkspace).toHaveBeenCalledWith('ws-1', {
|
||||
planningGoal: 'balanced',
|
||||
planningMode: 'couple',
|
||||
}),
|
||||
)
|
||||
|
||||
@@ -15,7 +15,6 @@ import { Layout } from '@/components/layout/Layout'
|
||||
import { LoadingSpinner } from '@/components/common/LoadingSpinner'
|
||||
import { ChildBirthdayInput } from '@/components/inputs/ChildBirthdayInput'
|
||||
import { ParentProfileInput, type SalaryType, type EmploymentStatus } from '@/components/inputs/ParentProfileInput'
|
||||
import { PlanningGoalSelector, type PlanningGoal } from '@/components/inputs/PlanningGoalSelector'
|
||||
import { PlanningModeSelector, type PlanningMode } from '@/components/inputs/PlanningModeSelector'
|
||||
import { VacationDaysInput } from '@/components/inputs/VacationDaysInput'
|
||||
import { VacationDaysTable, type VacationDaysTableRow } from '@/components/vacation-days/VacationDaysTable'
|
||||
@@ -132,7 +131,6 @@ export function Settings(): ReactNode {
|
||||
const [childBirthDate, setChildBirthDate] = useState('')
|
||||
const [preschoolPlanningDays, setPreschoolPlanningDays] = useState(6)
|
||||
const [parentData, setParentData] = useState<{ salaryType?: SalaryType; employmentStatus?: EmploymentStatus }>({})
|
||||
const [planningGoal, setPlanningGoal] = useState<PlanningGoal>(workspace?.planningGoal ?? 'balanced')
|
||||
const [planningMode, setPlanningMode] = useState<PlanningMode>(workspace?.planningMode ?? 'solo')
|
||||
const [saveMessage, setSaveMessage] = useState<{ type: 'success' | 'error'; text: string } | null>(null)
|
||||
const [isSaving, setIsSaving] = useState(false)
|
||||
@@ -152,13 +150,10 @@ export function Settings(): ReactNode {
|
||||
}, [childDetails])
|
||||
|
||||
useEffect(() => {
|
||||
if (workspace?.planningGoal) {
|
||||
setPlanningGoal(workspace.planningGoal)
|
||||
}
|
||||
if (workspace?.planningMode) {
|
||||
setPlanningMode(workspace.planningMode)
|
||||
}
|
||||
}, [workspace?.planningGoal, workspace?.planningMode])
|
||||
}, [workspace?.planningMode])
|
||||
|
||||
const selectedChild = children.find((c) => c.id === selectedChildId)
|
||||
const hasPartner = members.some((m) => m.uuid !== personalDataUuid)
|
||||
@@ -256,7 +251,7 @@ export function Settings(): ReactNode {
|
||||
try {
|
||||
if (workspace?.id) {
|
||||
setIsSaving(true)
|
||||
await api.updateWorkspace(workspace.id, { planningGoal, planningMode })
|
||||
await api.updateWorkspace(workspace.id, { planningMode })
|
||||
await refreshContext()
|
||||
showMessage('success', t('settings.savePlanningSuccess'))
|
||||
}
|
||||
@@ -442,7 +437,6 @@ export function Settings(): ReactNode {
|
||||
<section className="settings-page__section">
|
||||
<h2>{t('settings.planningSectionTitle')}</h2>
|
||||
<p className="settings-page__help">{t('settings.planningHelp')}</p>
|
||||
<PlanningGoalSelector value={planningGoal} onChange={setPlanningGoal} />
|
||||
<PlanningModeSelector value={planningMode} onChange={setPlanningMode} />
|
||||
<button
|
||||
onClick={handleSavePlanning}
|
||||
|
||||
@@ -24,7 +24,7 @@ describe('Tips', () => {
|
||||
vi.clearAllMocks()
|
||||
vi.mocked(useWorkspace).mockReturnValue(
|
||||
makeWorkspaceContextValue({
|
||||
workspace: { id: 'ws-1', name: 'Test Workspace', planningGoal: 'balanced', planningMode: 'solo', createdAt: '2026-01-01' },
|
||||
workspace: { id: 'ws-1', name: 'Test Workspace', planningMode: 'solo', createdAt: '2026-01-01' },
|
||||
})
|
||||
)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user