Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
danielxue committed Apr 25, 2024
1 parent 6eae61f commit b1f3a6d
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 37 deletions.
4 changes: 2 additions & 2 deletions frontend/components/Course/Calendar/InstructorCalendar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ export default function InstructorCalendar(props: CalendarProps) {

const handleSelectSlot = useCallback(async ({ start, end }) => {
setNewEvent(true);
setStartField(new Date(start));
setEndField(new Date(end));
setStartField(start);
setEndField(end);
}, []);

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,6 @@ export const NewEventModal = (props: NewEventProps) => {
size="small"
open={show}
as={Form}
onSubmit={handleCreateEvent}
onClose={() => setModalState(false)}
>
<Modal.Header>New Event</Modal.Header>
Expand Down Expand Up @@ -420,7 +419,7 @@ export const NewEventModal = (props: NewEventProps) => {
</Modal.Content>
<Modal.Actions>
<Button onClick={() => setModalState(false)}>Cancel</Button>
<Button positive type="submit">
<Button onClick={handleCreateEvent} positive type="submit">
Create Event
</Button>
</Modal.Actions>
Expand Down
57 changes: 29 additions & 28 deletions frontend/components/Home/Dashboard/EventSidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,39 @@ const EventSidebar = (props: EventSidebarProps) => {
);
const occurrences = (data || []).map(apiOccurrenceToOccurrence);

const startOfHour = moment().startOf("hour").toISOString();
useEffect(() => {
setFilter({
start: new Date(),
end: moment().endOf("day").toDate(),
});
}, [moment().startOf("hour").toISOString()]);
}, [startOfHour]);

const eventCards = occurrences
.filter((o) => !o.cancelled)
.sort((a, b) => a.start.getTime() - b.start.getTime())
.map((o) => {
const courseIndex = getMembershipIndex(
memberships,
o.event.course_id
);
if (courseIndex === -1) return undefined;

return (
<EventCard
occurrence={o}
course={memberships[courseIndex].course}
color={eventColors[courseIndex % eventColors.length]}
/>
);
});

const sidebarContent =
eventCards.length > 0 ? (
eventCards
) : (
<div>You have no events today!</div>
);

return (
<Segment basic style={{ width: "280px" }}>
Expand All @@ -109,33 +136,7 @@ const EventSidebar = (props: EventSidebarProps) => {
<Loader active />
</>
) : (
occurrences
.sort(
(a, b) =>
a.start.getTime() - b.start.getTime()
)
.map((o) => {
const courseIndex = getMembershipIndex(
memberships,
o.event.course_id
);
if (courseIndex === -1) return undefined;

return (
<EventCard
occurrence={o}
course={
memberships[courseIndex].course
}
color={
eventColors[
courseIndex %
eventColors.length
]
}
/>
);
})
sidebarContent
)}
</Grid.Row>
</Grid>
Expand Down
4 changes: 3 additions & 1 deletion frontend/hooks/data-fetching/calendar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,11 @@ export const useOccurrences = (courseIds: number[], start: Date, end: Date) => {
}
);

const filterStartString = filter.start.toISOString();
const filterEndString = filter.end.toISOString();
useEffect(() => {
mutate(undefined, undefined, { sendRequest: false });
}, [filter.start.toISOString(), filter.end.toISOString()]);
}, [filterStartString, filterEndString]);

return {
data,
Expand Down
5 changes: 1 addition & 4 deletions frontend/types.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export interface Course {
id: number;
courseCode: string;
department: string;
courseIdQueries: string;
courseTitle: string;
description: string;
semester: number;
semesterPretty: string;
Expand Down Expand Up @@ -233,9 +233,6 @@ export interface ApiOccurrence {
event: ApiEvent;
}

// export interface ApiOccurrence extends ApiPartialOccurrence {
// }

export interface Occurrence {
id: number;
title: string;
Expand Down

0 comments on commit b1f3a6d

Please sign in to comment.