// CreateWO.jsx — Admin-only booking creation. Strict shift options (8am-12pm / 1pm-5pm / Custom). // Reusable searchable select with an inline "+ Add new" footer. // `options` is an array of strings; `onAddNew` (optional) opens an add UI. function SearchableSelect({ value, onChange, options, placeholder, onAddNew, addLabel, error, emptyText, disabled }) { const [open, setOpen] = React.useState(false); const [q, setQ] = React.useState(''); const ref = React.useRef(null); const inputRef = React.useRef(null); React.useEffect(() => { if (!open) return; const onDoc = (e) => { if (ref.current && !ref.current.contains(e.target)) setOpen(false); }; document.addEventListener('mousedown', onDoc); setTimeout(() => inputRef.current && inputRef.current.focus(), 30); return () => document.removeEventListener('mousedown', onDoc); }, [open]); const filtered = (options || []).filter(o => o.toLowerCase().includes(q.toLowerCase())); return (
{editBooking.id} · changes notify the operator via push>
: duplicated
? <>Duplicated from {editBooking.id} · new work order {pendingWO} assigned on submit · pick a new date>
: <>Booking creation is restricted to Admin · Customer code maps to AutoCount Debtor>}