From 85ff2d104d01e99e6c7729618144240fad467550 Mon Sep 17 00:00:00 2001 From: NeemZ16 <110858265+NeemZ16@users.noreply.github.com> Date: Sun, 3 Nov 2024 16:13:14 -0500 Subject: [PATCH 1/6] added all options and defaults for session based on season, 110 --- .../pages/forms/courses/automateDates.tsx | 101 ++++++++++++++++++ .../pages/forms/courses/coursesFormPage.tsx | 6 +- 2 files changed, 105 insertions(+), 2 deletions(-) create mode 100644 devU-client/src/components/pages/forms/courses/automateDates.tsx diff --git a/devU-client/src/components/pages/forms/courses/automateDates.tsx b/devU-client/src/components/pages/forms/courses/automateDates.tsx new file mode 100644 index 0000000..ab855ea --- /dev/null +++ b/devU-client/src/components/pages/forms/courses/automateDates.tsx @@ -0,0 +1,101 @@ +import React, { useState } from 'react'; + +import formStyles from './coursesFormPage.scss' + +function AutomateDates() { + const [season, setSeason] = useState(''); + const [year, setYear] = useState(''); + const [session, setSession] = useState(''); + const currentYear = new Date().getFullYear(); + + // Define the session options based on the selected season + const getSessionOptions = (season: string) => { + switch (season) { + case 'Fall': + case 'Spring': + return [ + { value: '15 week', label: '15 week' }, + { value: '7 week', label: '7 week' }, + { value: 'Custom', label: 'Custom' } + ]; + case 'Winter': + return [ + { value: '15 days', label: '15 days' }, + { value: '14 days', label: '14 days' }, + { value: '10 days', label: '10 days' }, + { value: 'Custom', label: 'Custom' } + ]; + case 'Summer': + return [ + { value: 'Summer Session I (J)', label: 'Summer Session I (J)' }, + { value: 'Summer Session II (K)', label: 'Summer Session II (K)' }, + { value: 'Summer Session III (M)', label: 'Summer Session III (M)' }, + { value: '9 Weeks (L)', label: '9 Weeks (L)' }, + { value: '10 Weeks (A)', label: '10 Weeks (A)' }, + { value: '12 Weeks (I)', label: '12 Weeks (I)' }, + { value: 'Custom', label: 'Custom' } + ]; + default: + return []; + } + }; + + // Define default values based on season + const getDefaultSession = (season: string) => { + switch (season) { + case 'Fall': + case 'Spring': + return '15 week'; + case 'Winter': + return '15 days'; + case 'Summer': + return 'Summer Session I (J)'; + default: + return ''; + } + }; + + // Handle changes to season and update session options + const handleSeasonChange = (event: React.ChangeEvent) => { + const selectedSeason = event.target.value; + setSeason(selectedSeason); + setSession(getDefaultSession(selectedSeason)); + }; + + return ( +
+ {/* Season Dropdown */} + + + + {/* Year Dropdown */} + + + + {/* Session Dropdown */} + + +
+ ); +} + +export default AutomateDates; diff --git a/devU-client/src/components/pages/forms/courses/coursesFormPage.tsx b/devU-client/src/components/pages/forms/courses/coursesFormPage.tsx index e5814ce..fc9db8c 100644 --- a/devU-client/src/components/pages/forms/courses/coursesFormPage.tsx +++ b/devU-client/src/components/pages/forms/courses/coursesFormPage.tsx @@ -10,6 +10,7 @@ import { useActionless } from 'redux/hooks' import TextField from 'components/shared/inputs/textField' import { SET_ALERT } from 'redux/types/active.types' import formStyles from './coursesFormPage.scss' +import AutomateDates from './automateDates' import { applyMessageToErrorFields, removeClassFromField } from "../../../../utils/textField.utils"; @@ -75,9 +76,10 @@ const EditCourseFormPage = () => { invalidated={!!invalidFields.get("name")} helpText={invalidFields.get("name")} /> - + helpText={invalidFields.get("semester")} /> */} +
From 810988e953c25914b69f35990b47fa5e39cba901 Mon Sep 17 00:00:00 2001 From: NeemZ16 <110858265+NeemZ16@users.noreply.github.com> Date: Tue, 5 Nov 2024 09:51:15 -0500 Subject: [PATCH 2/6] added some styling for new dropdowns --- .../pages/forms/courses/automateDates.tsx | 57 +++++++++++-------- .../pages/forms/courses/coursesFormPage.scss | 22 +++++++ .../pages/forms/courses/coursesFormPage.tsx | 4 +- 3 files changed, 56 insertions(+), 27 deletions(-) diff --git a/devU-client/src/components/pages/forms/courses/automateDates.tsx b/devU-client/src/components/pages/forms/courses/automateDates.tsx index ab855ea..792d488 100644 --- a/devU-client/src/components/pages/forms/courses/automateDates.tsx +++ b/devU-client/src/components/pages/forms/courses/automateDates.tsx @@ -65,35 +65,42 @@ function AutomateDates() { return (
{/* Season Dropdown */} - - +
+ + +
{/* Year Dropdown */} - - +
+ + +
{/* Session Dropdown */} - - +
+ + +
+
); } diff --git a/devU-client/src/components/pages/forms/courses/coursesFormPage.scss b/devU-client/src/components/pages/forms/courses/coursesFormPage.scss index 3dc2c20..bd5d3e2 100644 --- a/devU-client/src/components/pages/forms/courses/coursesFormPage.scss +++ b/devU-client/src/components/pages/forms/courses/coursesFormPage.scss @@ -70,6 +70,28 @@ input[type='date'] { border-radius: 100px; } +.semesterOptions { + display: flex; + justify-content: space-between; +} + +.fieldContainer { + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + gap: 5px; +} + +.fieldContainer>select { + // background-color: $input-field-background; + // color: $input-field-label; + // border-radius: 20px; + padding: 0.625rem 1rem; + border: none; + border-radius: 100px; +} + input[type='file']::file-selector-button { background-color: $primary; border-radius: 100px; diff --git a/devU-client/src/components/pages/forms/courses/coursesFormPage.tsx b/devU-client/src/components/pages/forms/courses/coursesFormPage.tsx index fc9db8c..5010120 100644 --- a/devU-client/src/components/pages/forms/courses/coursesFormPage.tsx +++ b/devU-client/src/components/pages/forms/courses/coursesFormPage.tsx @@ -81,11 +81,11 @@ const EditCourseFormPage = () => { helpText={invalidFields.get("semester")} /> */}
-
+
-
+
From ff6153b4a87729efd66f4233700421653ebbe102 Mon Sep 17 00:00:00 2001 From: NeemZ16 <110858265+NeemZ16@users.noreply.github.com> Date: Tue, 5 Nov 2024 11:44:14 -0500 Subject: [PATCH 3/6] date selection automated on frontend --- .../pages/forms/courses/automateDates.tsx | 278 +++++++++++++++--- .../pages/forms/courses/coursesFormPage.tsx | 12 +- 2 files changed, 250 insertions(+), 40 deletions(-) diff --git a/devU-client/src/components/pages/forms/courses/automateDates.tsx b/devU-client/src/components/pages/forms/courses/automateDates.tsx index 792d488..c81d923 100644 --- a/devU-client/src/components/pages/forms/courses/automateDates.tsx +++ b/devU-client/src/components/pages/forms/courses/automateDates.tsx @@ -1,12 +1,202 @@ -import React, { useState } from 'react'; +import React, { useState, useEffect } from 'react'; +import formStyles from './coursesFormPage.scss'; -import formStyles from './coursesFormPage.scss' +interface AutomateDatesProps { + onDatesChange: (dates: { startDate: string; endDate: string }) => void; +} -function AutomateDates() { +const AutomateDates = ({ onDatesChange }: AutomateDatesProps) => { const [season, setSeason] = useState(''); - const [year, setYear] = useState(''); + const [year, setYear] = useState(new Date().getFullYear().toString()); const [session, setSession] = useState(''); - const currentYear = new Date().getFullYear(); + const [startDate, setStartDate] = useState(''); + const [endDate, setEndDate] = useState(''); + + // Hardcoded dates for each year, season, and session + const dateMapping: { [key: string]: { [key: string]: { [key: string]: { start: string; end: string } } } } = { + 2024: { + Fall: { + '15 week': { start: '2024-09-01', end: '2024-12-15' }, + '7 week': { start: '2024-09-01', end: '2024-10-20' }, + Custom: { start: '', end: '' }, + }, + Spring: { + '15 week': { start: '2024-09-01', end: '2024-12-15' }, + '7 week': { start: '2024-09-01', end: '2024-10-20' }, + Custom: { start: '', end: '' }, + }, + Winter: { + '15 days': { start: '2024-01-02', end: '2024-01-17' }, + '14 days': { start: '2024-01-02', end: '2024-01-16' }, + Custom: { start: '', end: '' }, + }, + Summer: { + 'Summer Session I (J)': { start: '2024-06-01', end: '2024-06-30' }, + 'Summer Session II (K)': { start: '2024-07-01', end: '2024-07-31' }, + 'Summer Session III (M)': { start: '2024-08-01', end: '2024-08-30' }, + '9 Weeks (L)': { start: '2024-06-01', end: '2024-08-01' }, + '10 Weeks (A)': { start: '2024-06-01', end: '2024-08-10' }, + '12 Weeks (I)': { start: '2024-05-20', end: '2024-08-10' }, + Custom: { start: '', end: '' }, + }, + }, + 2025: { + Fall: { + '15 week': { start: '2025-09-01', end: '2025-12-15' }, + '7 week': { start: '2025-09-01', end: '2025-10-20' }, + Custom: { start: '', end: '' }, + }, + Spring: { + '15 week': { start: '2025-09-01', end: '2025-12-15' }, + '7 week': { start: '2025-09-01', end: '2025-10-20' }, + Custom: { start: '', end: '' }, + }, + Winter: { + '15 days': { start: '2025-01-02', end: '2025-01-17' }, + '14 days': { start: '2025-01-02', end: '2025-01-16' }, + Custom: { start: '', end: '' }, + }, + Summer: { + 'Summer Session I (J)': { start: '2025-06-01', end: '2025-06-30' }, + 'Summer Session II (K)': { start: '2025-07-01', end: '2025-07-31' }, + 'Summer Session III (M)': { start: '2025-08-01', end: '2025-08-30' }, + '9 Weeks (L)': { start: '2025-06-01', end: '2025-08-01' }, + '10 Weeks (A)': { start: '2025-06-01', end: '2025-08-10' }, + '12 Weeks (I)': { start: '2025-05-20', end: '2025-08-10' }, + Custom: { start: '', end: '' }, + }, + }, + 2026: { + Fall: { + '15 week': { start: '2026-09-01', end: '2026-12-15' }, + '7 week': { start: '2026-09-01', end: '2026-10-20' }, + Custom: { start: '', end: '' }, + }, + Spring: { + '15 week': { start: '2026-09-01', end: '2026-12-15' }, + '7 week': { start: '2026-09-01', end: '2026-10-20' }, + Custom: { start: '', end: '' }, + }, + Winter: { + '15 days': { start: '2026-01-02', end: '2026-01-17' }, + '14 days': { start: '2026-01-02', end: '2026-01-16' }, + Custom: { start: '', end: '' }, + }, + Summer: { + 'Summer Session I (J)': { start: '2026-06-01', end: '2026-06-30' }, + 'Summer Session II (K)': { start: '2026-07-01', end: '2026-07-31' }, + 'Summer Session III (M)': { start: '2026-08-01', end: '2026-08-30' }, + '9 Weeks (L)': { start: '2026-06-01', end: '2026-08-01' }, + '10 Weeks (A)': { start: '2026-06-01', end: '2026-08-10' }, + '12 Weeks (I)': { start: '2026-05-20', end: '2026-08-10' }, + Custom: { start: '', end: '' }, + }, + }, + 2027: { + Fall: { + '15 week': { start: '2027-09-01', end: '2027-12-15' }, + '7 week': { start: '2027-09-01', end: '2027-10-20' }, + Custom: { start: '', end: '' }, + }, + Spring: { + '15 week': { start: '2027-09-01', end: '2027-12-15' }, + '7 week': { start: '2027-09-01', end: '2027-10-20' }, + Custom: { start: '', end: '' }, + }, + Winter: { + '15 days': { start: '2027-01-02', end: '2027-01-17' }, + '14 days': { start: '2027-01-02', end: '2027-01-16' }, + Custom: { start: '', end: '' }, + }, + Summer: { + 'Summer Session I (J)': { start: '2027-06-01', end: '2027-06-30' }, + 'Summer Session II (K)': { start: '2027-07-01', end: '2027-07-31' }, + 'Summer Session III (M)': { start: '2027-08-01', end: '2027-08-30' }, + '9 Weeks (L)': { start: '2027-06-01', end: '2027-08-01' }, + '10 Weeks (A)': { start: '2027-06-01', end: '2027-08-10' }, + '12 Weeks (I)': { start: '2027-05-20', end: '2027-08-10' }, + Custom: { start: '', end: '' }, + }, + }, + 2028: { + Fall: { + '15 week': { start: '2028-09-01', end: '2028-12-15' }, + '7 week': { start: '2028-09-01', end: '2028-10-20' }, + Custom: { start: '', end: '' }, + }, + Spring: { + '15 week': { start: '2028-09-01', end: '2028-12-15' }, + '7 week': { start: '2028-09-01', end: '2028-10-20' }, + Custom: { start: '', end: '' }, + }, + Winter: { + '15 days': { start: '2028-01-02', end: '2028-01-17' }, + '14 days': { start: '2028-01-02', end: '2028-01-16' }, + Custom: { start: '', end: '' }, + }, + Summer: { + 'Summer Session I (J)': { start: '2028-06-01', end: '2028-06-30' }, + 'Summer Session II (K)': { start: '2028-07-01', end: '2028-07-31' }, + 'Summer Session III (M)': { start: '2028-08-01', end: '2028-08-30' }, + '9 Weeks (L)': { start: '2028-06-01', end: '2028-08-01' }, + '10 Weeks (A)': { start: '2028-06-01', end: '2028-08-10' }, + '12 Weeks (I)': { start: '2028-05-20', end: '2028-08-10' }, + Custom: { start: '', end: '' }, + }, + }, + 2029: { + Fall: { + '15 week': { start: '2029-09-01', end: '2029-12-15' }, + '7 week': { start: '2029-09-01', end: '2029-10-20' }, + Custom: { start: '', end: '' }, + }, + Spring: { + '15 week': { start: '2029-09-01', end: '2029-12-15' }, + '7 week': { start: '2029-09-01', end: '2029-10-20' }, + Custom: { start: '', end: '' }, + }, + Winter: { + '15 days': { start: '2029-01-02', end: '2029-01-17' }, + '14 days': { start: '2029-01-02', end: '2029-01-16' }, + Custom: { start: '', end: '' }, + }, + Summer: { + 'Summer Session I (J)': { start: '2029-06-01', end: '2029-06-30' }, + 'Summer Session II (K)': { start: '2029-07-01', end: '2029-07-31' }, + 'Summer Session III (M)': { start: '2029-08-01', end: '2029-08-30' }, + '9 Weeks (L)': { start: '2029-06-01', end: '2029-08-01' }, + '10 Weeks (A)': { start: '2029-06-01', end: '2029-08-10' }, + '12 Weeks (I)': { start: '2029-05-20', end: '2029-08-10' }, + Custom: { start: '', end: '' }, + }, + }, + 2030: { + Fall: { + '15 week': { start: '2030-09-01', end: '2030-12-15' }, + '7 week': { start: '2030-09-01', end: '2030-10-20' }, + Custom: { start: '', end: '' }, + }, + Spring: { + '15 week': { start: '2030-09-01', end: '2030-12-15' }, + '7 week': { start: '2030-09-01', end: '2030-10-20' }, + Custom: { start: '', end: '' }, + }, + Winter: { + '15 days': { start: '2030-01-02', end: '2030-01-17' }, + '14 days': { start: '2030-01-02', end: '2030-01-16' }, + Custom: { start: '', end: '' }, + }, + Summer: { + 'Summer Session I (J)': { start: '2030-06-01', end: '2030-06-30' }, + 'Summer Session II (K)': { start: '2030-07-01', end: '2030-07-31' }, + 'Summer Session III (M)': { start: '2030-08-01', end: '2030-08-30' }, + '9 Weeks (L)': { start: '2030-06-01', end: '2030-08-01' }, + '10 Weeks (A)': { start: '2030-06-01', end: '2030-08-10' }, + '12 Weeks (I)': { start: '2030-05-20', end: '2030-08-10' }, + Custom: { start: '', end: '' }, + }, + }, + }; // Define the session options based on the selected season const getSessionOptions = (season: string) => { @@ -16,14 +206,14 @@ function AutomateDates() { return [ { value: '15 week', label: '15 week' }, { value: '7 week', label: '7 week' }, - { value: 'Custom', label: 'Custom' } + { value: 'Custom', label: 'Custom' }, ]; case 'Winter': return [ { value: '15 days', label: '15 days' }, { value: '14 days', label: '14 days' }, { value: '10 days', label: '10 days' }, - { value: 'Custom', label: 'Custom' } + { value: 'Custom', label: 'Custom' }, ]; case 'Summer': return [ @@ -33,41 +223,59 @@ function AutomateDates() { { value: '9 Weeks (L)', label: '9 Weeks (L)' }, { value: '10 Weeks (A)', label: '10 Weeks (A)' }, { value: '12 Weeks (I)', label: '12 Weeks (I)' }, - { value: 'Custom', label: 'Custom' } + { value: 'Custom', label: 'Custom' }, ]; default: return []; } }; - // Define default values based on season - const getDefaultSession = (season: string) => { - switch (season) { - case 'Fall': - case 'Spring': - return '15 week'; - case 'Winter': - return '15 days'; - case 'Summer': - return 'Summer Session I (J)'; - default: - return ''; + // Update start and end dates based on selected year, season, and session + const updateDates = () => { + console.log("year, season, session: ", year, season, session); + if (dateMapping[year]?.[season]?.[session]) { + const { start, end } = dateMapping[year][season][session]; + setStartDate(start); + setEndDate(end); + } else { + setStartDate(''); + setEndDate(''); } }; - // Handle changes to season and update session options - const handleSeasonChange = (event: React.ChangeEvent) => { - const selectedSeason = event.target.value; - setSeason(selectedSeason); - setSession(getDefaultSession(selectedSeason)); - }; + useEffect(() => { + updateDates(); + }, [season, session, year]); + + // set default session + useEffect(() => { + if (season) { + switch (season) { + case 'Fall': + case 'Spring': + setSession('15 week'); + break; + case 'Winter': + setSession('15 days'); + break; + case 'Summer': + setSession('Summer Session I (J)'); + break; + default: + setSession(''); // Clear session + } + } + }, [season]); + + useEffect(() => { + onDatesChange({ startDate, endDate }); + }, [startDate, endDate, onDatesChange]); return (
- {/* Season Dropdown */}
- setSeason(e.target.value)}> @@ -76,31 +284,23 @@ function AutomateDates() {
- {/* Year Dropdown */}
- {/* Session Dropdown */}
-
); } diff --git a/devU-client/src/components/pages/forms/courses/coursesFormPage.tsx b/devU-client/src/components/pages/forms/courses/coursesFormPage.tsx index 5010120..24244e9 100644 --- a/devU-client/src/components/pages/forms/courses/coursesFormPage.tsx +++ b/devU-client/src/components/pages/forms/courses/coursesFormPage.tsx @@ -36,6 +36,16 @@ const EditCourseFormPage = () => { setInvalidFields(newInvalidFields) } + interface Dates { + startDate: string; + endDate: string; + } + + const handleDatesChange = ({ startDate, endDate }: Dates) => { + setStartDate(startDate); + setEndDate(endDate); + }; + const handleStartDateChange = (event: React.ChangeEvent) => { setStartDate(event.target.value) } const handleEndDateChange = (event: React.ChangeEvent) => { setEndDate(event.target.value) } @@ -79,7 +89,7 @@ const EditCourseFormPage = () => { {/* */} - +
From 7c4b7c0105cb14cb4ac13eb75f22d11597deb809 Mon Sep 17 00:00:00 2001 From: NeemZ16 <110858265+NeemZ16@users.noreply.github.com> Date: Tue, 5 Nov 2024 11:56:10 -0500 Subject: [PATCH 4/6] set default semester for request to API --- .../pages/forms/courses/automateDates.tsx | 32 +++++++++---------- .../pages/forms/courses/coursesFormPage.tsx | 2 +- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/devU-client/src/components/pages/forms/courses/automateDates.tsx b/devU-client/src/components/pages/forms/courses/automateDates.tsx index c81d923..ac30f8d 100644 --- a/devU-client/src/components/pages/forms/courses/automateDates.tsx +++ b/devU-client/src/components/pages/forms/courses/automateDates.tsx @@ -21,8 +21,8 @@ const AutomateDates = ({ onDatesChange }: AutomateDatesProps) => { Custom: { start: '', end: '' }, }, Spring: { - '15 week': { start: '2024-09-01', end: '2024-12-15' }, - '7 week': { start: '2024-09-01', end: '2024-10-20' }, + '15 week': { start: '2024-02-01', end: '2024-05-15' }, + '7 week': { start: '2024-02-01', end: '2024-03-20' }, Custom: { start: '', end: '' }, }, Winter: { @@ -47,8 +47,8 @@ const AutomateDates = ({ onDatesChange }: AutomateDatesProps) => { Custom: { start: '', end: '' }, }, Spring: { - '15 week': { start: '2025-09-01', end: '2025-12-15' }, - '7 week': { start: '2025-09-01', end: '2025-10-20' }, + '15 week': { start: '2025-02-01', end: '2025-05-15' }, + '7 week': { start: '2025-02-01', end: '2025-03-20' }, Custom: { start: '', end: '' }, }, Winter: { @@ -73,8 +73,8 @@ const AutomateDates = ({ onDatesChange }: AutomateDatesProps) => { Custom: { start: '', end: '' }, }, Spring: { - '15 week': { start: '2026-09-01', end: '2026-12-15' }, - '7 week': { start: '2026-09-01', end: '2026-10-20' }, + '15 week': { start: '2026-02-01', end: '2026-05-15' }, + '7 week': { start: '2026-02-01', end: '2026-03-20' }, Custom: { start: '', end: '' }, }, Winter: { @@ -99,8 +99,8 @@ const AutomateDates = ({ onDatesChange }: AutomateDatesProps) => { Custom: { start: '', end: '' }, }, Spring: { - '15 week': { start: '2027-09-01', end: '2027-12-15' }, - '7 week': { start: '2027-09-01', end: '2027-10-20' }, + '15 week': { start: '2027-02-01', end: '2027-05-15' }, + '7 week': { start: '2027-02-01', end: '2027-03-20' }, Custom: { start: '', end: '' }, }, Winter: { @@ -125,8 +125,8 @@ const AutomateDates = ({ onDatesChange }: AutomateDatesProps) => { Custom: { start: '', end: '' }, }, Spring: { - '15 week': { start: '2028-09-01', end: '2028-12-15' }, - '7 week': { start: '2028-09-01', end: '2028-10-20' }, + '15 week': { start: '2028-02-01', end: '2028-05-15' }, + '7 week': { start: '2028-02-01', end: '2028-03-20' }, Custom: { start: '', end: '' }, }, Winter: { @@ -151,8 +151,8 @@ const AutomateDates = ({ onDatesChange }: AutomateDatesProps) => { Custom: { start: '', end: '' }, }, Spring: { - '15 week': { start: '2029-09-01', end: '2029-12-15' }, - '7 week': { start: '2029-09-01', end: '2029-10-20' }, + '15 week': { start: '2029-02-01', end: '2029-05-15' }, + '7 week': { start: '2029-02-01', end: '2029-03-20' }, Custom: { start: '', end: '' }, }, Winter: { @@ -172,13 +172,13 @@ const AutomateDates = ({ onDatesChange }: AutomateDatesProps) => { }, 2030: { Fall: { - '15 week': { start: '2030-09-01', end: '2030-12-15' }, - '7 week': { start: '2030-09-01', end: '2030-10-20' }, + '15 week': { start: '2030-02-01', end: '2030-05-15' }, + '7 week': { start: '2030-02-01', end: '2030-10-20' }, Custom: { start: '', end: '' }, }, Spring: { '15 week': { start: '2030-09-01', end: '2030-12-15' }, - '7 week': { start: '2030-09-01', end: '2030-10-20' }, + '7 week': { start: '2030-09-01', end: '2030-03-20' }, Custom: { start: '', end: '' }, }, Winter: { @@ -212,7 +212,7 @@ const AutomateDates = ({ onDatesChange }: AutomateDatesProps) => { return [ { value: '15 days', label: '15 days' }, { value: '14 days', label: '14 days' }, - { value: '10 days', label: '10 days' }, + // { value: '10 days', label: '10 days' }, { value: 'Custom', label: 'Custom' }, ]; case 'Summer': diff --git a/devU-client/src/components/pages/forms/courses/coursesFormPage.tsx b/devU-client/src/components/pages/forms/courses/coursesFormPage.tsx index 24244e9..fb447a7 100644 --- a/devU-client/src/components/pages/forms/courses/coursesFormPage.tsx +++ b/devU-client/src/components/pages/forms/courses/coursesFormPage.tsx @@ -21,7 +21,7 @@ const EditCourseFormPage = () => { const [formData, setFormData] = useState({ name: '', number: '', - semester: '', + semester: 'f0000', }) const [startDate, setStartDate] = useState(new Date().toISOString().split("T")[0]) From 4552cfa05c55397d21d6258dd4e392528ad5c732 Mon Sep 17 00:00:00 2001 From: NeemZ16 <110858265+NeemZ16@users.noreply.github.com> Date: Tue, 5 Nov 2024 12:22:05 -0500 Subject: [PATCH 5/6] semester options mobile friendly and works with theme toggle --- .../pages/forms/courses/courseUpdatePage.tsx | 24 ++++++++++++++----- .../pages/forms/courses/coursesFormPage.scss | 17 +++++++++---- 2 files changed, 30 insertions(+), 11 deletions(-) diff --git a/devU-client/src/components/pages/forms/courses/courseUpdatePage.tsx b/devU-client/src/components/pages/forms/courses/courseUpdatePage.tsx index 065df76..de78631 100644 --- a/devU-client/src/components/pages/forms/courses/courseUpdatePage.tsx +++ b/devU-client/src/components/pages/forms/courses/courseUpdatePage.tsx @@ -4,12 +4,13 @@ import { useHistory, useParams } from 'react-router-dom' import PageWrapper from 'components/shared/layouts/pageWrapper' import RequestService from 'services/request.service' -import 'react-datepicker/dist/react-datepicker.css' +// import 'react-datepicker/dist/react-datepicker.css' import { ExpressValidationError } from 'devu-shared-modules' import { useActionless } from 'redux/hooks' import TextField from 'components/shared/inputs/textField' +import AutomateDates from './automateDates' import { SET_ALERT } from 'redux/types/active.types' import { applyMessageToErrorFields, @@ -43,7 +44,7 @@ const CourseUpdatePage = ({ }) => { const [formData, setFormData] = useState({ name: '', number: '', - semester: '', + semester: 'f0000', }) const [startDate, setStartDate] = useState(new Date().toISOString()) const [endDate, setEndDate] = useState(new Date().toISOString()) @@ -68,6 +69,16 @@ const CourseUpdatePage = ({ }) => { } }, []); + interface Dates { + startDate: string; + endDate: string; + } + + const handleDatesChange = ({ startDate, endDate }: Dates) => { + setStartDate(startDate); + setEndDate(endDate); + }; + const handleChange = (value: string, e: React.ChangeEvent) => { const key = e.target.id const newInvalidFields = removeClassFromField(invalidFields, key) @@ -254,16 +265,17 @@ const CourseUpdatePage = ({ }) => { defaultValue={formData.name} /> - + helpText={invalidFields.get("semester")} /> */}
+
-
+
-
+
diff --git a/devU-client/src/components/pages/forms/courses/coursesFormPage.scss b/devU-client/src/components/pages/forms/courses/coursesFormPage.scss index bd5d3e2..750743d 100644 --- a/devU-client/src/components/pages/forms/courses/coursesFormPage.scss +++ b/devU-client/src/components/pages/forms/courses/coursesFormPage.scss @@ -83,10 +83,9 @@ input[type='date'] { gap: 5px; } -.fieldContainer>select { - // background-color: $input-field-background; - // color: $input-field-label; - // border-radius: 20px; +select { + background: $input-field-background; + color: $input-field-label; padding: 0.625rem 1rem; border: none; border-radius: 100px; @@ -110,9 +109,17 @@ input[type='file']::file-selector-button { .updateDetailsForm, .addDropForm { width: auto; // take up full container } + + .semesterOptions { + flex-direction: column; + } + + select { + width: 100%; + } } -@media (max-width: 450px) { +@media (max-width: 575px) { .datepickerContainer { flex-direction: column; } From b4d4c4293e1ae87ace8c3721d2d8e3403fba5916 Mon Sep 17 00:00:00 2001 From: NeemZ16 <110858265+NeemZ16@users.noreply.github.com> Date: Tue, 5 Nov 2024 15:14:16 -0500 Subject: [PATCH 6/6] added filtering by start date to assignments --- .../entities/assignment/assignment.service.ts | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/devU-api/src/entities/assignment/assignment.service.ts b/devU-api/src/entities/assignment/assignment.service.ts index 2948264..b6fc153 100644 --- a/devU-api/src/entities/assignment/assignment.service.ts +++ b/devU-api/src/entities/assignment/assignment.service.ts @@ -1,4 +1,4 @@ -import { IsNull } from 'typeorm' +import { IsNull, MoreThanOrEqual } from 'typeorm' import { dataSource } from '../../database' import AssignmentModel from './assignment.model' @@ -64,8 +64,24 @@ export async function listByCourse(courseId: number) { } export async function listByCourseReleased(courseId: number) { - // TODO: filter by start date after current time - return await connect().findBy({ courseId: courseId, deletedAt: IsNull() }) + // filter by start date after current time + const now = new Date(Date.now()) + const allAssignments = await connect().findBy({ courseId: courseId, startDate: MoreThanOrEqual(now), deletedAt: IsNull() }) + + console.log("ASSIGNMENTS WITH FILTER: ", allAssignments) + + // for each assignment in allAssignments (a list), if the startDate is more than 3 days from now then add it to list releasedAssignments + // const now = new Date(); + // const threeDaysFromNow = new Date(); + // threeDaysFromNow.setDate(now.getDate() + 3); + + // // Filter assignments where the startDate is within the next 3 days + // const releasedAssignments = allAssignments.filter(assignment => { + // const startDate = new Date(assignment.startDate); + // return startDate >= now && startDate <= threeDaysFromNow; + // }); + + return allAssignments; } export async function isReleased(id: number) {