From cdec90cc3b2c33e83290c5e58bf6c337be68a53e Mon Sep 17 00:00:00 2001 From: Peter Beverloo Date: Thu, 25 Apr 2024 22:48:41 +0100 Subject: [PATCH] Display active volunteers on the display --- app/display/cards/ActiveVolunteersCard.tsx | 73 ++++++++++++++++++---- 1 file changed, 61 insertions(+), 12 deletions(-) diff --git a/app/display/cards/ActiveVolunteersCard.tsx b/app/display/cards/ActiveVolunteersCard.tsx index bf6f4ef8..5b397165 100644 --- a/app/display/cards/ActiveVolunteersCard.tsx +++ b/app/display/cards/ActiveVolunteersCard.tsx @@ -3,11 +3,62 @@ 'use client'; +import Avatar from '@mui/material/Avatar'; +import Box from '@mui/material/Box'; +import Grid from '@mui/material/Unstable_Grid2'; import Paper from '@mui/material/Paper'; import Stack from '@mui/material/Stack'; import Typography from '@mui/material/Typography'; import type { DisplayShiftInfo } from '../DisplayContext'; +import { Temporal, formatDate } from '@lib/Temporal'; + +/** + * Props accepted by the component. + */ +interface ActiveVolunteerCardProps { + /** + * Timezone in which any times should be displayed in the user interface. + */ + timezone: string; + + /** + * The volunteer for whom this card is being displayed. + */ + volunteer: DisplayShiftInfo; +} + +/** + * The component displays the necessary information of a particular volunteer + * who is currently helping out at this location. + */ +function ActiveVolunteerCard(props: ActiveVolunteerCardProps) { + const endZonedDateTime = + Temporal.Instant.fromEpochSeconds(props.volunteer.end).toZonedDateTimeISO(props.timezone); + + return ( + + + + {props.volunteer.name[0]} + + + + {props.volunteer.name} + + + {props.volunteer.role}, until {formatDate(endZonedDateTime, 'HH:mm')} + + + + + ); +} /** * Props accepted by the component. @@ -29,19 +80,17 @@ export interface ActiveVolunteersCardProps { * shift, and are expected to be around. All information about these volunteers will be shown. */ export function ActiveVolunteersCard(props: ActiveVolunteersCardProps) { - const { volunteers } = props; + const size = + props.volunteers.length <= 3 ? /* full width= */ 12 : + props.volunteers.length <= 6 ? /* half width= */ 6 : + /* third width= */ 4; return ( - - - [ ActiveVolunteersCard ] - - + + { props.volunteers.map(volunteer => + + + ) } + ); }