Staff Multi-Booking
Staff can book multiple tokens at once. All tokens will be assigned for the same date.
Minimum 1 patient required. Maximum 20 patients per batch.
"use client"; import { useState } from 'react'; import { useRouter } from 'next/navigation'; import Header from "../../components/partials/header"; import { useTheme } from "../../context/ThemeContext"; export default function MultiBooking() { const { darkMode } = useTheme(); const router = useRouter(); const [appointmentDate, setAppointmentDate] = useState(new Date().toISOString().split('T')[0]); const [patients, setPatients] = useState( Array(5).fill().map((_, i) => ({ id: i+1, name: "" })) ); const [loading, setLoading] = useState(false); const [error, setError] = useState(null); const handleNameChange = (id, value) => { setPatients(patients.map(p => p.id === id ? { ...p, name: value } : p )); }; const handleSubmit = async (e) => { e.preventDefault(); setLoading(true); setError(null); try { // Filter out empty names and validate const validPatients = patients.filter(p => p.name.trim() !== ""); if (validPatients.length === 0) { throw new Error("Please enter at least one patient name"); } // Store in session to use in MultiBooked page sessionStorage.setItem('multiBookingData', JSON.stringify({ date: appointmentDate, patients: validPatients })); router.push('/pages/MultiBooked'); } catch (error) { setError(error.message); } finally { setLoading(false); } }; const addMorePatients = () => { const newId = patients.length > 0 ? Math.max(...patients.map(p => p.id)) + 1 : 1; setPatients([...patients, { id: newId, name: "" }]); }; return (
Staff can book multiple tokens at once. All tokens will be assigned for the same date.
Minimum 1 patient required. Maximum 20 patients per batch.