From d515e503b70c203676ebafe0c0147909b54c6b12 Mon Sep 17 00:00:00 2001 From: kristenyee <66435886+kristenyee@users.noreply.github.com> Date: Sat, 27 Apr 2024 14:50:46 -0700 Subject: [PATCH] 80 published schedule refinements (#90) * page adjustments * added cohort tags and updated confirm button color to match design * made stat button bigger to match add day button --------- Co-authored-by: Kristen Yee Co-authored-by: ThatMegamind <92563733+ThatMegamind@users.noreply.github.com> Co-authored-by: ThatMegamind --- src/components/Events/DailyEvent.jsx | 80 +++++++++++++++++-- src/components/Events/EventInfo.jsx | 5 +- src/components/Events/Events.jsx | 3 + .../Events/PublishedScheduleTable.jsx | 10 +-- 4 files changed, 85 insertions(+), 13 deletions(-) diff --git a/src/components/Events/DailyEvent.jsx b/src/components/Events/DailyEvent.jsx index 4e4a257..d5e60e1 100644 --- a/src/components/Events/DailyEvent.jsx +++ b/src/components/Events/DailyEvent.jsx @@ -1,13 +1,18 @@ import PropTypes from 'prop-types'; -import { Box, Flex, Text, Grid, Button, Spacer } from '@chakra-ui/react'; +import { Box, Flex, Text, Grid, Button, Spacer, Badge, VStack } from '@chakra-ui/react'; import { useState } from 'react'; import { NPOBackend } from '../../utils/auth_utils.js'; import AUTH_ROLES from '../../utils/auth_config.js'; import { useAuthContext } from '../../common/AuthContext.jsx'; const { USER_ROLE } = AUTH_ROLES.AUTH_ROLES; -const DailyEvent = ({ id, startTime, endTime, eventTitle, confirmed, description }) => { +const DailyEvent = ({ id, startTime, endTime, eventTitle, confirmed, description, eventId }) => { const [confirmEvent, setConfirmEvent] = useState(confirmed); + const [cohort, setCohort] = useState(undefined); + const [cohortBadgeColor, setCohortBadgeColor] = useState(undefined); + const [cohortTextColor, setCohortTextColor] = useState(undefined); + const [cohortBorderColor, setCohortBorderColor] = useState(undefined); + const [cohortBorder, setCohortBorder] = useState(undefined); const {currentUser} = useAuthContext(); let border_color = '#2B93D1'; @@ -17,6 +22,42 @@ const DailyEvent = ({ id, startTime, endTime, eventTitle, confirmed, description background_color = '#FEF1DC'; } + const getCohort = async () => { + if (eventId) { + try { + const { data } = await NPOBackend.get(`/catalog/${eventId}`); + let year = data[0].year; + if( year.length == 2) + { + setCohort('Both'); + setCohortBadgeColor("#FFFFFF"); + setCohortTextColor("#4A5568"); + setCohortBorderColor("#4A5568"); + setCohortBorder("outline"); + } + else if(year[0] == 'junior') + { + setCohort('Junior'); + setCohortBadgeColor("#CBD5E0"); + setCohortTextColor("#171923"); + setCohortBorderColor("#CBD5E0"); + setCohortBorder("simple"); + } + else { + setCohort('Senior'); + setCohortBadgeColor("#4A5568"); + setCohortTextColor("#FFFFFF"); + setCohortBorderColor("#4A5568"); + setCohortBorder("simple"); + } + } catch (error) { + console.error('Error fetching data:', error); + } + } + } + + getCohort(); + const handleConfirm = async () => { const date = new Date(); try { @@ -54,17 +95,43 @@ const DailyEvent = ({ id, startTime, endTime, eventTitle, confirmed, description + + + {cohort} + + {!confirmEvent && ( - +
- -
-
+ +
)} +
); @@ -77,6 +144,7 @@ DailyEvent.propTypes = { eventTitle: PropTypes.string.isRequired, description: PropTypes.string, confirmed: PropTypes.bool.isRequired, + eventId: PropTypes.number.isRequired, }; export default DailyEvent; diff --git a/src/components/Events/EventInfo.jsx b/src/components/Events/EventInfo.jsx index 48d9354..785fc09 100644 --- a/src/components/Events/EventInfo.jsx +++ b/src/components/Events/EventInfo.jsx @@ -47,9 +47,10 @@ const EventInfo = ({ dayId, eventDate, day, startTime, endTime, location, notes, {day} {startTime} - {endTime} - {location} + Location: + {location} - Details: + Details: {notes ? notes : 'No notes.'} diff --git a/src/components/Events/Events.jsx b/src/components/Events/Events.jsx index 85b4938..f1df953 100644 --- a/src/components/Events/Events.jsx +++ b/src/components/Events/Events.jsx @@ -5,6 +5,8 @@ import { Grid } from '@chakra-ui/react'; const Events = ({ eventData }) => { + // console.log("Event Data", eventData); + const formatDate = (date) => { let time = date.split(":"); let hours = time[0]; @@ -73,6 +75,7 @@ const Events = ({ eventData }) => { eventTitle={item.title} description={item.description} confirmed={item.confirmed} + eventId={item.eventId} /> ))} diff --git a/src/components/Events/PublishedScheduleTable.jsx b/src/components/Events/PublishedScheduleTable.jsx index 4537251..f6ec432 100644 --- a/src/components/Events/PublishedScheduleTable.jsx +++ b/src/components/Events/PublishedScheduleTable.jsx @@ -69,8 +69,8 @@ const PublishedScheduleTable = ({ season, allSeasons }) => { bottom="6rem" right={{ base: '1rem', lg: '2rem', xl: '3rem' }} fontSize="1.25rem" - w="3rem" - h="3rem" + w="3.25rem" + h="3.25rem" _hover={{ bgColor: 'blue.500' }} onClick={onOpenStats} icon={} @@ -86,8 +86,8 @@ const PublishedScheduleTable = ({ season, allSeasons }) => { bottom="2rem" right={{ base: '1rem', lg: '2rem', xl: '3rem' }} fontSize="0.75rem" - w="3rem" - h="3rem" + w="3.25rem" + h="3.25rem" _hover={{ bgColor: 'blue.500' }} onClick={onOpenDay} icon={} @@ -102,7 +102,7 @@ const PublishedScheduleTable = ({ season, allSeasons }) => { } - +