import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogFooter } from '@/components/ui/dialog'; import { Button } from '@/components/ui/button'; import { Input } from '@/components/ui/input'; import { Switch } from '@/components/ui/switch'; import { Label } from '@/components/ui/label'; import { Textarea } from '@/components/ui/textarea'; import { BytescaleUploader } from '@/components/BytescaleUploader/BytescaleUploader'; import { Department } from '@/api/department'; import { FacilityImage, Facility } from '@/api/facility'; interface FacilityModalProps { open: boolean; onOpenChange: (open: boolean) => void; editing: Facility | null; form: any; setForm: any; departments: Department[]; onSubmit: () => void; } export default function FacilityModal({ open, onOpenChange, editing, form, setForm, departments, onSubmit, }: FacilityModalProps) { const handleChange = (e: React.ChangeEvent) => { const { name, value, type } = e.target; let finalValue: any = type === 'number' ? Number(value) : value; if (name === 'slug') { finalValue = finalValue .toLowerCase() .replace(/\s+/g, '-') .replace(/[^\w-]+/g, '') .replace(/--+/g, '-'); } setForm((prev: any) => ({ ...prev, [name]: finalValue })); }; const handleAddImageField = () => { setForm((prev: any) => ({ ...prev, images: [...prev.images, { url: '', altText: '', description: '' }], })); }; const handleRemoveImageField = (index: number) => { setForm((prev: any) => ({ ...prev, images: prev.images.filter((_: any, i: number) => i !== index), })); }; const handleImageChange = (index: number, field: keyof FacilityImage, value: string) => { setForm((prev: any) => { const updatedImages = [...prev.images]; updatedImages[index] = { ...updatedImages[index], [field]: value }; return { ...prev, images: updatedImages }; }); }; return ( {editing ? 'Edit Facility Record' : 'Add New Facility Asset'}
{/* Left Side: Profile & Structure */}

Profile & Structure

setForm({ ...form, isActive: val })} />
setForm({ ...form, isFeatured: val })} />