From 784105d3bb86ce9eb054e4b757dd38909ee0330d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Bombeck?= Date: Thu, 14 May 2026 15:30:05 +0200 Subject: [PATCH] chore(medications): remove unused IntakeTimeline component MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The component was exported but never imported anywhere — only the file itself contained the three references (the props interface, the function declaration, and the type annotation). Likely an early scaffold for the v1.4 medication-intake redesign that was superseded by the intake-card layout before any caller wired it in. No tests existed for this component, so the delete is single-file. --- .../medications/intake-timeline.tsx | 159 ------------------ 1 file changed, 159 deletions(-) delete mode 100644 src/components/medications/intake-timeline.tsx 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 ( -
- -
- ); - } - - if (!events?.length) { - return ( -

- {`${t("medications.noIntakesForMedication")} ${medicationName}`} -

- ); - } - - // Group by day - const grouped = new Map(); - for (const event of events) { - const day = formatDateWithWeekday(event.scheduledFor); - const list = grouped.get(day) ?? []; - list.push(event); - grouped.set(day, list); - } - - return ( -
- {[...grouped.entries()].map(([day, dayEvents]) => ( -
-

{day}

-
- {dayEvents.map((event) => ( -
- - {event.skipped ? ( - - ) : ( - - )} - {formatTime(event.scheduledFor)} - {event.source !== "WEB" && ( - - {event.source} - - )} - - - - - - - - - {t("medications.intakeDeleteConfirm")} - - - {t("medications.intakeDeleteDescription")} - - - - - {t("common.cancel")} - - deleteMutation.mutate(event.id)} - > - {t("common.delete")} - - - - -
- ))} -
-
- ))} -
- ); -}