diff --git a/src/components/charts/compliance-charts.tsx b/src/components/charts/compliance-charts.tsx deleted file mode 100644 index 2af43b6bb..000000000 --- a/src/components/charts/compliance-charts.tsx +++ /dev/null @@ -1,145 +0,0 @@ -"use client"; - -import { useState } from "react"; -import { useQuery } from "@tanstack/react-query"; -import { - Select, - SelectContent, - SelectItem, - SelectTrigger, - SelectValue, -} from "@/components/ui/select"; -import { Button } from "@/components/ui/button"; -import { Loader2 } from "lucide-react"; -import { useTranslations } from "@/lib/i18n/context"; -import { ComplianceHeatmap } from "./compliance-heatmap"; -import { ComplianceLineChart } from "./compliance-line-chart"; - -interface DailyData { - expected: number; - taken: number; - skipped: number; - onTime?: number; - late?: number; - veryLate?: number; -} - -interface ComplianceData { - dailyCompliance: Record; -} - -interface Medication { - id: string; - name: string; - dose: string; - active: boolean; -} - -interface ComplianceChartsProps { - medications: Medication[]; -} - -export function ComplianceCharts({ medications }: ComplianceChartsProps) { - const { t } = useTranslations(); - const [selectedId, setSelectedId] = useState(medications[0]?.id ?? ""); - const [rangePoints, setRangePoints] = useState<30 | 90 | 0>(30); - - const { data, isLoading } = useQuery({ - queryKey: ["compliance-chart", selectedId], - queryFn: async () => { - const res = await fetch(`/api/medications/${selectedId}/compliance`); - if (!res.ok) return null; - const json = await res.json(); - return json.data as ComplianceData; - }, - enabled: !!selectedId, - staleTime: 60 * 1000, - }); - - if (medications.length === 0) return null; - - return ( -
-
- -
- - {isLoading ? ( -
- -
- ) : !data?.dailyCompliance ? ( -
- {t("charts.noComplianceData")} -
- ) : ( -
-
-
-

- {t("charts.complianceDays90")} -

-
- -
-
-
-

- {t("charts.history")} -

-
- - - -
-
- -
-
- )} -
- ); -}