Skip to content

Commit

Permalink
Cleaning comments, unused values and eslint ignores (#94)
Browse files Browse the repository at this point in the history
* lots of cleaning comments and unused values

Co-authored-by: ThatMegamind <[email protected]>
Co-authored-by: michellelin1 <[email protected]>

* fixed ps season bug

---------

Co-authored-by: ThatMegamind <[email protected]>
Co-authored-by: michellelin1 <[email protected]>
Co-authored-by: michellelin1 <[email protected]>
  • Loading branch information
4 people authored May 1, 2024
1 parent 831b37c commit a648ffb
Show file tree
Hide file tree
Showing 22 changed files with 43 additions and 146 deletions.
1 change: 0 additions & 1 deletion src/common/AuthContext.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable react/jsx-no-constructed-context-values */
import { createContext, useState, useContext } from 'react';
import PropTypes from 'prop-types';

Expand Down
1 change: 0 additions & 1 deletion src/components/AddDayForm/AddDayForm.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable react/jsx-props-no-spreading */
import {
Box,
FormLabel,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable react/jsx-props-no-spreading */
import {
Box,
FormLabel,
Expand Down Expand Up @@ -89,14 +88,10 @@ const AddEventToPublishedScheduleForm = ({ closeForm }) => {
setValue('startTime', eventData.startTime);
setValue('endTime', eventData.endTime);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [eventData]);

useEffect(() => {
if (formData.startTime && formData.endTime && formData.startTime < formData.endTime && formData.startTime >= "07:00" && formData.endTime <= "23:00") {
// if (isEdit) {
// // setPlannedEvents([...plannedEvents.filter(e => e.id != -1 && e.id != eventData.id)]);
// }
const newPlannedEvent = new PlannedEvent(
-1,
formData.title,
Expand All @@ -109,7 +104,6 @@ const AddEventToPublishedScheduleForm = ({ closeForm }) => {
} else {
setPlannedEvents(plannedEvents.filter(e => e.id != -1));
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [formData])

const toast = useToast();
Expand All @@ -125,8 +119,6 @@ const AddEventToPublishedScheduleForm = ({ closeForm }) => {

const handleCancel = () => {
if (isEdit) {
// let reAddedEvent = plannedEvents.filter(e => e.id == -1)[0];
// reAddedEvent.id = eventData.id;
const reAddedEvent = new PlannedEvent(
eventData.id,
eventData.title,
Expand Down Expand Up @@ -179,16 +171,12 @@ const AddEventToPublishedScheduleForm = ({ closeForm }) => {

const submitData = async (data) => {
try {
// eslint-disable-next-line no-unused-vars
const { title, host, description, tentative, startTime, endTime } = data;
const { title, host, description, startTime, endTime } = data;
const season = filterValues.season;
const eventType = filterValues.eventType;
const year = filterValues.year;
const subject = filterValues.subject;
console.log('submmitted data', data, season, eventType, year, subject);

toast.closeAll();

const catalogDataChanged = currentCatalogDataHasChanged(eventData, {
title,
host,
Expand Down
1 change: 0 additions & 1 deletion src/components/Authentication/EmailAction.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// import React from 'react';
import { useLocation, Navigate } from 'react-router-dom';
import PropTypes from 'prop-types';
import CreateNewPassword from './CreateNewPassword';
Expand Down
2 changes: 0 additions & 2 deletions src/components/Authentication/Login.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ import { useState } from 'react';
import { instanceOf } from 'prop-types';
import { Cookies, withCookies } from '../../utils/cookie_utils';
import { logInWithEmailAndPassword, useNavigate } from '../../utils/auth_utils';
// import { logInWithEmailAndPassword , signInWithGoogle, useNavigate } from '../utils/auth_utils';
import { Box, Heading, Text, FormControl, Input, Button, Center, Link, Alert, AlertDescription } from '@chakra-ui/react';
// import styles from

const Login = ({ cookies }) => {
const navigate = useNavigate();
Expand Down
1 change: 0 additions & 1 deletion src/components/Authentication/Logout.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ const Logout = ({ cookies }) => {

return (
<div>
{/* <h2 style={{ color: 'white' }}>Logout</h2> */}
{errorMessage && <p>{errorMessage}</p>}
<button type="submit" style={{ color: 'white' }} onClick={handleLogout}>
Log out
Expand Down
21 changes: 1 addition & 20 deletions src/components/Catalog/CatalogTable.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Container, Badge, IconButton, Table, Thead, Tr, Th, Td, Tbody, Text } from '@chakra-ui/react';
import { /*EditIcon,*/ DeleteIcon } from '@chakra-ui/icons'; // add 'EditIcon' to reinstate edit button.
import { DeleteIcon } from '@chakra-ui/icons'; // add 'EditIcon' to reinstate edit button.
import { IoIosAddCircleOutline } from "react-icons/io";
import s from './Catalog.module.css';
import PropTypes from 'prop-types';
Expand Down Expand Up @@ -98,25 +98,6 @@ const CatalogTable = ({ tableData, handleActionClick, onDayPlanner, setCurrEvent
</Td>
{ !onDayPlanner ?
<Td>
{/* <IconButton
color="gray.400"
backgroundColor="transparent"
p="0.5rem"
h="fit-content"
w="fit-content"
icon={<EditIcon />}
onClick={() =>
handleEditForm({
id,
title,
host,
year,
eventType,
subject,
description,
})
}
/> */}
<IconButton
color="gray.400"
backgroundColor="transparent"
Expand Down
6 changes: 0 additions & 6 deletions src/components/Catalog/CreateEventForm/CreateEventForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ const CreateEventForm = ({ eventData, setDataShouldRevalidate, closeModal }) =>

// make post request to catalog backend route
try {
// let response;
// let id;
if (eventData) {
await NPOBackend.put(`/catalog/${eventData.id}`, {
host: host,
Expand All @@ -69,7 +67,6 @@ const CreateEventForm = ({ eventData, setDataShouldRevalidate, closeModal }) =>
description: description,
year: year,
});
// id = response.data[0].id;
} else {
await NPOBackend.post(`/catalog`, {
host: host,
Expand All @@ -80,7 +77,6 @@ const CreateEventForm = ({ eventData, setDataShouldRevalidate, closeModal }) =>
description: description,
year: year,
});
// id = response.data.id;
}
reset();
toast({
Expand Down Expand Up @@ -117,7 +113,6 @@ const CreateEventForm = ({ eventData, setDataShouldRevalidate, closeModal }) =>

return (
<Box width="80%" m="auto" mt="20px">
{/* <Heading size="lg" color="gray.600" mb="20px">Event Form</Heading> */}
<Box p="20px" border="1px" borderRadius="10px" borderColor="gray.200">
<form onSubmit={handleSubmit(data => submitData(data))}>
<Heading size="md" color="gray.600">Event Information</Heading>
Expand Down Expand Up @@ -246,7 +241,6 @@ CreateEventForm.propTypes = {
setDataShouldRevalidate: PropTypes.func,
closeModal: PropTypes.func,
};
// dayId: PropTypes.number,


CreateEventForm.defaultProps = {
Expand Down
2 changes: 0 additions & 2 deletions src/components/Dropdown/Dropdown.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,11 @@ const Dropdown = ({ options, filter, selected, defaults, badgeColor, width }) =>
}, [selected]);

useEffect(() => {
// console.log('inital default');
if (defaults && defaults[0] !== '')
filter.setValue(defaults);
}, []);

useEffect(() => {
// console.log('update default', defaults);
if (defaults && defaults[0] !== '')
filter.setValue(defaults);
if (!defaults) {
Expand Down
3 changes: 0 additions & 3 deletions src/components/EmailTemplates/EmailSending.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
// eslint-disable-next-line no-unused-vars
import React, { useState } from 'react';
import axios from 'axios';
import { renderEmail } from 'react-html-email';
//import { sendEmail } from '../../utils/utils';

const AISSBackend = axios.create({
baseURL: import.meta.env.VITE_BACKEND_HOST,
Expand Down
1 change: 0 additions & 1 deletion src/components/EmailTemplates/emailtemplate.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
//import React from 'react';
import { Email, Item, Span } from 'react-html-email';

const emailTemplate = ({newEmail}) => (
Expand Down
5 changes: 3 additions & 2 deletions src/components/Events/PublishedScheduleTable.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@ import AUTH_ROLES from '../../utils/auth_config.js';
const { ADMIN_ROLE } = AUTH_ROLES.AUTH_ROLES;


const PublishedScheduleTable = ({ season, allSeasons }) => {
const PublishedScheduleTable = ({ season, allSeasons, dataShouldRevalidate, setShouldDataRevalidate}) => {
const {currentUser} = useAuthContext();
const [eventsInDay, setEventsInDay] = useState([]);
const seasonType = season.split(' ')[0];
const seasonYear = season.split(' ')[1];
const [dataShouldRevalidate, setShouldDataRevalidate] = useState(false);
const { isOpen: isOpenDay, onOpen: onOpenDay, onClose: onCloseDay } = useDisclosure();
const { isOpen: isOpenStats, onOpen: onOpenStats, onClose: onCloseStats } = useDisclosure();

Expand Down Expand Up @@ -140,6 +139,8 @@ const PublishedScheduleTable = ({ season, allSeasons }) => {
PublishedScheduleTable.propTypes = {
season: PropTypes.string.isRequired,
allSeasons: PropTypes.array.isRequired,
dataShouldRevalidate: PropTypes.bool.isRequired,
setShouldDataRevalidate: PropTypes.func.isRequired,
};

export default PublishedScheduleTable;
27 changes: 1 addition & 26 deletions src/components/Notifications/AccountNotification.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import {
GridItem,
Text,
Link,
// useToast,
} from '@chakra-ui/react';

const AccountNotification = ({
Expand All @@ -27,7 +26,7 @@ const AccountNotification = ({
declineAfterTimer,
setDeclineAfterTimer,
}) => {
// const toast = useToast();

const [accounts, setAccounts] = useState(notificationBlock.getNotificationData().accounts);
const [disableChildrenButtons, setDisableChildrenButtons] = useState(false);

Expand Down Expand Up @@ -75,36 +74,12 @@ const AccountNotification = ({
useEffect(() => {
if (approveAfterTimer && removeNotificationBlock) {
removeEntry(notificationBlock.key);
// toast({
// title: `Approved.`,
// status: 'success',
// duration: 9000,
// isClosable: true,
// });
} else if (declineAfterTimer && removeNotificationBlock) {
removeEntry(notificationBlock.key);
// toast({
// title: `Declined.`,
// status: 'info',
// duration: 9000,
// isClosable: true,
// });
} else if (approveAfterTimer) {
setAccounts(accounts => accounts.filter(account => account.id !== idToRemove));
// toast({
// title: `Approved.`,
// status: 'success',
// duration: 9000,
// isClosable: true,
// });
} else if (declineAfterTimer) {
setAccounts(accounts => accounts.filter(account => account.id !== idToRemove));
// toast({
// title: `Declined.`,
// status: 'info',
// duration: 9000,
// isClosable: true,
// });
}
}, [approveAfterTimer, declineAfterTimer, removeNotificationBlock]);

Expand Down
7 changes: 6 additions & 1 deletion src/components/Planner/PlannerContext.jsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { createContext, useState } from 'react';
import PropTypes from 'prop-types';

const PlannerContext = createContext(undefined);

/*
* Use context provider because multiply nested components will read/update planner state
*/

// eslint-disable-next-line react/prop-types
function PlannerContextProvider({ children, dayId }) {
const [plannedEvents, setPlannedEvents] = useState([]); // PlannedEvent[]
const [isEdit, setIsEdit] = useState(false);
Expand All @@ -26,4 +26,9 @@ function PlannerContextProvider({ children, dayId }) {
);
}

PlannerContextProvider.propTypes = {
children: PropTypes.array,
dayId: PropTypes.number
}

export { PlannerContextProvider, PlannerContext };
6 changes: 0 additions & 6 deletions src/components/Planner/PlannerEvents/PlannerEvents.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import EmptyDayModal from '../EmptyDayModal';

const PlannerEvents = ({ onClose }) => {
const [isAddingEvent, setIsAddingEvent] = useState(false);
// const [existingEventData, setExistingEventData] = useState({});
const [dateHeader, setDateHeader] = useState('');
const [dayData, setDayData] = useState({});
const { isOpen: isOpenDay, onOpen: onOpenDay, onClose: onCloseDay } = useDisclosure();
Expand All @@ -31,12 +30,10 @@ const PlannerEvents = ({ onClose }) => {

const getDayData = async () => {
try {
// console.log('getDayData');
const response = await NPOBackend.get(`/day/${dayId}`);
const responseData = response.data[0];
const [datePart] = responseData.eventDate.split('T');
const dateObj = getUTCDate(responseData.eventDate);
// console.log(dateObj);
setDateHeader(dateObj.toLocaleDateString({ year: 'numeric', month: 'short', day: '2-digit' }));
setDayData({id: responseData.id, eventDate: datePart, location: responseData.location, details: responseData.notes});
} catch (error) {
Expand All @@ -45,13 +42,11 @@ const PlannerEvents = ({ onClose }) => {
};

useEffect(() => {
// console.log('fetch data first time?')
getDayData();
}, [dayId]);

useEffect(() => {
if (dataShouldRevalidate) {
// console.log('reset data');
getDayData();
setShouldDataRevalidate(false);
}
Expand Down Expand Up @@ -81,7 +76,6 @@ const PlannerEvents = ({ onClose }) => {

return (
<div id={s['planner-events-container']} className={s['gray-scrollbar-vertical']}>
{/* {overlayIsVisible && <AddEventOverlay eventData={existingEventData} setOverlayIsVisible={openPSEventForm}/>} */}
<div id={s['planner-browse']}>
{(isAddingEvent || isEdit) &&
<AddEventToPublishedScheduleForm closeForm={togglePSForm} />
Expand Down
7 changes: 0 additions & 7 deletions src/components/Planner/PlannerTimeline/PlannerTimeline.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ const PlannerTimeline = () => {
}

const startEditAndSetCurrEventId = (id) => {
// console.log('selected', id);
if (isEdit) {
// add back the original state of the currently edited event
const reAddedEvent = new PlannedEvent(
Expand All @@ -48,14 +47,11 @@ const PlannerTimeline = () => {
}

useEffect(() => {
// console.log('updating timeline!');
updateTimeline();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

const updateTimeline = async () => {
const psEvents = await fetchDayInfo(dayId);
// console.log(psEvents);
if (psEvents && psEvents[0].id) {
setPlannedEvents(psEvents.map((data) => new PlannedEvent(
data.id,
Expand Down Expand Up @@ -91,14 +87,11 @@ const PlannerTimeline = () => {
);
}, []);

// console.log(plannedEvents);

return (
<div id={s['planner-timeline-container']}>
<div className={`${s['timeline-grid']} ${s['gray-scrollbar-vertical']}`}>
{timelineBlocks}
{plannedEvents.map(plannedEvent => {
// console.log(plannedEvent);
const { id, name, startTime, endTime, hostName, isTentative } = plannedEvent;
const gridStyles = plannedEvent.calculateGridStyles(addedEvents);
addedEvents.push({startTime, endTime});
Expand Down
3 changes: 0 additions & 3 deletions src/components/Planner/RemoveTimelineEventModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ const RemoveTimelineEventModal = ({ isOpen, onClose, deleteItemId, closeForm })

const handleConfirmDelete = async idToDelete => {
try {
console.log('id to delete:', idToDelete);
toast.closeAll();
await NPOBackend.delete(`/published-schedule/${idToDelete}`);
setPlannedEvents(plannedEvents.filter(e => (e.id != -1 && e.id != idToDelete)));
Expand All @@ -48,8 +47,6 @@ const RemoveTimelineEventModal = ({ isOpen, onClose, deleteItemId, closeForm })
}
};

// console.log(deleteItemId);

return (
<Modal isOpen={isOpen} onClose={onClose} isCentered>
<ModalOverlay />
Expand Down
Loading

0 comments on commit a648ffb

Please sign in to comment.