Skip to content

Commit d515e50

Browse files
kristenyeeKristen YeeThatMegamind
authored
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 <[email protected]> Co-authored-by: ThatMegamind <[email protected]> Co-authored-by: ThatMegamind <[email protected]>
1 parent 1cc3095 commit d515e50

File tree

4 files changed

+85
-13
lines changed

4 files changed

+85
-13
lines changed

src/components/Events/DailyEvent.jsx

+74-6
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
import PropTypes from 'prop-types';
2-
import { Box, Flex, Text, Grid, Button, Spacer } from '@chakra-ui/react';
2+
import { Box, Flex, Text, Grid, Button, Spacer, Badge, VStack } from '@chakra-ui/react';
33
import { useState } from 'react';
44
import { NPOBackend } from '../../utils/auth_utils.js';
55
import AUTH_ROLES from '../../utils/auth_config.js';
66
import { useAuthContext } from '../../common/AuthContext.jsx';
77
const { USER_ROLE } = AUTH_ROLES.AUTH_ROLES;
88

9-
const DailyEvent = ({ id, startTime, endTime, eventTitle, confirmed, description }) => {
9+
const DailyEvent = ({ id, startTime, endTime, eventTitle, confirmed, description, eventId }) => {
1010
const [confirmEvent, setConfirmEvent] = useState(confirmed);
11+
const [cohort, setCohort] = useState(undefined);
12+
const [cohortBadgeColor, setCohortBadgeColor] = useState(undefined);
13+
const [cohortTextColor, setCohortTextColor] = useState(undefined);
14+
const [cohortBorderColor, setCohortBorderColor] = useState(undefined);
15+
const [cohortBorder, setCohortBorder] = useState(undefined);
1116
const {currentUser} = useAuthContext();
1217

1318
let border_color = '#2B93D1';
@@ -17,6 +22,42 @@ const DailyEvent = ({ id, startTime, endTime, eventTitle, confirmed, description
1722
background_color = '#FEF1DC';
1823
}
1924

25+
const getCohort = async () => {
26+
if (eventId) {
27+
try {
28+
const { data } = await NPOBackend.get(`/catalog/${eventId}`);
29+
let year = data[0].year;
30+
if( year.length == 2)
31+
{
32+
setCohort('Both');
33+
setCohortBadgeColor("#FFFFFF");
34+
setCohortTextColor("#4A5568");
35+
setCohortBorderColor("#4A5568");
36+
setCohortBorder("outline");
37+
}
38+
else if(year[0] == 'junior')
39+
{
40+
setCohort('Junior');
41+
setCohortBadgeColor("#CBD5E0");
42+
setCohortTextColor("#171923");
43+
setCohortBorderColor("#CBD5E0");
44+
setCohortBorder("simple");
45+
}
46+
else {
47+
setCohort('Senior');
48+
setCohortBadgeColor("#4A5568");
49+
setCohortTextColor("#FFFFFF");
50+
setCohortBorderColor("#4A5568");
51+
setCohortBorder("simple");
52+
}
53+
} catch (error) {
54+
console.error('Error fetching data:', error);
55+
}
56+
}
57+
}
58+
59+
getCohort();
60+
2061
const handleConfirm = async () => {
2162
const date = new Date();
2263
try {
@@ -54,17 +95,43 @@ const DailyEvent = ({ id, startTime, endTime, eventTitle, confirmed, description
5495

5596
<Spacer />
5697

98+
<VStack align="flex-end">
99+
<Badge
100+
key={eventId}
101+
variant={cohortBorder}
102+
backgroundColor={cohortBadgeColor}
103+
color={cohortTextColor}
104+
textTransform="capitalize"
105+
borderRadius="10rem"
106+
borderColor={cohortBorderColor}
107+
fontWeight="normal"
108+
px="0.5rem"
109+
mr="0.125rem"
110+
>
111+
{cohort}
112+
</Badge>
113+
57114
{!confirmEvent && (
58-
<Box w="15vh" alignItems="top">
115+
<Box w="4rem" alignItems="top">
59116
<Grid gap={2}>
60117
<div></div>
61118
<div></div>
62-
<Button bg="#FBD38D" textColor="#2D3748" size="sm" onClick={handleConfirm} visibility={currentUser.type == USER_ROLE ? 'hidden' : 'visible'}>
119+
<Button
120+
variant="outline"
121+
bg="#FEF1DC"
122+
textColor="#F69052"
123+
borderColor="#F69052"
124+
_hover={{ bg: "#F6AD55", color: "#2D3748" }}
125+
size="xs"
126+
onClick={handleConfirm}
127+
visibility={currentUser.type == USER_ROLE ? 'hidden' : 'visible'}
128+
>
63129
Confirm
64130
</Button>
65-
</Grid>
66-
</Box>
131+
</Grid>
132+
</Box>
67133
)}
134+
</VStack>
68135
</Flex>
69136
</Box>
70137
);
@@ -77,6 +144,7 @@ DailyEvent.propTypes = {
77144
eventTitle: PropTypes.string.isRequired,
78145
description: PropTypes.string,
79146
confirmed: PropTypes.bool.isRequired,
147+
eventId: PropTypes.number.isRequired,
80148
};
81149

82150
export default DailyEvent;

src/components/Events/EventInfo.jsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,10 @@ const EventInfo = ({ dayId, eventDate, day, startTime, endTime, location, notes,
4747
{day} {startTime} - {endTime}
4848
</Text>
4949

50-
<Text mb="1.5rem">{location}</Text>
50+
<Text as="b" mb="0.5rem">Location: </Text>
51+
<Text whiteSpace="pre-wrap" mb="2rem">{location}</Text>
5152

52-
<Text mb="0.5rem">Details:</Text>
53+
<Text as="b" mb="0.5rem">Details:</Text>
5354
<Text whiteSpace="pre-wrap" mb="2rem">{notes ? notes : 'No notes.'}</Text>
5455

5556
<HStack mt="auto">

src/components/Events/Events.jsx

+3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import { Grid } from '@chakra-ui/react';
55

66
const Events = ({ eventData }) => {
77

8+
// console.log("Event Data", eventData);
9+
810
const formatDate = (date) => {
911
let time = date.split(":");
1012
let hours = time[0];
@@ -73,6 +75,7 @@ const Events = ({ eventData }) => {
7375
eventTitle={item.title}
7476
description={item.description}
7577
confirmed={item.confirmed}
78+
eventId={item.eventId}
7679
/>
7780
))}
7881
</Grid>

src/components/Events/PublishedScheduleTable.jsx

+5-5
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ const PublishedScheduleTable = ({ season, allSeasons }) => {
6969
bottom="6rem"
7070
right={{ base: '1rem', lg: '2rem', xl: '3rem' }}
7171
fontSize="1.25rem"
72-
w="3rem"
73-
h="3rem"
72+
w="3.25rem"
73+
h="3.25rem"
7474
_hover={{ bgColor: 'blue.500' }}
7575
onClick={onOpenStats}
7676
icon={<IoStatsChart />}
@@ -86,8 +86,8 @@ const PublishedScheduleTable = ({ season, allSeasons }) => {
8686
bottom="2rem"
8787
right={{ base: '1rem', lg: '2rem', xl: '3rem' }}
8888
fontSize="0.75rem"
89-
w="3rem"
90-
h="3rem"
89+
w="3.25rem"
90+
h="3.25rem"
9191
_hover={{ bgColor: 'blue.500' }}
9292
onClick={onOpenDay}
9393
icon={<AddIcon />}
@@ -102,7 +102,7 @@ const PublishedScheduleTable = ({ season, allSeasons }) => {
102102
<StatModal isOpen={isOpenStats} onClose={onCloseStats} season={season} allSeasons={allSeasons}/>
103103
}
104104

105-
<TableContainer borderWidth={1} borderRadius="10px">
105+
<TableContainer borderWidth={1} borderRadius="10px" mr="2rem">
106106
<Table variant="simple">
107107
<Thead>
108108
<Tr>

0 commit comments

Comments
 (0)