diff --git a/scheduler_app/app/(routes)/[business]/_components/MeetingEventSelection.js b/scheduler_app/app/(routes)/[business]/_components/MeetingEventSelection.js index f98d6fa..5369938 100644 --- a/scheduler_app/app/(routes)/[business]/_components/MeetingEventSelection.js +++ b/scheduler_app/app/(routes)/[business]/_components/MeetingEventSelection.js @@ -1,12 +1,15 @@ import { GoClock } from "react-icons/go"; -import { PiMapPinLight, PiInfo } from "react-icons/pi"; -import { Calendar } from "@/components/ui/calendar" +import { PiMapPinLight, PiInfo, PiCalendarCheck } from "react-icons/pi"; import React, { useEffect, useState } from 'react' import Link from "next/link"; +import { format } from "date-fns"; +import TimeDateSelection from "./TimeDateSelection"; const MeetingEventSelection = ({meetingEventInfo, businessInfo}) => { const [date, setDate] = useState(new Date()); const [timeSlots, setTimeSlots] = useState(); + const [unavialableTime, setUnavialableTime] = useState(false) + const [selectedTime, setSelectedTime] = useState(); useEffect(() => { meetingEventInfo?.timeDuration && createTimeSlot(meetingEventInfo?.timeDuration) @@ -26,32 +29,33 @@ const MeetingEventSelection = ({meetingEventInfo, businessInfo}) => { }); setTimeSlots(slots); } + + const handleDatechange = (date) => { + setDate(date); + const day = format(date, 'EEEE') + if(businessInfo?.availableDays?.[day]){ + setUnavialableTime(true) + } else { + setUnavialableTime(false) + } + } return ( -
+

Schedule.Me

{businessInfo?.businessName}

{meetingEventInfo?.eventName?meetingEventInfo?.eventName:'Meeting/Event Name'}

-

{meetingEventInfo?.timeDuration} minutes

+

{format(date, 'PPP')}

+

{meetingEventInfo?.timeDuration} minutes {selectedTime && ({selectedTime})}

{meetingEventInfo?.locationMeeting}

{meetingEventInfo?.urlMeeting}
-
-
-

Select your meeting date & time

- date < new Date()} mode="single" selected={date} onSelect={setDate} className="rounded-md border mt-5"/> -
-
- {timeSlots?.map((time, index) => ( - - ))} -
-
+
) diff --git a/scheduler_app/app/(routes)/[business]/_components/TimeDateSelection.js b/scheduler_app/app/(routes)/[business]/_components/TimeDateSelection.js new file mode 100644 index 0000000..e097a6f --- /dev/null +++ b/scheduler_app/app/(routes)/[business]/_components/TimeDateSelection.js @@ -0,0 +1,20 @@ +import { Calendar } from "@/components/ui/calendar" +import React from 'react' + +const TimeDateSelection = ({date, handleDatechange, timeSlots, setSelectedTime, unavialableTime}) => { + return ( +
+
+

Select your meeting date & time

+ date < new Date()} mode="single" selected={date} onSelect={(d) => handleDatechange(d)} className="rounded-md border mt-5"/> +
+
+ {timeSlots?.map((time, index) => ( + + ))} +
+
+ ) +} + +export default TimeDateSelection \ No newline at end of file