Show the partner's name, and count in the unit that was asked for

A partner added during onboarding appeared as "Parent 2" on the overview
until you navigated away and back: the members list had been fetched before
that partner existed and nothing refetched when the wizard finished. The
fallback was doing its job; it was covering for stale data.

A period drawn on the calendar is measured in days, but a shortfall was
reported in the weeks the engine had rounded it to, so seven days came back
as three weeks. It now reports what was actually asked for.
This commit is contained in:
2026-09-18 00:23:16 +02:00
parent 18c742c16a
commit 8d2f658061
4 changed files with 71 additions and 3 deletions
+19 -2
View File
@@ -1,4 +1,4 @@
import { ReactNode, useState } from 'react'
import { ReactNode, useEffect, useRef, useState } from 'react'
import { useNavigate } from 'react-router-dom'
import { useWorkspace } from '@/context'
import {
@@ -47,7 +47,7 @@ export function Dashboard(): ReactNode {
)
const { data: plannedDays, isLoading: pdLoading } = usePlannedDays(selectedChildId ?? undefined)
const { data: parentalLeave, refresh: refreshParentalLeave } = useParentalLeave(personalDataUuid, selectedChildId ?? null)
const { data: members, isLoading: membersLoading } = useWorkspaceMembers(workspace?.id ?? null)
const { data: members, isLoading: membersLoading, refresh: refreshMembers } = useWorkspaceMembers(workspace?.id ?? null)
const { data: tips, dismiss: dismissTip } = useOptimizationTips(workspace?.id ?? null)
const scraper = useScraperFetch()
@@ -56,6 +56,23 @@ export function Dashboard(): ReactNode {
const [isManualFetchSaving, setIsManualFetchSaving] = useState(false)
const [manualFetchError, setManualFetchError] = useState<string | null>(null)
// `useWorkspaceMembers` fetches once per `workspace.id`, which never
// changes across onboarding — so a couple's partner, added mid-wizard via
// `Onboarding.tsx`'s own direct `api.addPartner` call, is invisible to
// this hook's already-fetched `data` until something explicitly refetches
// it. `Onboarding` only refreshes `WorkspaceContext` (which flips
// `children` from empty to non-empty) when it finishes — it has no way to
// reach into this component's `useWorkspaceMembers` instance. Watching
// that same empty-to-non-empty transition here is what tells this
// component "onboarding just finished, the members list might be stale."
const wasAwaitingFirstChildRef = useRef(children.length === 0)
useEffect(() => {
if (wasAwaitingFirstChildRef.current && children.length > 0) {
void refreshMembers()
}
wasAwaitingFirstChildRef.current = children.length === 0
}, [children.length, refreshMembers])
const isLoading = wsLoading || analyticsLoading || pdLoading
if (isLoading) {