import { useEffect, useState, useRef } from "react"; import TimeDateSelector from "./TimeDateSelector"; // Import the TimeSlotSelector component /** * @param {null} null - Takes in nothing * @returns {JSX.element} JSX - HTML and JS functionality * @description Used for picking an interview slot * @author Ahmad * @todo CSS */ const InterviewForm = () => { const [isButtonDisabled, setIsButtonDisabled] = useState(false); const dialogRef = useRef(null); const [selectedTimeSlot, setSelectedTimeSlot] = useState(null); /** * @param {String HTML} event - Takes in form info * @returns {null} null - Returns in nothing * @description * @author Ahmad * @todo CSS */ const formsubmit = async (event) => { event.preventDefault(); if (!selectedTimeSlot) { alert("Please select a time slot!"); return; } setIsButtonDisabled(true); await new Promise((res) => setTimeout(res, 1000)); const formData = new FormData(event.target); const formObject = Object.fromEntries(formData.entries()); formObject.date = selectedTimeSlot["date"]; // Add the selected time slot to form data formObject.startTime = selectedTimeSlot["startTime"]; console.log("Form Data:", formObject); const res = await fetch( "https://bajabackend.bajacloud.duckdns.org/SelectInterview", { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify(formObject), } ); let data = await res.json(); console.log(data); // dialogRef.current.showModal(); setIsButtonDisabled(false); }; return ( <>
{/* Time Slot Selector */} setSelectedTimeSlot(timeSlot)} /> {/* Success Dialog */} {" "} {/* Add the `ref` attribute */}

Booking Successful!

Thank you for booking your interview slot. We’ll contact you soon.

What to do if I cannot make it to any of the avaliable time slots or need to rescedule?

While we highly encourage sceduling an interview in one of the above time slots, we recongize that not everyone can make it work with their personal and university schedules.

Please email us at{" "} uofcbaja@gmail.com to work out an alternate interview time or for rescheduling.

); }; export default InterviewForm;