From a4c8f28ecb034400cfd376c82a2842a37957cabb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Bombeck?= Date: Mon, 6 Apr 2026 13:34:27 +0200 Subject: [PATCH] feat(ui): integrate InsightStatusCard into insights page Replace 7 inline status text sections (general, blood pressure, weight, pulse, mood, medication compliance, BMI) with the new InsightStatusCard component. This adds consistent Card-based rendering with loading states, provider detection, cache indicators, and timestamps. Co-Authored-By: Claude Opus 4.6 (1M context) --- src/app/insights/page.tsx | 253 ++++++++++---------------------------- 1 file changed, 67 insertions(+), 186 deletions(-) diff --git a/src/app/insights/page.tsx b/src/app/insights/page.tsx index 4dea98fed..579b8cd30 100644 --- a/src/app/insights/page.tsx +++ b/src/app/insights/page.tsx @@ -29,12 +29,16 @@ import { ComplianceHeatmap } from "@/components/charts/compliance-heatmap"; import { Activity, Heart, + HeartPulse, Loader2, Percent, Pill, + Ruler, + Scale, Smile, TrendingUp, } from "lucide-react"; +import { InsightStatusCard } from "@/components/insights/insight-status-card"; import { ScatterChart, Scatter, @@ -525,7 +529,6 @@ export default function InsightsPage() { const { data: generalStatus, isLoading: isGeneralStatusLoading, - isError: isGeneralStatusError, } = useQuery({ queryKey: ["insights", "general-status", locale], queryFn: async () => { @@ -541,7 +544,6 @@ export default function InsightsPage() { const { data: bloodPressureStatus, isLoading: isBloodPressureStatusLoading, - isError: isBloodPressureStatusError, } = useQuery({ queryKey: ["insights", "blood-pressure-status", locale], queryFn: async () => { @@ -559,7 +561,6 @@ export default function InsightsPage() { const { data: weightStatus, isLoading: isWeightStatusLoading, - isError: isWeightStatusError, } = useQuery({ queryKey: ["insights", "weight-status", locale], queryFn: async () => { @@ -575,7 +576,6 @@ export default function InsightsPage() { const { data: pulseStatus, isLoading: isPulseStatusLoading, - isError: isPulseStatusError, } = useQuery({ queryKey: ["insights", "pulse-status", locale], queryFn: async () => { @@ -591,7 +591,6 @@ export default function InsightsPage() { const { data: bmiStatus, isLoading: isBmiStatusLoading, - isError: isBmiStatusError, } = useQuery({ queryKey: ["insights", "bmi-status", locale], queryFn: async () => { @@ -607,7 +606,6 @@ export default function InsightsPage() { const { data: moodStatus, isLoading: isMoodStatusLoading, - isError: isMoodStatusError, } = useQuery({ queryKey: ["insights", "mood-status", locale], queryFn: async () => { @@ -623,7 +621,6 @@ export default function InsightsPage() { const { data: medicationComplianceStatus, isLoading: isMedicationComplianceStatusLoading, - isError: isMedicationComplianceStatusError, } = useQuery({ queryKey: ["insights", "medication-compliance-status", locale], queryFn: async () => { @@ -929,27 +926,15 @@ export default function InsightsPage() { {t(`insights.generalStatusBadge.${overallStatus.level}`)} - {isGeneralStatusLoading ? ( -

- {t("insights.generalStatusLoading")} -

- ) : isGeneralStatusError ? ( -

- {t("insights.generalStatusUnavailable")} -

- ) : generalStatus?.text ? ( -

- {generalStatus.text} -

- ) : !generalStatus?.hasProvider ? ( -

- {t("insights.generalStatusNoKey")} -

- ) : ( -

- {generalStatus.text ?? t("insights.generalStatusUnavailable")} -

- )} + } + text={generalStatus?.text ?? null} + hasProvider={generalStatus?.hasProvider ?? false} + cached={generalStatus?.cached ?? false} + updatedAt={generalStatus?.updatedAt ?? null} + loading={isGeneralStatusLoading} + /> {/* Section 3: Blood pressure */} @@ -1213,33 +1198,15 @@ export default function InsightsPage() { -
-

- {t("insights.assessmentTitle")} -

- {isBloodPressureStatusLoading ? ( -

- {t("insights.bloodPressureStatusLoading")} -

- ) : isBloodPressureStatusError ? ( -

- {t("insights.bloodPressureStatusUnavailable")} -

- ) : bloodPressureStatus?.text ? ( -

- {bloodPressureStatus.text} -

- ) : !bloodPressureStatus?.hasProvider ? ( -

- {t("insights.bloodPressureStatusNoKey")} -

- ) : ( -

- {bloodPressureStatus.text ?? - t("insights.bloodPressureStatusUnavailable")} -

- )} -
+ } + text={bloodPressureStatus?.text ?? null} + hasProvider={bloodPressureStatus?.hasProvider ?? false} + cached={bloodPressureStatus?.cached ?? false} + updatedAt={bloodPressureStatus?.updatedAt ?? null} + loading={isBloodPressureStatusLoading} + /> {/* Section 4: Weight */} @@ -1462,32 +1429,15 @@ export default function InsightsPage() { )} -
-

- {t("insights.assessmentTitle")} -

- {isWeightStatusLoading ? ( -

- {t("insights.weightStatusLoading")} -

- ) : isWeightStatusError ? ( -

- {t("insights.weightStatusUnavailable")} -

- ) : weightStatus?.text ? ( -

- {weightStatus.text} -

- ) : !weightStatus?.hasProvider ? ( -

- {t("insights.weightStatusNoKey")} -

- ) : ( -

- {weightStatus.text ?? t("insights.weightStatusUnavailable")} -

- )} -
+ } + text={weightStatus?.text ?? null} + hasProvider={weightStatus?.hasProvider ?? false} + cached={weightStatus?.cached ?? false} + updatedAt={weightStatus?.updatedAt ?? null} + loading={isWeightStatusLoading} + /> {/* Section 5: Pulse */} @@ -1512,32 +1462,15 @@ export default function InsightsPage() { valueBands={pulseBands} /> -
-

- {t("insights.assessmentTitle")} -

- {isPulseStatusLoading ? ( -

- {t("insights.pulseStatusLoading")} -

- ) : isPulseStatusError ? ( -

- {t("insights.pulseStatusUnavailable")} -

- ) : pulseStatus?.text ? ( -

- {pulseStatus.text} -

- ) : !pulseStatus?.hasProvider ? ( -

- {t("insights.pulseStatusNoKey")} -

- ) : ( -

- {pulseStatus.text ?? t("insights.pulseStatusUnavailable")} -

- )} -
+ } + text={pulseStatus?.text ?? null} + hasProvider={pulseStatus?.hasProvider ?? false} + cached={pulseStatus?.cached ?? false} + updatedAt={pulseStatus?.updatedAt ?? null} + loading={isPulseStatusLoading} + /> {/* Section: Mood */} @@ -1557,32 +1490,15 @@ export default function InsightsPage() { -
-

- {t("insights.assessmentTitle")} -

- {isMoodStatusLoading ? ( -

- {t("insights.moodStatusLoading")} -

- ) : isMoodStatusError ? ( -

- {t("insights.moodStatusUnavailable")} -

- ) : moodStatus?.text ? ( -

- {moodStatus.text} -

- ) : !moodStatus?.hasProvider ? ( -

- {t("insights.moodStatusNoKey")} -

- ) : ( -

- {moodStatus.text ?? t("insights.moodStatusUnavailable")} -

- )} -
+ } + text={moodStatus?.text ?? null} + hasProvider={moodStatus?.hasProvider ?? false} + cached={moodStatus?.cached ?? false} + updatedAt={moodStatus?.updatedAt ?? null} + loading={isMoodStatusLoading} + /> )} @@ -1668,33 +1584,15 @@ export default function InsightsPage() { ) : null} -
-

- {t("insights.assessmentTitle")} -

- {isMedicationComplianceStatusLoading ? ( -

- {t("insights.medicationComplianceStatusLoading")} -

- ) : isMedicationComplianceStatusError ? ( -

- {t("insights.medicationComplianceStatusUnavailable")} -

- ) : medicationComplianceStatus?.summary ? ( -

- {medicationComplianceStatus.summary} -

- ) : !medicationComplianceStatus?.hasProvider ? ( -

- {t("insights.medicationComplianceStatusNoKey")} -

- ) : ( -

- {medicationComplianceStatus.summary ?? - t("insights.medicationComplianceStatusUnavailable")} -

- )} -
+ } + text={medicationComplianceStatus?.summary ?? null} + hasProvider={medicationComplianceStatus?.hasProvider ?? false} + cached={medicationComplianceStatus?.cached ?? false} + updatedAt={medicationComplianceStatus?.updatedAt ?? null} + loading={isMedicationComplianceStatusLoading} + /> {/* Section 7: BMI */} @@ -1724,32 +1622,15 @@ export default function InsightsPage() {

{t("common.noData")}

)} -
-

- {t("insights.assessmentTitle")} -

- {isBmiStatusLoading ? ( -

- {t("insights.bmiStatusLoading")} -

- ) : isBmiStatusError ? ( -

- {t("insights.bmiStatusUnavailable")} -

- ) : bmiStatus?.text ? ( -

- {bmiStatus.text} -

- ) : !bmiStatus?.hasProvider ? ( -

- {t("insights.bmiStatusNoKey")} -

- ) : ( -

- {bmiStatus.text ?? t("insights.bmiStatusUnavailable")} -

- )} -
+ } + text={bmiStatus?.text ?? null} + hasProvider={bmiStatus?.hasProvider ?? false} + cached={bmiStatus?.cached ?? false} + updatedAt={bmiStatus?.updatedAt ?? null} + loading={isBmiStatusLoading} + /> );