diff --git a/src/features/prozess/hooks.ts b/src/features/prozess/hooks.ts index 65bd042..47825a6 100644 --- a/src/features/prozess/hooks.ts +++ b/src/features/prozess/hooks.ts @@ -86,7 +86,7 @@ export function useSitzungen(sprechstundeId: number) { ); } -export function useProcessStatus( +export function deriveProcessStatus( nutzer: NutzerRow | undefined, stats: KontaktStats | undefined, erstgespraeche: ErstgespraechRow[], diff --git a/src/routes/prozess/index.tsx b/src/routes/prozess/index.tsx index 8c355ca..15173fa 100644 --- a/src/routes/prozess/index.tsx +++ b/src/routes/prozess/index.tsx @@ -1,6 +1,11 @@ import { createFileRoute } from "@tanstack/react-router"; import { ProcessStepper } from "@/features/prozess/components/process-stepper"; -import { useKontaktStats, useNutzer } from "@/features/prozess/hooks"; +import { + deriveProcessStatus, + useErstgespraeche, + useKontaktStats, + useNutzer, +} from "@/features/prozess/hooks"; export const Route = createFileRoute("/prozess/")({ component: ProzessPage, @@ -17,20 +22,34 @@ function ProzessPage() { loading: statsLoading, refetch: refetchStats, } = useKontaktStats(); + const { + data: erstgespraeche, + loading: egLoading, + refetch: refetchEg, + } = useErstgespraeche(); - if (nutzerLoading || statsLoading) return
Laden…
; + if (nutzerLoading || statsLoading || egLoading) returnLaden…
; if (!nutzer[0]) returnBitte zuerst das Onboarding abschließen.
; - const s = stats[0] ?? { gesamt: 0, absagen: 0 }; + const s = stats[0] ?? { + gesamt: 0, + absagen: 0, + warteliste: 0, + keine_antwort: 0, + }; + + const processStatus = deriveProcessStatus(nutzer[0], s, erstgespraeche); return (