Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AddEventToPublishSchedule + Edit/Delete Days + Edit/Delete PS Events #61

Merged
merged 61 commits into from
Mar 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
ab449fa
added two modals and started search and filter
Philip-Jian Feb 10, 2024
d64b9ee
progress on add day modal and day planner modal.
Philip-Jian Feb 13, 2024
bd73c67
added create event form inside day planner
Philip-Jian Feb 14, 2024
da476ee
Put the catalog component in PlannerEvents component + fixed useState…
SubinQKim Feb 16, 2024
8a1e6cd
updated branch from dev
Philip-Jian Mar 2, 2024
c18f078
updated branch from dev
Philip-Jian Mar 2, 2024
5ae38c9
added Add Day Modal back to Publish Schedule and connected to backend
Philip-Jian Mar 3, 2024
ad7a6b9
AddDayContext file so no need for multiple prop passes for addDayForm…
SubinQKim Mar 4, 2024
89e1244
Post request to /published-schedule inside CreateEventForm
SubinQKim Mar 4, 2024
5768f29
AddEventToPublishedSchedule form used in PS modal to create new ps an…
SubinQKim Mar 5, 2024
49e7616
fixed addEventOverlay rendering the datePart and location on event form
SubinQKim Mar 5, 2024
bb0c798
AddEventToPublishScheduleForm creates new events in the PS and catalo…
SubinQKim Mar 5, 2024
b32308b
merged in dev
michellelin1 Mar 8, 2024
328affc
Planner Timeline changes
SubinQKim Mar 15, 2024
ecd97ca
merged in dev
michellelin1 Mar 23, 2024
6ed632e
light styling
michellelin1 Mar 24, 2024
1571c30
Merge branch 'dev' into 34-add-event-to-published-schedule-full-flow
ThatMegamind Mar 24, 2024
406731f
semi styled published schedule form
michellelin1 Mar 24, 2024
2cd2d6b
matched ps form styling
michellelin1 Mar 25, 2024
04ac1e2
updated styling, events display on timeline
ThatMegamind Mar 25, 2024
358de52
can add existing catalog event to ps
ThatMegamind Mar 25, 2024
f04691d
sorting events on schedule by startTime
ThatMegamind Mar 25, 2024
278488f
fixing bugs + re-implementing catalog add
ThatMegamind Mar 25, 2024
942f0eb
(rest of changes)
ThatMegamind Mar 25, 2024
dcc185c
replace location with description for individual ps events
ThatMegamind Mar 25, 2024
bd74ebf
fixed bugs and added styling to timeline
ThatMegamind Mar 25, 2024
8dad37d
change to use planner context
michellelin1 Mar 25, 2024
4a23028
merge conflict fixes
ThatMegamind Mar 25, 2024
e3ec9f2
live events on timeline
michellelin1 Mar 26, 2024
bd8da7f
fixed ps table styling + removed date/location from ps form
michellelin1 Mar 26, 2024
5351512
migrated day context to planner context
michellelin1 Mar 26, 2024
11222db
missed a file
michellelin1 Mar 26, 2024
28075d9
edit existing day
michellelin1 Mar 26, 2024
d716182
delete day if no events + more styling
michellelin1 Mar 26, 2024
3b0a5a5
handled 2 overlapping events
michellelin1 Mar 26, 2024
d21615a
close ps form after submission + prevent multiple fetches of catalog
michellelin1 Mar 27, 2024
d23d4b7
delete day + (bad) data revalidation
michellelin1 Mar 27, 2024
4bc923e
edit day from day planner implemented
ThatMegamind Mar 27, 2024
c7762eb
edit day, edit events (mostly), plus bug fixes
ThatMegamind Mar 27, 2024
9feebfd
updated navbar, dropdown, catalog, 'finish day' + fixed ps student view
michellelin1 Mar 28, 2024
c0328ce
editing event reflects correctly on timeline, edit/delete appear on h…
ThatMegamind Mar 28, 2024
f487a0f
Merge branch '34-add-event-to-published-schedule-full-flow' of https:…
ThatMegamind Mar 28, 2024
fd377ee
edit buttons updated, styling of delete event modal still has darknes…
ThatMegamind Mar 28, 2024
e19b285
fixed delete event + styled edit/delete buttons
michellelin1 Mar 28, 2024
bf42889
fixed host bug
michellelin1 Mar 28, 2024
45e09d7
minor visual touch-ups, fixed timeline height issue
ThatMegamind Mar 28, 2024
efff1e6
Merge branch '34-add-event-to-published-schedule-full-flow' of https:…
ThatMegamind Mar 28, 2024
bacee9a
alt timeline size fix
michellelin1 Mar 28, 2024
39e6263
fixed season cutoff
michellelin1 Mar 28, 2024
92aff2d
removed unnessary addDayModal
michellelin1 Mar 28, 2024
3d4a38b
made catalog scroll bar nicer
michellelin1 Mar 28, 2024
1376329
fixed small catalog bug
michellelin1 Mar 28, 2024
08112cb
fixed bugs, removed second variable tracking edit state, added some t…
ThatMegamind Mar 28, 2024
72e9b12
update catalog on timeline event edit
michellelin1 Mar 29, 2024
3429a38
removed unnessary console logs
michellelin1 Mar 29, 2024
9a322cd
fixed season select issue
michellelin1 Mar 29, 2024
64c5451
fixed bug of currently edited event disappearing when editing differe…
ThatMegamind Mar 29, 2024
f1d2d06
Merge branch '34-add-event-to-published-schedule-full-flow' of https:…
ThatMegamind Mar 29, 2024
d6cdb86
toast clean up
michellelin1 Mar 29, 2024
d4c8575
Merge branch '34-add-event-to-published-schedule-full-flow' of https:…
michellelin1 Mar 29, 2024
2c01db6
fixed day toast error message
michellelin1 Mar 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"plugin:react/recommended",
"plugin:prettier/recommended"
],
"parser": "@babel/eslint-parser",
"parserOptions": {
"ecmaFeatures": {
"jsx": true
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
"react-dom": "^18.2.0",
"react-hook-form": "^7.45.4",
"react-html-email": "^3.0.0",
"react-icons": "^5.0.1",
"react-router-dom": "^6.20.0",
"react-script": "^2.0.5",
"react-icons": "^5.0.1",
Expand Down
10 changes: 1 addition & 9 deletions src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import PublishedSchedule from './pages/PublishedSchedule/PublishedSchedule';
import Playground from './pages/Playground/Playground';
import Planner from './pages/Planner/Planner';
import Navbar from './components/Navbar/Navbar';
import NotificationSandbox from './pages/NotificationSandbox/NotificationSandbox';
import Accounts from './pages/Accounts/Accounts';
import { AuthContextProvider, useAuthContext } from './common/AuthContext';

Expand Down Expand Up @@ -56,13 +55,6 @@ const App = () => {
<Route exact path="/signUp" element={<SignUp />} />
<Route exact path="/emailAction" element={<EmailAction redirectPath="/" />} />
<Route exact path="/awaitConfirmation" element={<AwaitConfirmation redirectPath="/" />} />
<Route
exact
path="/notification-sandbox"
element={
<NotificationSandbox />
}
/>
<Route
exact
path="/catalog"
Expand Down Expand Up @@ -99,7 +91,7 @@ const App = () => {
redirectPath="/login"
roles={[ADMIN_ROLE]}
/>
} />
} />
</Route>
</Routes>
</Router>
Expand Down
153 changes: 153 additions & 0 deletions src/components/AddDayForm/AddDayForm.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
/* eslint-disable react/jsx-props-no-spreading */
import {
Box,
FormLabel,
Input,
FormControl,
FormErrorMessage,
Button,
Textarea,
useToast,
Heading,
Flex
} from '@chakra-ui/react';
import { PropTypes } from 'prop-types';
import { yupResolver } from '@hookform/resolvers/yup';
import { useForm } from 'react-hook-form';
import * as yup from 'yup';
import { NPOBackend } from '../../utils/auth_utils';

const schema = yup.object({
date: yup.date().nullable().transform((curr, orig) => orig === '' ? null : curr).required('Date required'),
location: yup.string().required('Location required').max(50, 'Location exceeds 50 character limit'),
details: yup
.string()
.max(50, 'Details exceeds 50 character limit'),
});

const AddDayForm = ({ onClose, onOpen, setDayId, dayData, setShouldDataRevalidate }) => {
const toast = useToast();
const {
handleSubmit,
register,
formState: { errors },
} = useForm({
resolver: yupResolver(schema),
});

const submitData = async data => {
const { date, details, location } = data;
toast.closeAll();
try {
const payload = {
eventDate: date,
location: location,
notes: details,
};

let response;
if (dayData) {
response = await NPOBackend.put(`/day/${dayData.id}`, payload);
setShouldDataRevalidate(true);
} else {
response = await NPOBackend.post('/day/', payload);
}

if (response.status === 200 || (response.status == 201 && response.data.status === 'Success')) {
const id = dayData ? dayData.id : response.data['id'];
setDayId(id);
onOpen(id);
} else if (response.status == 201 && response.data.status === 'Failed') {
toast({
title: 'This date already exists in the schedule.',
description: `${date.toLocaleDateString()}`,
status: 'error',
variant: 'subtle',
position: 'top-right',
containerStyle: {
mt: '6rem',
},
duration: 3000,
isClosable: true,
});
}

} catch (error) {
console.log(error);
}
}

return (
<Box p="20px">
<Heading size="lg" textAlign="center" mb="8px" color="#2D3748">{!dayData ? 'Add New Day' : 'Edit Day Details'}</Heading>
<form onSubmit={handleSubmit(data => submitData(data))}>
<Box mb="4vh">
{/* DATE */}
<Box mb="15px">
<FormControl isInvalid={errors && errors.date} >
<FormLabel fontWeight="bold" color="gray.600">Date *</FormLabel>
<Input
size="md"
type="date"
{...register('date')}
defaultValue={dayData && dayData.eventDate}
/>
<FormErrorMessage>{errors.date && errors.date.message}</FormErrorMessage>
</FormControl>
</Box>

{/* LOCATION */}
<Box mb="15px">
<FormControl isInvalid={errors && errors.location} >
<FormLabel fontWeight="bold" color="gray.600">Location *</FormLabel>
<Input placeholder='Location' {...register('location')} defaultValue={dayData && dayData.location}/>
<FormErrorMessage>{errors.location && errors.location.message}</FormErrorMessage>
</FormControl>
</Box>


{/* DETAILS */}
<Box mb="15px">
<FormControl isInvalid={errors && errors.details}>
<FormLabel fontWeight="bold" color="gray.600">Details</FormLabel>
<Textarea placeholder='Details' {...register('details')} defaultValue={dayData && dayData.details}/>
<FormErrorMessage>
{errors.details && errors.details.message}
</FormErrorMessage>
</FormControl>
</Box>
</Box>

<Flex justifyContent="space-between">
<Button width="48%" size='lg' onClick={onClose}>
Cancel
</Button>
<Button
width="48%"
type='submit'
size='lg'
bgColor="#2c93d1"
color="white"
_hover={{ bgColor: '#1b6896' }}
>
{!dayData ? '+ Add To Schedule' : 'Save Changes'}
</Button>
</Flex>
</form>
</Box>
);
};

AddDayForm.propTypes = {
onClose: PropTypes.func,
onOpen: PropTypes.func,
setDayId: PropTypes.func,
dayData: PropTypes.object,
setShouldDataRevalidate: PropTypes.func
};
AddDayForm.defaultProps = {
onClose: () => {},
onOpen: () => {},
dayData: null
};
export default AddDayForm;
Loading
Loading