diff --git a/src/components/Planner/PlannerEvents/PlannerEvents.jsx b/src/components/Planner/PlannerEvents/PlannerEvents.jsx index 6b89866..45b4c4d 100644 --- a/src/components/Planner/PlannerEvents/PlannerEvents.jsx +++ b/src/components/Planner/PlannerEvents/PlannerEvents.jsx @@ -1,58 +1,22 @@ -import { useState, useEffect, useContext } from 'react'; +import { useState, useContext } from 'react'; import s from '../PlannerLayout.module.css'; -import { Text, Button, Heading, Box, IconButton, HStack, Flex, useDisclosure } from '@chakra-ui/react'; +import { Text, Button, Heading, Box, Flex, useDisclosure } from '@chakra-ui/react'; import { AddIcon } from '@chakra-ui/icons'; -import { FiEdit2 } from "react-icons/fi"; import Catalog from '../../../pages/Catalog/Catalog'; import PropTypes from 'prop-types'; import { PlannerContext } from '../PlannerContext'; -import { NPOBackend } from '../../../utils/auth_utils'; -import AddDayModal from '../../../pages/PublishedSchedule/AddDayModal'; import AddEventToPublishedScheduleForm from '../../AddEventToPublishedScheduleForm/AddEventToPublishedScheduleForm'; import EmptyDayModal from '../EmptyDayModal'; const PlannerEvents = ({ onClose }) => { const [isAddingEvent, setIsAddingEvent] = useState(false); - const [dateHeader, setDateHeader] = useState(''); - const [dayData, setDayData] = useState({}); - const { isOpen: isOpenDay, onOpen: onOpenDay, onClose: onCloseDay } = useDisclosure(); const { isOpen: isOpenEmptyDay, onOpen: onOpenEmptyDay, onClose: onCloseEmptyDay } = useDisclosure(); - const { plannedEventsContext, dayId, editContext, currEventContext } = useContext(PlannerContext); + const { plannedEventsContext, editContext, currEventContext } = useContext(PlannerContext); const [isEdit, setIsEdit] = editContext; const setCurrEvent = currEventContext[1]; // fix? - const [dataShouldRevalidate, setShouldDataRevalidate] = useState(false); const plannedEvents = plannedEventsContext[0]; - const getUTCDate = (eventDate) => { - const utcDate = new Date(eventDate); - return new Date(utcDate.getTime() + utcDate.getTimezoneOffset() * 60000); - } - - const getDayData = async () => { - try { - const response = await NPOBackend.get(`/day/${dayId}`); - const responseData = response.data[0]; - const [datePart] = responseData.eventDate.split('T'); - const dateObj = getUTCDate(responseData.eventDate); - setDateHeader(dateObj.toLocaleDateString("en-US", { year: "numeric", month: "short", day: "numeric", })); - setDayData({id: responseData.id, eventDate: datePart, location: responseData.location, details: responseData.notes}); - } catch (error) { - console.error(error); - } - }; - - useEffect(() => { - getDayData(); - }, [dayId]); - - useEffect(() => { - if (dataShouldRevalidate) { - getDayData(); - setShouldDataRevalidate(false); - } - }, [dataShouldRevalidate]) - const handleCreateNewEvent = () => { setCurrEvent({}); togglePSForm(); @@ -83,19 +47,6 @@ const PlannerEvents = ({ onClose }) => { }