import React, { useState, useEffect } from 'react' import NovaSelect from '../ui/NovaSelect' /** * Modal for choosing a category in bulk. * * Props: * - open: boolean * - categories: array of content types with nested categories * - onClose: () => void * - onConfirm: (categoryId: number) => void */ export default function BulkCategoryModal({ open, categories = [], onClose, onConfirm }) { const [selectedId, setSelectedId] = useState('') useEffect(() => { if (open) setSelectedId('') }, [open]) const handleConfirm = () => { if (!selectedId) return onConfirm(Number(selectedId)) } const handleKeyDown = (e) => { if (e.key === 'Escape') onClose() if (e.key === 'Enter' && selectedId) handleConfirm() } if (!open) return null return (
{/* Backdrop */}
{/* Modal */}
{/* Header */}

Change category

Choose a category to assign to the selected artworks.

{/* Category select */}
setSelectedId(value)} placeholder="Select a category…" options={categories.flatMap((ct) => ( (ct.categories || []).flatMap((cat) => ([ { value: String(cat.id), label: cat.name, group: ct.name }, ...((cat.children || []).map((child) => ({ value: String(child.id), label: child.name, group: ct.name }))), ])) ))} />
{/* Actions */}
) }