Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Table, TableBody, TableCell, TableContainer, TableHead, TableRow, Typography } from '@mui/material';
import { Availability, dbDateToLocalDate, Event, EventWithMembers, getDayOfWeek, getNextSevenDays, User } from 'shared';
import { Availability, Event, EventWithMembers, getDayOfWeek, getNextSevenDays, User } from 'shared';
import React, { useState } from 'react';
import { enumToArray, getBackgroundColor, NUMBER_OF_TIME_SLOTS, REVIEW_TIMES } from '../../utils/design-review.utils';
import { datePipe } from '../../utils/pipes';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { useQuery as useQueryParam } from '../../../hooks/utils.hooks';
import { Box, Grid, Typography, useTheme } from '@mui/material';
import {
Availability,
dbDateToLocalDate,
getMostRecentAvailabilities,
User,
UserWithScheduleSettings,
Expand Down
13 changes: 4 additions & 9 deletions src/frontend/src/pages/HomePage/components/EventCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import CalendarMonthIcon from '@mui/icons-material/CalendarMonth';
import { LocationOnOutlined, Computer } from '@mui/icons-material';
import { useHistory } from 'react-router-dom';
import { NERButton } from '../../../components/NERButton';
import { formatDateOnly, formatEventDate } from 'shared';
import { formatEventDate } from 'shared';

interface EventProps {
event: Event;
Expand Down Expand Up @@ -58,10 +58,7 @@ const DisplayStatus: React.FC<EventProps> = ({ event, user }) => {
);
};

const getWeekday = (date: Date, utc = false): string => {
if (utc) {
return formatDateOnly(date, 'dddd');
}
const getWeekday = (date: Date): string => {
const weekdays: string[] = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
return weekdays[date.getDay()];
};
Expand All @@ -70,9 +67,7 @@ const UpcomingEventCard: React.FC<EventProps> = ({ event, user }) => {
const theme = useTheme();
const firstScheduledDate = event.initialDateScheduled || event.scheduledTimes[0]?.startTime;
const displayDate = firstScheduledDate ? new Date(firstScheduledDate) : new Date();
// initialDateScheduled is a date-only field (@db.Date), scheduledTimes startTime is a full datetime
const isDateOnly = !!event.initialDateScheduled;
const formattedDate = isDateOnly ? formatDateOnly(displayDate, 'MM/DD') : formatEventDate(displayDate);
const formattedDate = formatEventDate(displayDate);

const [firstWorkPackage] = event.workPackages;

Expand Down Expand Up @@ -110,7 +105,7 @@ const UpcomingEventCard: React.FC<EventProps> = ({ event, user }) => {
<Stack direction="row" spacing={1} sx={{ mt: 0.5 }}>
<Typography>{<CalendarMonthIcon sx={{ fontSize: 21 }} />}</Typography>
<Typography fontWeight={'regular'} variant="body2">
{getWeekday(displayDate, isDateOnly) +
{getWeekday(displayDate) +
', ' +
formattedDate +
' @ ' +
Expand Down