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:
@@ -1,94 +0,0 @@
|
||||
import { describe, it, expect, vi } from 'vitest'
|
||||
import { render, fireEvent } from '@testing-library/react'
|
||||
import { PlanningGoalSelector } from './PlanningGoalSelector'
|
||||
|
||||
describe('PlanningGoalSelector', () => {
|
||||
it('renders three planning goal options', () => {
|
||||
const { getByTestId } = render(
|
||||
<PlanningGoalSelector onChange={() => {}} />
|
||||
)
|
||||
expect(getByTestId('goal-max-time')).toBeInTheDocument()
|
||||
expect(getByTestId('goal-max-money')).toBeInTheDocument()
|
||||
expect(getByTestId('goal-balanced')).toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('renders as radio buttons', () => {
|
||||
const { getByTestId } = render(
|
||||
<PlanningGoalSelector onChange={() => {}} />
|
||||
)
|
||||
const radio1 = getByTestId('goal-max-time') as HTMLInputElement
|
||||
const radio2 = getByTestId('goal-max-money') as HTMLInputElement
|
||||
expect(radio1.type).toBe('radio')
|
||||
expect(radio2.type).toBe('radio')
|
||||
})
|
||||
|
||||
it('checks selected value', () => {
|
||||
const { getByTestId } = render(
|
||||
<PlanningGoalSelector value="max_money" onChange={() => {}} />
|
||||
)
|
||||
const radio = getByTestId('goal-max-money') as HTMLInputElement
|
||||
expect(radio.checked).toBe(true)
|
||||
})
|
||||
|
||||
it('calls onChange with max_time when selecting max_time option', () => {
|
||||
const onChange = vi.fn()
|
||||
const { getByTestId } = render(
|
||||
<PlanningGoalSelector onChange={onChange} />
|
||||
)
|
||||
const radio = getByTestId('goal-max-time')
|
||||
fireEvent.click(radio)
|
||||
expect(onChange).toHaveBeenCalledWith('max_time')
|
||||
})
|
||||
|
||||
it('calls onChange with max_money when selecting max_money option', () => {
|
||||
const onChange = vi.fn()
|
||||
const { getByTestId } = render(
|
||||
<PlanningGoalSelector onChange={onChange} />
|
||||
)
|
||||
const radio = getByTestId('goal-max-money')
|
||||
fireEvent.click(radio)
|
||||
expect(onChange).toHaveBeenCalledWith('max_money')
|
||||
})
|
||||
|
||||
it('calls onChange with balanced when selecting balanced option', () => {
|
||||
const onChange = vi.fn()
|
||||
const { getByTestId } = render(
|
||||
<PlanningGoalSelector onChange={onChange} />
|
||||
)
|
||||
const radio = getByTestId('goal-balanced')
|
||||
fireEvent.click(radio)
|
||||
expect(onChange).toHaveBeenCalledWith('balanced')
|
||||
})
|
||||
|
||||
it('updates selection when value changes', () => {
|
||||
const { getByTestId, rerender } = render(
|
||||
<PlanningGoalSelector value="max_time" onChange={() => {}} />
|
||||
)
|
||||
let radio = getByTestId('goal-max-time') as HTMLInputElement
|
||||
expect(radio.checked).toBe(true)
|
||||
|
||||
rerender(<PlanningGoalSelector value="balanced" onChange={() => {}} />)
|
||||
radio = getByTestId('goal-balanced') as HTMLInputElement
|
||||
expect(radio.checked).toBe(true)
|
||||
})
|
||||
|
||||
it('only one option can be selected at a time', () => {
|
||||
const { getByTestId } = render(
|
||||
<PlanningGoalSelector value="max_time" onChange={() => {}} />
|
||||
)
|
||||
const radio1 = getByTestId('goal-max-time') as HTMLInputElement
|
||||
const radio2 = getByTestId('goal-max-money') as HTMLInputElement
|
||||
expect(radio1.checked).toBe(true)
|
||||
expect(radio2.checked).toBe(false)
|
||||
})
|
||||
|
||||
it('has no selection when value is undefined', () => {
|
||||
const { getByTestId } = render(
|
||||
<PlanningGoalSelector onChange={() => {}} />
|
||||
)
|
||||
const radio1 = getByTestId('goal-max-time') as HTMLInputElement
|
||||
const radio2 = getByTestId('goal-max-money') as HTMLInputElement
|
||||
expect(radio1.checked).toBe(false)
|
||||
expect(radio2.checked).toBe(false)
|
||||
})
|
||||
})
|
||||
@@ -1,62 +0,0 @@
|
||||
import { ReactNode } from 'react'
|
||||
import { useTranslation } from '@/i18n'
|
||||
|
||||
export type PlanningGoal = 'max_time' | 'max_money' | 'balanced'
|
||||
|
||||
export interface PlanningGoalSelectorProps {
|
||||
value?: PlanningGoal
|
||||
onChange: (goal: PlanningGoal) => void
|
||||
}
|
||||
|
||||
export function PlanningGoalSelector({ value, onChange }: PlanningGoalSelectorProps): ReactNode {
|
||||
const { t } = useTranslation()
|
||||
return (
|
||||
<div data-testid="planning-goal-selector" className="planning-goal-selector">
|
||||
<fieldset className="planning-goal-selector__fieldset">
|
||||
<legend className="planning-goal-selector__legend">{t('planningGoalSelector.legend')}</legend>
|
||||
|
||||
<div className="planning-goal-selector__option">
|
||||
<input
|
||||
type="radio"
|
||||
id="goal-max-time"
|
||||
name="planning-goal"
|
||||
value="max_time"
|
||||
checked={value === 'max_time'}
|
||||
onChange={(e) => onChange(e.target.value as PlanningGoal)}
|
||||
data-testid="goal-max-time"
|
||||
/>
|
||||
<label htmlFor="goal-max-time">{t('planningGoalSelector.maxTime')}</label>
|
||||
<small>{t('planningGoalSelector.maxTimeHelp')}</small>
|
||||
</div>
|
||||
|
||||
<div className="planning-goal-selector__option">
|
||||
<input
|
||||
type="radio"
|
||||
id="goal-max-money"
|
||||
name="planning-goal"
|
||||
value="max_money"
|
||||
checked={value === 'max_money'}
|
||||
onChange={(e) => onChange(e.target.value as PlanningGoal)}
|
||||
data-testid="goal-max-money"
|
||||
/>
|
||||
<label htmlFor="goal-max-money">{t('planningGoalSelector.maxMoney')}</label>
|
||||
<small>{t('planningGoalSelector.maxMoneyHelp')}</small>
|
||||
</div>
|
||||
|
||||
<div className="planning-goal-selector__option">
|
||||
<input
|
||||
type="radio"
|
||||
id="goal-balanced"
|
||||
name="planning-goal"
|
||||
value="balanced"
|
||||
checked={value === 'balanced'}
|
||||
onChange={(e) => onChange(e.target.value as PlanningGoal)}
|
||||
data-testid="goal-balanced"
|
||||
/>
|
||||
<label htmlFor="goal-balanced">{t('planningGoalSelector.balanced')}</label>
|
||||
<small>{t('planningGoalSelector.balancedHelp')}</small>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -42,10 +42,6 @@ const TIP_TRANSLATION_KEYS: Record<string, { title: TranslationKey; body: Transl
|
||||
title: 'tip.stretchTimeAtHome.title',
|
||||
body: 'tip.stretchTimeAtHome.body',
|
||||
},
|
||||
'tips.skip_fp_first_12_months': {
|
||||
title: 'tip.skipFpFirst12Months.title',
|
||||
body: 'tip.skipFpFirst12Months.body',
|
||||
},
|
||||
'tips.sgi_minimum_after_age_1': {
|
||||
title: 'tip.sgiMinimumAfterAge1.title',
|
||||
body: 'tip.sgiMinimumAfterAge1.body',
|
||||
|
||||
@@ -20,7 +20,6 @@ const mockWish: LeaveWish = {
|
||||
priority: 1,
|
||||
parentMode: 'either',
|
||||
parentPersonalDataUuid: null,
|
||||
goalOverride: null,
|
||||
windowMode: 'fixed',
|
||||
createdAt: '2026-01-01',
|
||||
updatedAt: '2026-01-01',
|
||||
|
||||
@@ -59,7 +59,6 @@ const unauthenticated = {
|
||||
const workspace: Workspace = {
|
||||
id: 'ws1',
|
||||
name: 'Our workspace',
|
||||
planningGoal: 'balanced',
|
||||
planningMode: 'couple',
|
||||
createdAt: '2026-01-01T00:00:00Z',
|
||||
}
|
||||
|
||||
@@ -23,7 +23,6 @@ const mockWish = {
|
||||
priority: 1,
|
||||
parentMode: 'either' as const,
|
||||
parentPersonalDataUuid: null,
|
||||
goalOverride: null,
|
||||
windowMode: 'fixed' as const,
|
||||
createdAt: '2026-01-01',
|
||||
updatedAt: '2026-01-01',
|
||||
|
||||
@@ -104,13 +104,6 @@ export const plan = {
|
||||
'planResults.wished': 'wished',
|
||||
'planResults.yearHeader': 'Year',
|
||||
'planResults.yearOverviewTitle': 'Overview by year',
|
||||
'planningGoalSelector.balanced': 'Balanced',
|
||||
'planningGoalSelector.balancedHelp': 'A trade-off between time at home and income.',
|
||||
'planningGoalSelector.legend': 'Planning goal',
|
||||
'planningGoalSelector.maxMoney': 'Most money',
|
||||
'planningGoalSelector.maxMoneyHelp': 'Protect your income, e.g. by placing vacation around weekends and public holidays.',
|
||||
'planningGoalSelector.maxTime': 'Most time at home',
|
||||
'planningGoalSelector.maxTimeHelp': 'Save days and extend your total leave time, with lower income now.',
|
||||
'planningModeSelector.couple': 'Me and my partner',
|
||||
'planningModeSelector.legend': 'Are you planning alone or together with a partner?',
|
||||
'planningModeSelector.solo': 'Just me',
|
||||
|
||||
@@ -13,8 +13,6 @@ export const tips = {
|
||||
'tip.reserveForPreschoolPlanningDays.title': 'Reserve days for preschool planning days',
|
||||
'tip.sgiMinimumAfterAge1.body': '{parent_name} is planning fewer than {min_days_per_week} parental-benefit days a week over the coming month, which can affect SGI protection.',
|
||||
'tip.sgiMinimumAfterAge1.title': 'Risk to SGI protection',
|
||||
'tip.skipFpFirst12Months.body': '{parent_name} has parental-benefit leave planned before the child turns 1. With the "most time at home" goal it can pay off to save those days for later.',
|
||||
'tip.skipFpFirst12Months.title': 'Save parental benefit for later',
|
||||
'tip.stretchTimeAtHome.body': '{parent_name} is planning {weekly_intensity} days a week over the coming month, leaving {projected_left} days at age 4.',
|
||||
'tip.stretchTimeAtHome.title': 'Stretch out your time at home',
|
||||
'tip.useDubbeldagarStrategically.body': 'You both have parental-benefit leave planned on {date} but it isn\'t marked as a double day (dubbeldag).',
|
||||
|
||||
@@ -104,13 +104,6 @@ export const plan = {
|
||||
'planResults.wished': 'önskade',
|
||||
'planResults.yearHeader': 'År',
|
||||
'planResults.yearOverviewTitle': 'Översikt över åren',
|
||||
'planningGoalSelector.balanced': 'Balanserad',
|
||||
'planningGoalSelector.balancedHelp': 'En avvägning mellan tid hemma och inkomst.',
|
||||
'planningGoalSelector.legend': 'Planeringsmål',
|
||||
'planningGoalSelector.maxMoney': 'Mest pengar',
|
||||
'planningGoalSelector.maxMoneyHelp': 'Skydda din inkomst, t.ex. genom att lägga semester runt helger och röda dagar.',
|
||||
'planningGoalSelector.maxTime': 'Mest tid hemma',
|
||||
'planningGoalSelector.maxTimeHelp': 'Spara dagar och förläng din totala lediga tid, med lägre inkomst nu.',
|
||||
'planningModeSelector.couple': 'Jag och min partner',
|
||||
'planningModeSelector.legend': 'Planerar du själv eller tillsammans med en partner?',
|
||||
'planningModeSelector.solo': 'Bara jag',
|
||||
|
||||
@@ -13,8 +13,6 @@ export const tips = {
|
||||
'tip.reserveForPreschoolPlanningDays.title': 'Reservera dagar för förskolans planeringsdagar',
|
||||
'tip.sgiMinimumAfterAge1.body': '{parent_name} planerar färre än {min_days_per_week} föräldrapenningdagar per vecka den kommande månaden, vilket kan påverka SGI-skyddet.',
|
||||
'tip.sgiMinimumAfterAge1.title': 'Risk för SGI-skydd',
|
||||
'tip.skipFpFirst12Months.body': '{parent_name} har föräldrapenning planerad innan barnet fyller 1 år. Med målet "mest tid hemma" kan det löna sig att spara dagarna till senare.',
|
||||
'tip.skipFpFirst12Months.title': 'Spara föräldrapenning första året',
|
||||
'tip.stretchTimeAtHome.body': '{parent_name} planerar {weekly_intensity} dagar per vecka den kommande månaden, vilket lämnar {projected_left} dagar kvar vid 4 års ålder.',
|
||||
'tip.stretchTimeAtHome.title': 'Sträck ut tiden hemma',
|
||||
'tip.useDubbeldagarStrategically.body': 'Ni har båda föräldrapenning planerad {date} men den är inte markerad som dubbeldag.',
|
||||
|
||||
@@ -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' },
|
||||
})
|
||||
)
|
||||
})
|
||||
|
||||
@@ -188,7 +188,6 @@ describe('API response mappers (snake_case → camelCase)', () => {
|
||||
priority: 1,
|
||||
parent_mode: 'either',
|
||||
parent_personal_data_uuid: null,
|
||||
goal_override: null,
|
||||
created_at: '2026-06-14T17:09:47',
|
||||
updated_at: '2026-06-14T17:09:47',
|
||||
},
|
||||
@@ -265,7 +264,6 @@ describe('API response mappers (snake_case → camelCase)', () => {
|
||||
priority: 1,
|
||||
parent_mode: 'either',
|
||||
parent_personal_data_uuid: null,
|
||||
goal_override: null,
|
||||
created_at: '2026-06-14T17:09:47',
|
||||
updated_at: '2026-06-14T17:09:47',
|
||||
}
|
||||
@@ -322,7 +320,6 @@ describe('API response mappers (snake_case → camelCase)', () => {
|
||||
priority: 1,
|
||||
parent_mode: 'either',
|
||||
parent_personal_data_uuid: null,
|
||||
goal_override: null,
|
||||
created_at: '2026-06-14T17:09:47',
|
||||
updated_at: '2026-06-14T17:09:47',
|
||||
}
|
||||
@@ -361,7 +358,7 @@ describe('API response mappers (snake_case → camelCase)', () => {
|
||||
const rawResponse = {
|
||||
id: 'ws1',
|
||||
name: 'My Workspace',
|
||||
planning_goal: 'max_time' as const,
|
||||
planning_mode: 'couple' as const,
|
||||
created_at: '2026-06-14T17:09:47',
|
||||
}
|
||||
|
||||
@@ -375,7 +372,7 @@ describe('API response mappers (snake_case → camelCase)', () => {
|
||||
|
||||
expect(result.id).toBe('ws1')
|
||||
expect(result.name).toBe('My Workspace')
|
||||
expect(result.planningGoal).toBe('max_time')
|
||||
expect(result.planningMode).toBe('couple')
|
||||
expect(result.createdAt).toBe('2026-06-14T17:09:47')
|
||||
})
|
||||
})
|
||||
@@ -666,7 +663,6 @@ describe('endpoint functions (representative coverage)', () => {
|
||||
json: async () => ({
|
||||
id: 'ws1',
|
||||
name: 'Home',
|
||||
planning_goal: 'balanced',
|
||||
planning_mode: 'solo',
|
||||
created_at: '2026-01-01',
|
||||
}),
|
||||
@@ -685,7 +681,6 @@ describe('endpoint functions (representative coverage)', () => {
|
||||
json: async () => ({
|
||||
id: 'ws1',
|
||||
name: 'New name',
|
||||
planning_goal: 'max_money',
|
||||
planning_mode: 'couple',
|
||||
created_at: '2026-01-01',
|
||||
}),
|
||||
@@ -693,17 +688,14 @@ describe('endpoint functions (representative coverage)', () => {
|
||||
|
||||
const result = await api.updateWorkspace('ws1', {
|
||||
name: 'New name',
|
||||
planningGoal: 'max_money',
|
||||
planningMode: 'couple',
|
||||
})
|
||||
|
||||
expect(lastRequest()).toEqual({ url: '/api/workspace/ws1', method: 'PUT' })
|
||||
expect(lastRequestBody()).toEqual({
|
||||
name: 'New name',
|
||||
planning_goal: 'max_money',
|
||||
planning_mode: 'couple',
|
||||
})
|
||||
expect(result.planningGoal).toBe('max_money')
|
||||
expect(result.planningMode).toBe('couple')
|
||||
})
|
||||
|
||||
@@ -871,7 +863,6 @@ describe('endpoint functions (representative coverage)', () => {
|
||||
priority: 1,
|
||||
parent_mode: 'either',
|
||||
parent_personal_data_uuid: null,
|
||||
goal_override: null,
|
||||
created_at: '2026-01-01',
|
||||
updated_at: '2026-01-01',
|
||||
}),
|
||||
@@ -908,7 +899,6 @@ describe('endpoint functions (representative coverage)', () => {
|
||||
priority: 1,
|
||||
parent_mode: 'either',
|
||||
parent_personal_data_uuid: null,
|
||||
goal_override: null,
|
||||
created_at: '2026-01-01',
|
||||
updated_at: '2026-01-01',
|
||||
}),
|
||||
@@ -944,7 +934,6 @@ describe('endpoint functions (representative coverage)', () => {
|
||||
priority: 2,
|
||||
parent_mode: 'specific',
|
||||
parent_personal_data_uuid: 'pd1',
|
||||
goal_override: 'max_time',
|
||||
window_mode: 'fixed',
|
||||
created_at: '2026-01-01',
|
||||
updated_at: '2026-01-01',
|
||||
@@ -965,7 +954,6 @@ describe('endpoint functions (representative coverage)', () => {
|
||||
priority: 2,
|
||||
parentMode: 'specific',
|
||||
parentPersonalDataUuid: 'pd1',
|
||||
goalOverride: 'max_time',
|
||||
})
|
||||
|
||||
expect(lastRequestBody()).toEqual({
|
||||
@@ -982,7 +970,6 @@ describe('endpoint functions (representative coverage)', () => {
|
||||
priority: 2,
|
||||
parent_mode: 'specific',
|
||||
parent_personal_data_uuid: 'pd1',
|
||||
goal_override: 'max_time',
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1009,7 +996,6 @@ describe('endpoint functions (representative coverage)', () => {
|
||||
priority: 1,
|
||||
parent_mode: 'either',
|
||||
parent_personal_data_uuid: null,
|
||||
goal_override: null,
|
||||
window_mode: 'flexible',
|
||||
created_at: '2026-01-01',
|
||||
updated_at: '2026-01-01',
|
||||
@@ -1053,7 +1039,6 @@ describe('endpoint functions (representative coverage)', () => {
|
||||
priority: 1,
|
||||
parent_mode: 'either',
|
||||
parent_personal_data_uuid: null,
|
||||
goal_override: null,
|
||||
window_mode: 'fixed',
|
||||
created_at: '2026-01-01',
|
||||
updated_at: '2026-01-01',
|
||||
@@ -1095,7 +1080,6 @@ describe('endpoint functions (representative coverage)', () => {
|
||||
priority: 1,
|
||||
parent_mode: 'either',
|
||||
parent_personal_data_uuid: null,
|
||||
goal_override: null,
|
||||
window_mode: 'flexible',
|
||||
created_at: '2026-01-01',
|
||||
updated_at: '2026-01-01',
|
||||
|
||||
@@ -218,7 +218,6 @@ interface RawLeaveWish {
|
||||
priority: number
|
||||
parent_mode: 'either' | 'both' | 'specific'
|
||||
parent_personal_data_uuid: string | null
|
||||
goal_override: 'max_time' | 'max_money' | 'balanced' | null
|
||||
window_mode: 'fixed' | 'flexible'
|
||||
created_at: string | null
|
||||
updated_at: string | null
|
||||
@@ -242,7 +241,6 @@ function toLeaveWish(raw: RawLeaveWish): LeaveWish {
|
||||
priority: raw.priority,
|
||||
parentMode: raw.parent_mode,
|
||||
parentPersonalDataUuid: raw.parent_personal_data_uuid,
|
||||
goalOverride: raw.goal_override,
|
||||
windowMode: raw.window_mode ?? 'fixed',
|
||||
createdAt: raw.created_at,
|
||||
updatedAt: raw.updated_at,
|
||||
@@ -429,7 +427,6 @@ function toPersonalData(raw: RawPersonalData): PersonalData {
|
||||
interface RawWorkspace {
|
||||
id: string
|
||||
name: string
|
||||
planning_goal: 'max_time' | 'max_money' | 'balanced'
|
||||
planning_mode: 'solo' | 'couple'
|
||||
created_at: string
|
||||
}
|
||||
@@ -438,7 +435,6 @@ function toWorkspace(raw: RawWorkspace): Workspace {
|
||||
return {
|
||||
id: raw.id,
|
||||
name: raw.name,
|
||||
planningGoal: raw.planning_goal,
|
||||
planningMode: raw.planning_mode,
|
||||
createdAt: raw.created_at,
|
||||
}
|
||||
@@ -632,7 +628,6 @@ export async function updateWorkspace(
|
||||
method: 'PUT',
|
||||
body: JSON.stringify({
|
||||
name: req.name,
|
||||
planning_goal: req.planningGoal,
|
||||
planning_mode: req.planningMode,
|
||||
}),
|
||||
})) as RawWorkspace
|
||||
@@ -773,7 +768,6 @@ export async function createLeaveWish(payload: LeaveWishCreateRequest): Promise<
|
||||
priority: payload.priority ?? 1,
|
||||
parent_mode: payload.parentMode ?? 'either',
|
||||
parent_personal_data_uuid: payload.parentPersonalDataUuid ?? null,
|
||||
goal_override: payload.goalOverride ?? null,
|
||||
window_mode: payload.windowMode ?? 'fixed',
|
||||
}),
|
||||
})) as RawLeaveWish
|
||||
@@ -801,7 +795,6 @@ export async function updateLeaveWish(
|
||||
if (payload.parentPersonalDataUuid !== undefined) {
|
||||
body.parent_personal_data_uuid = payload.parentPersonalDataUuid
|
||||
}
|
||||
if (payload.goalOverride !== undefined) body.goal_override = payload.goalOverride
|
||||
if (payload.windowMode !== undefined) body.window_mode = payload.windowMode
|
||||
|
||||
const raw = (await apiFetch(`/leave-wishes/${id}`, {
|
||||
|
||||
@@ -45,7 +45,6 @@ export interface WorkspaceCreateRequest {
|
||||
|
||||
export interface WorkspaceUpdateRequest {
|
||||
name?: string
|
||||
planningGoal?: 'max_time' | 'max_money' | 'balanced'
|
||||
planningMode?: 'solo' | 'couple'
|
||||
}
|
||||
|
||||
@@ -86,7 +85,6 @@ export interface LeaveWishCreateRequest {
|
||||
priority?: number
|
||||
parentMode?: 'either' | 'both' | 'specific'
|
||||
parentPersonalDataUuid?: string | null
|
||||
goalOverride?: 'max_time' | 'max_money' | 'balanced' | null
|
||||
|
||||
// PLANNING_ENGINE_SPEC.md §10.1 — defaults to 'fixed' server-side when omitted.
|
||||
windowMode?: 'fixed' | 'flexible'
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
export interface Workspace {
|
||||
id: string
|
||||
name: string
|
||||
planningGoal: 'max_time' | 'max_money' | 'balanced'
|
||||
planningMode: 'solo' | 'couple'
|
||||
createdAt: string // ISO-8601
|
||||
}
|
||||
@@ -50,7 +49,6 @@ export interface LeaveWish {
|
||||
priority: number
|
||||
parentMode: 'either' | 'both' | 'specific'
|
||||
parentPersonalDataUuid: string | null
|
||||
goalOverride: 'max_time' | 'max_money' | 'balanced' | null
|
||||
// PLANNING_ENGINE_SPEC.md §10.1 — 'fixed': window_start_*/window_end_* are the
|
||||
// exact placement. 'flexible': the same fields describe the bounding range the
|
||||
// allocator searches within for the best-costing placement.
|
||||
|
||||
Reference in New Issue
Block a user