import { useEffect, useState } from 'react' import clsx from 'clsx' import { Trash2, Archive } from 'lucide-react' import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, } from '@/components/ui/dialog' import { Button } from '@/components/ui/button' import { RadioGroup, RadioGroupItem } from '@/components/ui/radio-group' import { Label } from '@/components/ui/label' interface DeleteFolderDialogProps { isOpen: boolean folderName: string /** Number of photos under this folder, including descendants. Surfaced * in the dialog copy so the user understands the blast radius. */ photoCount?: number onClose: () => void /** Called with the chosen mode when the user confirms. */ onConfirm: (mode: 'discard' | 'permanent') => void } type Mode = 'discard' | 'permanent' /** * Two-mode folder delete dialog built on the shadcn Dialog + RadioGroup * primitives (instead of the old custom fixed-inset backdrop). Esc * closes, overlay click closes, focus is trapped by Radix. */ export function DeleteFolderDialog({ isOpen, folderName, photoCount, onClose, onConfirm, }: DeleteFolderDialogProps) { const [mode, setMode] = useState('discard') // Reset mode when re-opening so the safe option is always the default. useEffect(() => { if (isOpen) setMode('discard') }, [isOpen]) const photoBlurb = photoCount === undefined ? 'photos in this folder' : photoCount === 0 ? 'this empty folder' : `${photoCount} photo${photoCount === 1 ? '' : 's'} in this folder` return ( !o && onClose()}> Delete folder "{folderName}"? What should happen to {photoBlurb}? setMode(v as Mode)} className="gap-2" > } title="Move photos to discard pile" description="Photos can be restored later from Discarded. The folder and files stay on disk." selected={mode === 'discard'} /> } title="Permanently delete folder and photos" description="Removes the folder, every photo inside it, and the directory from disk. This cannot be undone." selected={mode === 'permanent'} destructive /> ) } /** Radio-group item rendered as a full-width descriptive card. */ function ModeCard({ id, value, icon, title, description, selected, destructive = false, }: { id: string value: string icon: React.ReactNode title: string description: string selected: boolean destructive?: boolean }) { return ( ) }