Skip to content

Commit

Permalink
Remove inductee polling on event page. (#188)
Browse files Browse the repository at this point in the history
* Remove inductee polling on Event page.

* Fix props.
  • Loading branch information
godwinpang authored Nov 16, 2020
1 parent 478bc1a commit a6fd9a1
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { parseISO, format } from 'date-fns';

import { useInterval } from '../../../../hooks/index';

import { OfficerRenderPermission } from '@HOCs/RenderPermissions';
import { Button, Table } from '@SharedComponents';
import {
AttendanceResponse,
Expand Down Expand Up @@ -57,28 +56,24 @@ function CheckOffTable(props: CheckOffTableProps) {
delay: 1000,
});

// TODO: Remove type casting on startTime when startTime on payload is changed to string and move map logic to a separate function
return (
<>
{OfficerRenderPermission(Table)({
columns,
data: attendances.map(attendance => {
const fullName = `${attendance.attendee.firstName} ${attendance.attendee.lastName}`;
const startTimeString = format(
parseISO(attendance.startTime),
'PPP h:mm aaaa'
);
const attendanceToDisplay = {
...attendance,
name: fullName,
startTimeString,
};
const attendanceData = attendances.map(attendance => {
const fullName = `${attendance.attendee.firstName} ${attendance.attendee.lastName}`;
// TODO: Remove type casting on startTime when startTime on payload is changed to string and move map logic to a separate function
const startTimeString = format(
parseISO((attendance.startTime as unknown) as string),
'PPP h:mm aaaa'
);
const attendanceToDisplay = {
...attendance,
name: fullName,
startTimeString,
};

return attendanceToDisplay;
});

return attendanceToDisplay;
}),
title: 'Check Off Table',
})}
</>
return (
<Table columns={columns} data={attendanceData} title='Check Off Table' />
);
}

Expand Down
11 changes: 6 additions & 5 deletions frontend/src/pages/EventDetailsPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import EventDetailsComponent from './components/EventDetails';
import CheckOffTable from './components/CheckOffTable';

import { Loading } from '@SharedComponents';
import { OfficerRenderPermission } from '@HOCs/RenderPermissions';
import {
getEventById,
getEventAttendances,
Expand Down Expand Up @@ -41,11 +42,11 @@ function EventDetailsPage(): JSX.Element {
</Grid>

<Grid item xs={12}>
<CheckOffTable
getAttendances={() => getEventAttendances(eventId, true, true)}
checkOffAttendance={checkOffAttendance}
eventId={eventId}
/>
{OfficerRenderPermission(CheckOffTable)({
getAttendances: () => getEventAttendances(eventId, true, false),
checkOffAttendance,
eventId,
})}
</Grid>

<Grid item>
Expand Down

0 comments on commit a6fd9a1

Please sign in to comment.