mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-14 22:50:51 +00:00
feat(analytics): replace health score with reference composite
This commit is contained in:
1 parent
666a85d311
commit
c91558f18f
87 files changed
+6033
-5868
No files matched your search
@@ -1,16 +1,15 @@
|
||||
"use client";
|
||||
|
||||
import { useContext } from "react";
|
||||
import { QueryClientContext } from "@tanstack/react-query";
|
||||
import { QueryClientContext, type QueryClient } from "@tanstack/react-query";
|
||||
|
||||
/**
|
||||
* v1.4.48 M4 — shared SSR-safety helper for hooks that delegate to
|
||||
* React Query under a `<QueryClientProvider>`.
|
||||
*
|
||||
* A long tail of legacy presentational components (`<HeroStrip>`,
|
||||
* `<SuggestedPrompts>`, `<LayoutCoachFab>`, `<InsightStatusCard>`,
|
||||
* `<HealthScoreDeltaExplainer>`, …) ships with unit tests that render
|
||||
* the component in isolation without wrapping it in
|
||||
* Several presentational components (`<HeroStrip>`, `<SuggestedPrompts>`,
|
||||
* `<LayoutCoachFab>`, and `<InsightStatusCard>`) ship with unit tests that
|
||||
* render the component in isolation without wrapping it in
|
||||
* `<QueryClientProvider>`. Hooks that call `useQuery` directly crash
|
||||
* in that environment.
|
||||
*
|
||||
@@ -31,3 +30,8 @@ export function useQueryClientMounted(): boolean {
|
||||
);
|
||||
return ctx != null;
|
||||
}
|
||||
|
||||
/** Return the mounted client without throwing in isolated SSR renders. */
|
||||
export function useOptionalQueryClient(): QueryClient | undefined {
|
||||
return useContext(QueryClientContext);
|
||||
}
|
||||
@@ -70,9 +70,8 @@ async function fetchFeatureFlags(): Promise<FeatureFlagsPayload> {
|
||||
* remount within a minute. The hook fails open — any network error
|
||||
* returns the all-on default so the user keeps seeing the surface.
|
||||
*
|
||||
* The hook is referenced from a long tail of legacy presentational
|
||||
* components (`<InsightStatusCard>`, `<HealthScoreDeltaExplainer>`)
|
||||
* whose unit tests render the component without a
|
||||
* The hook is referenced from presentational components such as
|
||||
* `<InsightStatusCard>` whose unit tests render without a
|
||||
* `<QueryClientProvider>`. To keep those tests valid we delegate
|
||||
* the React-Query call to a child hook that's only invoked when a
|
||||
* client is mounted. The branch is stable across the component's
|
||||
|
||||
Reference in new issue
Block a user