Skip to content

Commit

Permalink
Added general schedule (#982)
Browse files Browse the repository at this point in the history
  • Loading branch information
itamaroryan authored Jan 31, 2025
1 parent 88637d6 commit ac0bd1e
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 6 deletions.
7 changes: 3 additions & 4 deletions apps/backend/src/routers/public/portal/divisions/schedule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import { PortalActivity, PortalSchedule, RobotGameMatch } from '@lems/types';
const router = express.Router({ mergeParams: true });

router.get('/', (req: Request, res: Response) => {
const generalActivities: Array<PortalActivity<'general'>> = (req.division.schedule ?? []).map(
({ name, startTime }) => ({ type: 'general', name, time: startTime })
);
const generalActivities: Array<PortalActivity<'general'>> = (req.division.schedule ?? [])
.filter(activity => activity.showOnDashboard)
.map(({ name, startTime }) => ({ type: 'general', name, time: startTime }));
res.json(generalActivities);
});

Expand All @@ -37,7 +37,6 @@ router.get(

const columns = rooms.map(room => ({ id: String(room._id), name: room.name }));

// Group sessions by scheduled time, sort array by rooms
const rows = {};

for (const session of sessions) {
Expand Down
11 changes: 11 additions & 0 deletions apps/portal/components/events/event-quick-links.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,17 @@ const EventQuickLinks: React.FC<EventQuickLinksProps> = ({ event, hasAwards }) =
לוח זמנים - שיפוט
</Button>
</Grid>
<Grid size={{ xs: 6, md: 3 }}>
<Button
variant="contained"
fullWidth
sx={{ borderRadius: 2, minHeight: 25 }}
LinkComponent={Link}
href={`/events/${event.id}/schedule/general`}
>
לוח זמנים כללי
</Button>
</Grid>
</Grid>
);
};
Expand Down
4 changes: 2 additions & 2 deletions apps/portal/lib/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export const fetchScoreboard = async (eventId: string) => {
return { scoreboard, stage: field.stage };
};

export const fetchSchedule = async (eventId: string, type: 'field' | 'judging') => {
const schedule = await apiFetch<PortalSchedule>(`/events/${eventId}/schedule/${type}`);
export const fetchGeneralSchedule = async (eventId: string) => {
const schedule = await apiFetch<PortalSchedule>(`/events/${eventId}/schedule`);
return schedule;
};
47 changes: 47 additions & 0 deletions apps/portal/pages/events/[id]/schedule/general.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { GetServerSideProps, GetServerSidePropsContext, NextPage } from 'next';
import dayjs from 'dayjs';
import { Typography, Container, Stack, Divider, Paper } from '@mui/material';
import { PortalActivity, PortalEvent, RobotGameMatchStage } from '@lems/types';
import { fetchEvent, fetchGeneralSchedule } from '../../../../lib/api';
import StyledEventSubtitle from '../../../../components/events/styled-event-subtitle';

interface Props {
event: PortalEvent;
schedule: PortalActivity<'general'>[];
}

const Page: NextPage<Props> = ({ event, schedule }) => {
return (
<Container maxWidth="md" sx={{ mt: 2 }}>
<Typography variant="h2">לוח זמנים כללי</Typography>
<StyledEventSubtitle event={event} />
<Stack component={Paper} spacing={1} p={2} mt={2}>
{schedule.length === 0 && <Typography variant="body1">אין לוח זמנים כללי</Typography>}
{schedule.map((activity, index) => (
<Stack
key={index}
spacing={2}
direction="row"
alignItems="center"
divider={<Divider orientation="vertical" flexItem sx={{ borderWidth: 1 }} />}
>
<Typography sx={{ dir: 'ltr' }} variant="body1" fontWeight={500}>
{dayjs(activity.time).format('HH:mm')}
</Typography>
<Typography variant="body1">{activity.name}</Typography>
</Stack>
))}
</Stack>
</Container>
);
};

export const getServerSideProps: GetServerSideProps = async (ctx: GetServerSidePropsContext) => {
const eventId = ctx.params?.id as string;

const { event } = await fetchEvent(eventId);
const schedule = await fetchGeneralSchedule(eventId);
return { props: { event, schedule } };
};

export default Page;

0 comments on commit ac0bd1e

Please sign in to comment.