diff --git a/src/CalendarPage.tsx b/src/CalendarPage.tsx index 4a211e8..5fc0a2b 100644 --- a/src/CalendarPage.tsx +++ b/src/CalendarPage.tsx @@ -33,24 +33,20 @@ function CalendarPage() { const [scheduledSessions, setScheduledSessions] = useState([]); async function selectDate(value: any) { - await getScheduledSessions(value); + await getScheduledSessions("653675f420af0dadee9003ec", value); setDate(value); setStep((prev) => prev + 1); } - async function getScheduledSessions(value: Date) { - const username = params.username; - + async function getScheduledSessions(buildId: string, date: Date) { const result: any[] = await ky .get( - `${ - import.meta.env.VITE_COORD_URL - }/scheduled_sessions/${username}?date=${value.toISOString()}` + `https://crm.stream.graff.tech/api/scheduled_sessions/${buildId}?date=${date.toISOString()}` ) .json(); - console.log(scheduledSessions); + console.log(result); setScheduledSessions(result); } diff --git a/src/components/Calendar.tsx b/src/components/Calendar.tsx index e2cf704..aab7293 100644 --- a/src/components/Calendar.tsx +++ b/src/components/Calendar.tsx @@ -1,12 +1,18 @@ +/* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable react-hooks/exhaustive-deps */ import { add, + differenceInDays, eachDayOfInterval, endOfMonth, format, getDay, + isAfter, + isBefore, isEqual, + isWithinInterval, parse, + parseISO, startOfToday, } from "date-fns"; import { enUS, ru } from "date-fns/locale"; @@ -17,6 +23,7 @@ import { Trans } from "react-i18next"; import i18n from "../i18n"; interface CalendarProps { + schedules: any[]; handleSelect: (day: Date) => void; } @@ -24,7 +31,7 @@ function classNames(...classes: (string | boolean)[]) { return classes.filter(Boolean).join(" "); } -function Calendar({ handleSelect }: CalendarProps) { +function Calendar({ schedules, handleSelect }: CalendarProps) { const today = startOfToday(); const [selectedDay, setSelectedDay] = useState(null); const [currentMonth, setCurrentMonth] = useState(format(today, "MMM-yyyy")); @@ -46,9 +53,11 @@ function Calendar({ handleSelect }: CalendarProps) { } useEffect(() => { - if (selectedDay !== null) { - handleSelect(selectedDay); - } + console.log(schedules); + + if (!selectedDay) return; + + handleSelect(selectedDay); }, [selectedDay]); return ( @@ -89,7 +98,16 @@ function Calendar({ handleSelect }: CalendarProps) { >