Free days, vacation forfeiture, and global auto-replanning
Free days (Sat/Sun/red days, subject to DayOverride) can never be vacation, and can only be parental leave when the workspace opts in via take_pl_on_red_days. The allocator already honoured this; the hand-pin path bypassed it entirely. - PlanningService gains optional workspace_repo/day_override_repo deps and _reject_illegal_free_day, enforced in add_planned_day and update. Reuses allocation_service.is_free_day rather than re-deriving it, and no-ops when the deps are unset so existing callers are unaffected. - update_planned_day had no ValidationError handler at all, so a validation failure there 500'd instead of 422'ing. Fixed. - Calendar filters the pin write loop by the day's isFree; the modal explains free days stay off, and that pinning opts a day out of automatic re-planning. Vacation days at risk of forfeiture were computed and sent over the wire but never rendered: an at-risk column with the age-out/over-cap split, and a dashboard key figure. PlanProposal.warnings was likewise parsed but rendered nowhere, for all three kinds. Adds PlanWarningCard in a Risks section above the tips, with parent names resolved and dates formatted. POST /api/plan/sync now fires from the workspace layer on every plan-input change rather than only from Calendar, so a Settings edit or a pinned-day save re-plans day types instead of merely refetching. Overlapping bumps coalesce into one trailing run; a rejection cannot wedge the in-flight guard. eviction_preview was silently dropped by the frontend despite always being on the wire, and is now surfaced through context. Verified: backend 890 passed (91.49% coverage), frontend 1297 passed, ruff/eslint/tsc clean. Browser-checked in Swedish and English. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JVQx4NUvPbJhn6UcvRd2QY
This commit is contained in:
@@ -24,6 +24,7 @@ import { KeyFigures } from '@/components/dashboard/KeyFigures'
|
||||
import { Age4Bars } from '@/components/dashboard/Age4Bars'
|
||||
import { YearRows } from '@/components/dashboard/YearRows'
|
||||
import { SurplusAdviceTip } from '@/components/dashboard/SurplusAdviceTip'
|
||||
import { PlanWarningCard } from '@/components/dashboard/PlanWarningCard'
|
||||
import { ParentalLeaveBreakdown } from '@/components/dashboard/ParentalLeaveBreakdown'
|
||||
import { TipCard } from '@/components/inputs/TipCard'
|
||||
import { Onboarding } from '@/pages/Onboarding'
|
||||
@@ -133,6 +134,20 @@ export function Dashboard(): ReactNode {
|
||||
// the combined total, so skip the breakdown in that case.
|
||||
const showPerParentExpiring = parentProjections.length > 1
|
||||
|
||||
// Vacation days forecast lost (age-out or over the carry-forward cap),
|
||||
// across every parent, from this year onward — a past year's loss already
|
||||
// happened and is no longer actionable (same guard `YearRows` uses for
|
||||
// its own per-year expiring figure).
|
||||
const currentYear = new Date().getFullYear()
|
||||
const vacationAtRisk = parentProjections.reduce(
|
||||
(sum, projection) =>
|
||||
sum +
|
||||
projection.yearBalances
|
||||
.filter((balance) => balance.year >= currentYear)
|
||||
.reduce((yearSum, balance) => yearSum + balance.vacation.expiring, 0),
|
||||
0,
|
||||
)
|
||||
|
||||
const parentDisplayName = (uuid: string, index: number): string => {
|
||||
const resolved = membersLoading ? uuid : nameFor(uuid)
|
||||
return resolved === uuid
|
||||
@@ -217,6 +232,7 @@ export function Dashboard(): ReactNode {
|
||||
}))
|
||||
|
||||
const surplusAdvice = proposal?.surplusAdvice ?? []
|
||||
const warnings = proposal?.warnings ?? []
|
||||
const hasTips = (tips?.length ?? 0) > 0 || surplusAdvice.length > 0
|
||||
const heroRemedy = deriveHeroRemedy(tips)
|
||||
|
||||
@@ -254,6 +270,7 @@ export function Dashboard(): ReactNode {
|
||||
daysLeft={analytics.combinedDaysLeft}
|
||||
daysUsed={analytics.combinedDaysUsed}
|
||||
expiringAtB4={analytics.combinedExpiringAtB4}
|
||||
vacationAtRisk={vacationAtRisk}
|
||||
/>
|
||||
)}
|
||||
|
||||
@@ -278,6 +295,17 @@ export function Dashboard(): ReactNode {
|
||||
</section>
|
||||
)}
|
||||
|
||||
{warnings.length > 0 && (
|
||||
<section className="dashboard__section" data-testid="dashboard-warnings">
|
||||
<h2>{t('planWarnings.sectionTitle')}</h2>
|
||||
<div className="dashboard__tips-list">
|
||||
{warnings.map((warning, index) => (
|
||||
<PlanWarningCard key={`${warning.kind}-${index}`} warning={warning} nameFor={nameForAdvice} index={index} />
|
||||
))}
|
||||
</div>
|
||||
</section>
|
||||
)}
|
||||
|
||||
{hasTips && (
|
||||
<section className="dashboard__section" data-testid="dashboard-tips">
|
||||
<h2>{t('tips.title')}</h2>
|
||||
|
||||
Reference in New Issue
Block a user