diff --git a/src/Interivew Booking/Database.json b/src/Interivew Booking/Database.json
new file mode 100644
index 0000000..6dbb143
--- /dev/null
+++ b/src/Interivew Booking/Database.json
@@ -0,0 +1,7 @@
+{
+ "body": {
+ "interviewDates": {
+ "2025-01-11": { "11:30:00": { "Meeting Duration": "30 min" } }
+ }
+ }
+}
diff --git a/src/Interivew Booking/InterviewBooking.jsx b/src/Interivew Booking/InterviewBooking.jsx
index 0e95b73..eb08065 100644
--- a/src/Interivew Booking/InterviewBooking.jsx
+++ b/src/Interivew Booking/InterviewBooking.jsx
@@ -1,5 +1,6 @@
import InterviewForm from "./InterviewForm";
import logo from "../Header/logo.webp";
+import Ender from "../Footer/Ender";
/**
* @param {null} null - requires onthing
* @returns {JSX.Element} Page - HTML tags and JS functionality
@@ -14,6 +15,21 @@ const InterviewBooking = () => {
UofC Baja Interview Form
Please kindly fill out the form and our team will contact you.
+
+ 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.
+
+
>
);
};
diff --git a/src/Interivew Booking/InterviewForm.jsx b/src/Interivew Booking/InterviewForm.jsx
index 4c19ede..ffb17ca 100644
--- a/src/Interivew Booking/InterviewForm.jsx
+++ b/src/Interivew Booking/InterviewForm.jsx
@@ -1,46 +1,109 @@
-import { useEffect, useState } from "react";
+import { useEffect, useState, useRef } from "react";
+import TimeSlotSelector from "./TimeSlotSelector"; // 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);
- useEffect(() => {
- test();
- }, []);
+ 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());
- await console.log("Form Data:", formObject);
- setIsButtonDisabled(false);
- };
- const test = async () => {
+ 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/getAppointments",
- "https://randomfox.ca/floof",
- { method: "GET" }
+ "https://bajabackend.bajacloud.duckdns.org/SelectInterview",
+ {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ body: JSON.stringify(formObject),
+ }
);
- let json = await res.json();
- await console.log(json);
+
+ console.log(res.text);
+
+ // dialogRef.current.showModal();
+ setIsButtonDisabled(false);
};
return (
<>
- test
+ {/* 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.
+
+
>
);
};
diff --git a/src/Interivew Booking/TimeSlotSelector.jsx b/src/Interivew Booking/TimeSlotSelector.jsx
new file mode 100644
index 0000000..3162e46
--- /dev/null
+++ b/src/Interivew Booking/TimeSlotSelector.jsx
@@ -0,0 +1,74 @@
+import React, { useState, useEffect } from "react";
+
+const TimeSlotSelector = ({ onTimeSlotSelect }) => {
+ const [selectedDate, setSelectedDate] = useState();
+ const [timeSlots, setTimeSlots] = useState([]);
+ const [interviewDates, setInterviewDates] = useState([]);
+ useEffect(() => {
+ getInterviewDates();
+ }, []);
+ useEffect(() => {
+ if (selectedDate) {
+ const availableSlots =
+ interviewDates.interviewDates?.[selectedDate] || {};
+ setTimeSlots(Object.keys(availableSlots));
+ }
+ }, [selectedDate]);
+ /**
+ * @param {null} null - Takes in nothing
+ * @returns {null} null - Returns in nothing
+ * @description Hooking upto backend
+ * @author Ahmad
+ */
+ const getInterviewDates = async () => {
+ const res = await fetch(
+ "https://bajabackend.bajacloud.duckdns.org/getAppointments",
+ { method: "GET" }
+ );
+ let json = await res.json();
+ await setInterviewDates(json["body"]);
+ };
+
+ const handleDateChange = (e) => {
+ let date = e.target.value;
+ setSelectedDate(date); // Capture the selected date in YYYY-MM-DD format
+ onTimeSlotSelect({ date, startTime: null });
+ };
+
+ const handleTimeSlotChange = (e) => {
+ let startTime = e.target.value;
+ onTimeSlotSelect((prev) => ({ ...prev, startTime }));
+ };
+
+ return (
+
+
Select a Date:
+ {/* Replace Calendar with input type="date" */}
+
+ {!selectedDate ? (
+ <>
+
Available Time Slots:
+
Please select the a date to see time slots.
+ >
+ ) : (
+ <>
+
Available Time Slots for {selectedDate}:
+ {timeSlots.length > 0 ? (
+
+ Select a time slot
+ {timeSlots.map((time, index) => (
+
+ {time}
+
+ ))}
+
+ ) : (
+
No available time slots for the selected date.
+ )}
+ >
+ )}
+
+ );
+};
+
+export default TimeSlotSelector;