diff --git a/src/components/medications/intake-timeline.tsx b/src/components/medications/intake-timeline.tsx deleted file mode 100644 index e9bc6023f..000000000 --- a/src/components/medications/intake-timeline.tsx +++ /dev/null @@ -1,159 +0,0 @@ -"use client"; - -import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query"; -import { invalidateKeys, medicationDependentKeys } from "@/lib/query-keys"; -import { Badge } from "@/components/ui/badge"; -import { - AlertDialog, - AlertDialogAction, - AlertDialogCancel, - AlertDialogContent, - AlertDialogDescription, - AlertDialogFooter, - AlertDialogHeader, - AlertDialogTitle, - AlertDialogTrigger, -} from "@/components/ui/alert-dialog"; -import { Check, SkipForward, Loader2, X } from "lucide-react"; -import { formatDateWithWeekday, formatTime } from "@/lib/format"; -import { useTranslations } from "@/lib/i18n/context"; - -interface IntakeEvent { - id: string; - medicationId: string; - scheduledFor: string; - takenAt: string | null; - skipped: boolean; - source: string; - createdAt: string; -} - -interface IntakeTimelineProps { - medicationId: string; - medicationName: string; -} - -export function IntakeTimeline({ - medicationId, - medicationName, -}: IntakeTimelineProps) { - const queryClient = useQueryClient(); - const { t } = useTranslations(); - - const { data: events, isLoading } = useQuery({ - queryKey: ["medications", medicationId, "intake"], - queryFn: async () => { - const res = await fetch( - `/api/medications/${medicationId}/intake?limit=50`, - ); - if (!res.ok) throw new Error("Failed to fetch"); - const json = await res.json(); - return json.data.events as IntakeEvent[]; - }, - }); - - const deleteMutation = useMutation({ - mutationFn: async (eventId: string) => { - const res = await fetch( - `/api/medications/${medicationId}/intake/${eventId}`, - { method: "DELETE" }, - ); - if (!res.ok) throw new Error("Delete failed"); - }, - onSuccess: () => { - void invalidateKeys(queryClient, medicationDependentKeys); - }, - }); - - if (isLoading) { - return ( -
- {`${t("medications.noIntakesForMedication")} ${medicationName}`} -
- ); - } - - // Group by day - const grouped = new Map{day}
-