Skip to content

Commit

Permalink
Fixed times on portal schedules
Browse files Browse the repository at this point in the history
  • Loading branch information
johnmeshulam committed Jan 31, 2025
1 parent e9a38f0 commit c358537
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
7 changes: 4 additions & 3 deletions apps/backend/src/routers/public/portal/divisions/schedule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import asyncHandler from 'express-async-handler';
import { ObjectId } from 'mongodb';
import dayjs from 'dayjs';
import * as db from '@lems/database';
import { PortalActivity, PortalSchedule, RobotGameMatch } from '@lems/types';
import { PortalActivity, PortalSchedule } from '@lems/types';

const router = express.Router({ mergeParams: true });

Expand Down Expand Up @@ -40,7 +40,7 @@ router.get(
const rows = {};

for (const session of sessions) {
const startTime = dayjs(session.scheduledTime).format('HH:mm');
const startTime = dayjs(session.scheduledTime).unix();
const team = teams.find(team => String(team._id) === String(session.teamId));
const room = rooms.find(room => String(room._id) === String(session.roomId));

Expand Down Expand Up @@ -115,7 +115,8 @@ router.get(
if (!acc[match.stage][match.round]) {
acc[match.stage][match.round] = { columns, rows: {} };
}
acc[match.stage][match.round].rows[dayjs(match.scheduledTime).format('HH:mm')] = {
const startTime = dayjs(match.scheduledTime).unix();
acc[match.stage][match.round].rows[startTime] = {
number: match.number,
data: matchTeams
};
Expand Down
3 changes: 2 additions & 1 deletion apps/portal/pages/events/[id]/schedule/field.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { GetServerSideProps, GetServerSidePropsContext, NextPage } from 'next';
import dayjs from 'dayjs';
import {
TableContainer,
Table,
Expand Down Expand Up @@ -83,7 +84,7 @@ const Page: NextPage<Props> = ({ event }) => {
sx={{ '&:last-child td, &:last-child th': { border: 0 } }}
>
<TableCell>{teams.number}</TableCell>
<TableCell>{time}</TableCell>
<TableCell>{dayjs.unix(Number(time)).format('HH:mm')}</TableCell>
{round.schedule.columns.map(column => {
const team = teams.data.find(t => t?.column === column.id);
return (
Expand Down
6 changes: 3 additions & 3 deletions apps/portal/pages/events/[id]/schedule/judging.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { GetServerSideProps, GetServerSidePropsContext, NextPage } from 'next';
import dayjs from 'dayjs';
import {
TableContainer,
Table,
Expand All @@ -9,8 +10,7 @@ import {
TableBody,
Paper,
Container,
Box,
Stack
Box
} from '@mui/material';
import { PortalEvent, PortalJudgingSchedule } from '@lems/types';
import { fetchEvent } from '../../../../lib/api';
Expand Down Expand Up @@ -64,7 +64,7 @@ const Page: NextPage<Props> = ({ event }) => {
{Object.entries(schedule.rows).map(([time, session]) => (
<TableRow key={time} sx={{ '&:last-child td, &:last-child th': { border: 0 } }}>
<TableCell>{session.number}</TableCell>
<TableCell>{time}</TableCell>
<TableCell>{dayjs.unix(Number(time)).format('HH:mm')}</TableCell>
{schedule.columns.map(column => {
const team = session.data.find(t => t?.column === column.id);
return (
Expand Down
2 changes: 1 addition & 1 deletion libs/types/src/lib/portal/requests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export type PortalActivity<T extends 'match' | 'session' | 'general'> = T extend
export interface PortalSchedule {
columns: { id: string; name: string }[];
rows: Record<
string,
number,
{
number: number;
data: ((PortalTeam & { column: string }) | null)[];
Expand Down

0 comments on commit c358537

Please sign in to comment.