Skip to content

Commit 229c50f

Browse files
committed
#2217 tooltip + fixed dates
1 parent 1a985a8 commit 229c50f

3 files changed

Lines changed: 30 additions & 12 deletions

File tree

src/frontend/src/pages/CalendarPage/CalendarComponents/CalendarDayCard.tsx

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,20 +71,40 @@ const CalendarDayCard: React.FC<CalendarDayCardProps> = ({ cardDate, events }) =
7171
return (
7272
<>
7373
<DRCSummaryModal open={isSummaryModalOpen} onHide={() => setIsSummaryModalOpen(false)} designReview={event} />
74-
<Link style={{ cursor: 'pointer' }} fontSize={15} onClick={() => setIsSummaryModalOpen(true)}>
74+
<Link
75+
style={{ cursor: 'pointer' }}
76+
fontSize={15}
77+
onClick={() => {
78+
setIsSummaryModalOpen(true);
79+
}}
80+
>
7581
{event.wbsName + (event.meetingTimes.length > 0 ? ' - ' + meetingStartTimePipe(event.meetingTimes) : '')}
7682
</Link>
7783
</>
7884
);
7985
};
8086

8187
const ExtraEventsCard = (extraEvents: DesignReview[]) => {
88+
const [showTooltip, setShowTooltip] = useState(false);
8289
return (
8390
<Box marginLeft={0.5} marginBottom={0.2}>
84-
<Card sx={{ backgroundColor: 'grey', borderRadius: 1, minWidth: 140, maxWidth: 140, minHeight: 20, maxHeight: 20 }}>
91+
<Card
92+
sx={{
93+
backgroundColor: 'grey',
94+
borderRadius: 1,
95+
minWidth: 140,
96+
maxWidth: 140,
97+
minHeight: 20,
98+
maxHeight: 20
99+
}}
100+
>
85101
<Tooltip
86102
id="tooltip"
103+
open={showTooltip}
104+
disableHoverListener
105+
onClick={() => setShowTooltip(!showTooltip)}
87106
placement="right"
107+
sx={{ cursor: 'pointer' }}
88108
PopperProps={{
89109
popperOptions: {
90110
modifiers: [

src/frontend/src/pages/CalendarPage/CalendarPage.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import { useState } from 'react';
66
import { Box, Grid, Stack, Typography, useTheme } from '@mui/material';
77
import PageLayout from '../../components/PageLayout';
8-
import { DesignReview, DesignReviewStatus } from 'shared';
8+
import { DesignReview } from 'shared';
99
import MonthSelector from './CalendarComponents/MonthSelector';
1010
import CalendarDayCard, { getTeamTypeIcon } from './CalendarComponents/CalendarDayCard';
1111
import FillerCalendarDayCard from './CalendarComponents/FillerCalendarDayCard';
@@ -26,10 +26,11 @@ const CalendarPage = () => {
2626
if (isLoading || !allDesignReviews) return <LoadingIndicator />;
2727
if (isError) return <ErrorPage message={error.message} />;
2828

29-
const designReviews = allDesignReviews.filter(isConfirmed);
29+
const confirmedDesignReviews = allDesignReviews.filter(isConfirmed);
3030

3131
const eventDict = new Map<string, DesignReview[]>();
32-
designReviews.forEach((designReview) => {
32+
confirmedDesignReviews.forEach((designReview) => {
33+
// Accessing the date actually converts it to local time, which causes the date to be off. This is a workaround.
3334
const date = datePipe(
3435
new Date(designReview.dateScheduled.getTime() - designReview.dateScheduled.getTimezoneOffset() * -60000)
3536
);
@@ -41,8 +42,7 @@ const CalendarPage = () => {
4142
});
4243

4344
const unconfirmedDR = allDesignReviews.filter(
44-
(designReview) =>
45-
designReview.userCreated.userId === user.userId && designReview.status === DesignReviewStatus.UNCONFIRMED
45+
(designReview) => designReview.userCreated.userId === user.userId && !isConfirmed(designReview)
4646
);
4747

4848
const startOfEachWeek = [0, 7, 14, 21, 28, 35];

src/frontend/src/utils/pipes.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
*/
55

66
import { WbsNumber, User, wbsPipe, WbsElement, isProject, WorkPackage, ClubAccount, ExpenseType } from 'shared';
7-
import { NOON_IN_MINUTES } from './design-review.utils';
87

98
/**
109
* Pipes:
@@ -165,10 +164,9 @@ export const displayEnum = (enumString: string) => {
165164
};
166165

167166
export const meetingStartTimePipe = (times: number[]) => {
168-
const time = times[0] * 15 + 9 * 60;
169-
const minutes = time % 60;
170-
const hours = ((time - minutes) / 60) % 12 === 0 ? 12 : ((time - minutes) / 60) % 12;
171-
return hours + (minutes !== 0 ? ':' + minutes : '') + (time >= NOON_IN_MINUTES ? 'pm' : 'am');
167+
const time = (times[0] % 12) + 10;
168+
169+
return time <= 12 ? time + 'am' : time - 12 + 'pm';
172170
};
173171

174172
// takes in a Date and returns it as a string in the form mm/dd/yy

0 commit comments

Comments
 (0)