Skip to content

Commit 36ba00e

Browse files
committed
#2217 - clean up code a bit
1 parent 229c50f commit 36ba00e

2 files changed

Lines changed: 15 additions & 9 deletions

File tree

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

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ const CalendarDayCard: React.FC<CalendarDayCardProps> = ({ cardDate, events }) =
4141
</Grid>
4242
);
4343

44-
const EventCard = (event: DesignReview) => {
44+
const EventCard = ({ event }: { event: DesignReview }) => {
4545
const [isSummaryModalOpen, setIsSummaryModalOpen] = useState(false);
4646
const name = event.wbsName;
4747
return (
@@ -65,7 +65,7 @@ const CalendarDayCard: React.FC<CalendarDayCardProps> = ({ cardDate, events }) =
6565
);
6666
};
6767

68-
const ExtraEventNote = (event: DesignReview) => {
68+
const ExtraEventNote = ({ event }: { event: DesignReview }) => {
6969
const [isSummaryModalOpen, setIsSummaryModalOpen] = useState(false);
7070

7171
return (
@@ -84,7 +84,7 @@ const CalendarDayCard: React.FC<CalendarDayCardProps> = ({ cardDate, events }) =
8484
);
8585
};
8686

87-
const ExtraEventsCard = (extraEvents: DesignReview[]) => {
87+
const ExtraEventsCard = ({ extraEvents }: { extraEvents: DesignReview[] }) => {
8888
const [showTooltip, setShowTooltip] = useState(false);
8989
return (
9090
<Box marginLeft={0.5} marginBottom={0.2}>
@@ -126,7 +126,13 @@ const CalendarDayCard: React.FC<CalendarDayCardProps> = ({ cardDate, events }) =
126126
}
127127
}}
128128
arrow
129-
title={<Stack direction="column">{extraEvents.map((event) => ExtraEventNote(event))}</Stack>}
129+
title={
130+
<Stack direction="column">
131+
{extraEvents.map((event) => (
132+
<ExtraEventNote event={event} />
133+
))}
134+
</Stack>
135+
}
130136
>
131137
<Typography marginLeft={0.5} marginBottom={0.3} align="center">
132138
{'+' + extraEvents.length}
@@ -142,11 +148,11 @@ const CalendarDayCard: React.FC<CalendarDayCardProps> = ({ cardDate, events }) =
142148
<CardContent sx={{ padding: 0 }}>
143149
<DayCardTitle />
144150
{events.length < 3 ? (
145-
events.map((event) => EventCard(event))
151+
events.map((event) => <EventCard event={event} />)
146152
) : (
147153
<>
148-
{EventCard(events[0])}
149-
{ExtraEventsCard(events.slice(1))}
154+
<EventCard event={events[0]} />
155+
<ExtraEventsCard extraEvents={events.slice(1)} />
150156
</>
151157
)}
152158
</CardContent>

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ const CalendarPage = () => {
4141
}
4242
});
4343

44-
const unconfirmedDR = allDesignReviews.filter(
44+
const unconfirmedDesignReviews = allDesignReviews.filter(
4545
(designReview) => designReview.userCreated.userId === user.userId && !isConfirmed(designReview)
4646
);
4747

@@ -77,7 +77,7 @@ const CalendarPage = () => {
7777
.concat(paddingArrayEnd.length < 7 ? paddingArrayEnd : []);
7878

7979
const unconfirmedDRSDropdown = (
80-
<ActionsMenu title="My Unconfirmed DRS" buttons={designReviewButtons(unconfirmedDR)}>
80+
<ActionsMenu title="My Unconfirmed DRS" buttons={designReviewButtons(unconfirmedDesignReviews)}>
8181
My Unconfirmed DRs
8282
</ActionsMenu>
8383
);

0 commit comments

Comments
 (0)