"use client"; import { Loader2, Trash2, X } 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"; /** * Selection action bar for the data-management lists (measurements + * mood). Appears when ≥1 row on the current page is selected; shows * "N selected", a destructive "Delete (N)" button gated behind an * AlertDialog confirm, and a clear-selection affordance. * * Pure / presentational: every behaviour is a callback. The component * renders nothing when `count === 0`. The bar is sticky to the bottom of * the viewport so it stays reachable while scrolling a long page, and the * confirm dialog is focus-trapped by the shared `AlertDialog` primitive. * * The confirm copy is passed in because the title/body differ per surface * (measurements vs mood) and the count is interpolated by the caller. */ export function SelectionActionBar({ count, onClear, onConfirmDelete, isDeleting, confirmTitle, confirmBody, }: { count: number; onClear: () => void; onConfirmDelete: () => void; isDeleting: boolean; confirmTitle: string; confirmBody: string; }) { const { t } = useTranslations(); if (count <= 0) return null; return (
{t("dataList.selected", { count: String(count) })}
{confirmTitle} {confirmBody} {t("common.cancel")} {isDeleting ? ( ) : null} {t("common.delete")}
); }