fix(labs): confirm destructive deletes on lab results and Vorsorge reminders

The single-row delete on lab results and on preventive-care reminders
fired immediately on click, unlike the measurement and mood lists which
gate the same action behind a confirm dialog. Route both through the
shared DeleteButton so a stray tap can no longer drop a reading or a
reminder, and add the per-surface confirm copy across all locales.
This commit is contained in:
Marc-André Bombeck committed 2026-06-16 00:45:19 +02:00
1 parent 7c8d82f565
commit ba7a72f484
8 files changed
+44 -22

No files matched your search

+10 -11
View File
@@ -2,9 +2,10 @@
import { useMemo } from "react";
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
import { FlaskConical, Trash2 } from "lucide-react";
import { FlaskConical } from "lucide-react";
import { toast } from "sonner";
import { DeleteButton } from "@/components/data-list";
import { Button } from "@/components/ui/button";
import {
Card,
@@ -166,16 +167,14 @@ export function LabList({ onAddFirst }: { onAddFirst?: () => void } = {}) {
</CardTitle>
<CardAction className="flex items-center gap-3">
<LabTrendSparkline values={group.readings.map((r) => r.value)} />
<Button
variant="ghost"
size="icon"
className="text-muted-foreground hover:text-destructive"
aria-label={t("labs.deleteLatest")}
disabled={deleteMutation.isPending}
onClick={() => deleteMutation.mutate(group.latest.id)}
>
<Trash2 className="h-4 w-4" />
</Button>
<DeleteButton
onConfirm={() => deleteMutation.mutate(group.latest.id)}
title={t("labs.deleteConfirmTitle")}
description={t("labs.deleteConfirmDescription")}
confirmLabel={t("labs.deleteLatest")}
className="size-9"
iconClassName="h-4 w-4"
/>
</CardAction>
</CardHeader>
<CardContent>
@@ -13,9 +13,10 @@
* relative to "now" but never recomputes the cadence.
*/
import { useState } from "react";
import { CheckCircle2, Plus, Trash2 } from "lucide-react";
import { CheckCircle2, Plus } from "lucide-react";
import { useTranslations } from "@/lib/i18n/context";
import { DeleteButton } from "@/components/data-list";
import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
import {
@@ -365,16 +366,14 @@ function VorsorgeCard({
<CheckCircle2 className="mr-1 h-4 w-4" />
{t("measurementReminders.markDone")}
</Button>
<Button
type="button"
size="sm"
variant="ghost"
onClick={onRemove}
disabled={busy}
aria-label={t("measurementReminders.delete")}
>
<Trash2 className="h-4 w-4" />
</Button>
<DeleteButton
onConfirm={onRemove}
title={t("measurementReminders.deleteConfirmTitle")}
description={t("measurementReminders.deleteConfirmDescription")}
confirmLabel={t("measurementReminders.delete")}
className="size-9"
iconClassName="h-4 w-4"
/>
</CardAction>
</CardHeader>
<CardContent className="space-y-1">