mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-10 05:12:14 +00:00
Resolve the catalog slug from both the current-locale display name and the English canonical name. A marker stores the catalog name as it read at creation time, so one minted under the English default and then viewed in another locale never matched a map built only from the current locale's names — its rich per-biomarker description silently fell back to the generic line. The English bundle is always in the client chunk, so adding its names makes the lookup independent of the locale the marker was created in. Tidy the header control cluster: - Drop the standalone "adjust target range" control and its sheet; the reference bounds are already editable inside the full marker editor behind the pencil. Remove the now-dead handler, mutation, and `targetRange.*` strings across all locales. - Give the show-all-values, edit, and delete controls one shared ghost-icon treatment instead of the show-all control's separate muted variant. - Add hover tooltips to edit and delete, matching the other icon controls. - Order the controls left → right: delete, edit, show all values, add value.
80 lines
2.3 KiB
TypeScript
80 lines
2.3 KiB
TypeScript
"use client";
|
|
|
|
import { Trash2 } from "lucide-react";
|
|
|
|
import { Button } from "@/components/ui/button";
|
|
import {
|
|
AlertDialog,
|
|
AlertDialogAction,
|
|
AlertDialogCancel,
|
|
AlertDialogContent,
|
|
AlertDialogDescription,
|
|
AlertDialogFooter,
|
|
AlertDialogHeader,
|
|
AlertDialogTitle,
|
|
AlertDialogTrigger,
|
|
} from "@/components/ui/alert-dialog";
|
|
import { useTranslations } from "@/lib/i18n/context";
|
|
|
|
/**
|
|
* Shared single-row delete button + confirm dialog for the data-
|
|
* management lists (measurements + mood). Lifted from the two
|
|
* copy-pasted `DeleteButton` helpers (v1.15.13).
|
|
*
|
|
* The confirm copy differs per surface (a measurement vs a mood entry),
|
|
* so the title/description are passed in rather than reaching for a fixed
|
|
* translation key. `cancelLabel` / `confirmLabel` default to the shared
|
|
* `common.*` strings.
|
|
*/
|
|
export function DeleteButton({
|
|
onConfirm,
|
|
title,
|
|
description,
|
|
cancelLabel,
|
|
confirmLabel,
|
|
triggerTitle,
|
|
className = "",
|
|
iconClassName = "h-3.5 w-3.5",
|
|
}: {
|
|
onConfirm: () => void;
|
|
title: string;
|
|
description: string;
|
|
cancelLabel?: string;
|
|
confirmLabel?: string;
|
|
/** Native hover tooltip on the trigger; defaults to the accessible name. */
|
|
triggerTitle?: string;
|
|
className?: string;
|
|
iconClassName?: string;
|
|
}) {
|
|
const { t } = useTranslations();
|
|
return (
|
|
<AlertDialog>
|
|
<AlertDialogTrigger asChild>
|
|
<Button
|
|
variant="ghost"
|
|
size="icon-lg"
|
|
className={`text-destructive ${className}`}
|
|
aria-label={confirmLabel ?? t("common.delete")}
|
|
title={triggerTitle ?? confirmLabel ?? t("common.delete")}
|
|
>
|
|
<Trash2 className={iconClassName} />
|
|
</Button>
|
|
</AlertDialogTrigger>
|
|
<AlertDialogContent>
|
|
<AlertDialogHeader>
|
|
<AlertDialogTitle>{title}</AlertDialogTitle>
|
|
<AlertDialogDescription>{description}</AlertDialogDescription>
|
|
</AlertDialogHeader>
|
|
<AlertDialogFooter>
|
|
<AlertDialogCancel>
|
|
{cancelLabel ?? t("common.cancel")}
|
|
</AlertDialogCancel>
|
|
<AlertDialogAction variant="destructive" onClick={onConfirm}>
|
|
{confirmLabel ?? t("common.delete")}
|
|
</AlertDialogAction>
|
|
</AlertDialogFooter>
|
|
</AlertDialogContent>
|
|
</AlertDialog>
|
|
);
|
|
}
|