"use client"; /** * Floating bulk-action bar for the vault's multi-select mode. Appears once * at least one document is selected, pinned above the bottom nav on phones * and near the bottom edge on desktop. Carries the selected count and the * four bulk verbs — set type, link condition, delete (undo-able), clear — * all driving `POST /api/documents/inbound/bulk` from the page. * * A `role="toolbar"` with proper labels; the destructive verb sits last * before Clear so a stray tap sequence never ends on Delete. The bar is a * deliberate hand-rolled shell (a floating toolbar is not a Card surface): * dense-tile padding `p-3` per the standards. */ import { FolderPlus, Tag, Trash2, X } from "lucide-react"; import { Button } from "@/components/ui/button"; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu"; import { useTranslations } from "@/lib/i18n/context"; import { cn } from "@/lib/utils"; import type { InboundDocumentKindValue } from "@/lib/validations/inbound-documents"; import { DOCUMENT_KIND_ICONS, DOCUMENT_KIND_ORDER } from "./document-kind-meta"; export interface BulkEpisodeOption { id: string; label: string; } export function DocumentBulkBar({ selectedCount, episodes, busy, onSetKind, onLinkEpisode, onDelete, onClear, }: { selectedCount: number; /** The caller's live illness episodes — the link-condition targets. */ episodes: BulkEpisodeOption[]; /** A bulk call is in flight — the verbs disable, Clear stays live. */ busy: boolean; onSetKind: (kind: InboundDocumentKindValue) => void; onLinkEpisode: (episodeId: string) => void; onDelete: () => void; onClear: () => void; }) { const { t } = useTranslations(); return (

{t("documents.selection.count", { count: selectedCount })}

{DOCUMENT_KIND_ORDER.map((kind) => { const Icon = DOCUMENT_KIND_ICONS[kind]; return ( onSetKind(kind)}> {t(`documents.kind.${kind}`)} ); })} {episodes.length > 0 ? ( {episodes.map((episode) => ( onLinkEpisode(episode.id)} > {episode.label} ))} ) : null} {/* Solid destructive (matching the detail sheet's Delete) — the outline variant's destructive text on the card surface fails the WCAG contrast gate. */}
); }