diff --git a/frontend/app/schedule-meets/components/Calendar.jsx b/frontend/app/schedule-meets/components/Calendar.jsx index 86a11c65..53c9c727 100644 --- a/frontend/app/schedule-meets/components/Calendar.jsx +++ b/frontend/app/schedule-meets/components/Calendar.jsx @@ -5,7 +5,6 @@ import dayjs from "dayjs"; import NextIcon from "@/app/svg-icons/NextIcon"; import PrevIcon from "@/app/svg-icons/PrevIcon"; import { months, generateDate } from "@/app/utils/calendar"; -import { getMeeting } from "@/app/hooks/MeetApiCalls"; import axios from "axios"; @@ -19,21 +18,65 @@ const Calendar = () => { const [today, setToday] = useState(currentDate); const [selectDate, setSelectDate] = useState(currentDate); const user = useAppStore(state => state.user) + const [meetingsData, setMeetingsData] = useState([]) + const [userMeets, setUserMeets] = useState([]) + const [userPerMonthMeets, setUserPerMonthMeets] = useState([]) + const [showDayMeets, setShowDayMeets] = useState([false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false]) useEffect(() => { const getMeets = async () => { - console.log(user.ethAddress) + // console.log(user.ethAddress) const { data } = await axios.patch('/api/meetings', { "address": user.ethAddress }) console.log(data); + setUserMeets(data.data) + const dates = [] + for (let i = 0; i < 12; i++) { + dates.push([]) + } + const meetsMetaData = {} + // console.log(userMeets) + // const meetShow = [] + const processUserMeets = () => { + data.data.forEach((meet) => { + const strDate = meet.meetConfig.date; + const date = new Date(strDate); + if (!date || date === undefined || date === null) { + return; + } + const month = date.getMonth(); + const day = date.getDate(); + const hash = day + "," + month; + if (!meetsMetaData[hash]) { + meetsMetaData[hash] = []; + } + meetsMetaData[hash].push(meet); + dates[month].push(day); + }); + } + processUserMeets(); + setUserPerMonthMeets(dates) + setMeetingsData(meetsMetaData) + // console.log(meetsMetaData) + // setShowDayMeets(meetShow) } - getMeets(); + // console.log(meetingsData) }, []) + const getMeetByDate = (date) => { + console.log(date) + const strDate = new Date(date); + console.log(strDate.toDateString()) + const meet = meetingsData[strDate]; + if (!meet) { + return null; + } + return meet.title; + } return (