Skip to content

Commit caed965

Browse files
committed
Fixed weekday breakdown for room schedule
1 parent e9fdae3 commit caed965

File tree

1 file changed

+42
-7
lines changed

1 file changed

+42
-7
lines changed

src/pages/Competition/Room.tsx

Lines changed: 42 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,22 +31,57 @@ export default function Round() {
3131
);
3232

3333
const scheduleDays = activities
34-
.map((a) => {
35-
const dateTime = new Date(a.startTime);
34+
.map((activity) => {
35+
const venue =
36+
wcif?.schedule.venues?.find((v) =>
37+
v.rooms.some((r) =>
38+
r.activities.some(
39+
(a) => a.id === activity.id || a.childActivities?.some((ca) => ca.id === activity.id)
40+
)
41+
)
42+
) || wcif?.schedule.venues?.[0];
43+
44+
const dateTime = new Date(activity.startTime);
45+
3646
return {
3747
approxDateTime: dateTime.getTime(),
38-
date: formatDate(dateTime) || 'foo',
48+
date: dateTime.toLocaleDateString([], {
49+
weekday: 'long',
50+
year: 'numeric',
51+
month: 'numeric',
52+
day: 'numeric',
53+
timeZone: venue?.timezone,
54+
}),
3955
dateParts: formatToParts(dateTime),
4056
};
4157
})
4258
.filter((v, i, arr) => arr.findIndex(({ date }) => date === v.date) === i)
4359
.sort((a, b) => a.approxDateTime - b.approxDateTime);
4460

4561
const activitiesWithParsedDate = activities
46-
.map((a) => ({
47-
...a,
48-
date: formatDate(new Date(a.startTime)),
49-
}))
62+
.map((activity) => {
63+
const venue =
64+
wcif?.schedule.venues?.find((v) =>
65+
v.rooms.some((r) =>
66+
r.activities.some(
67+
(a) => a.id === activity.id || a.childActivities?.some((ca) => ca.id === activity.id)
68+
)
69+
)
70+
) || wcif?.schedule.venues?.[0];
71+
72+
const dateTime = new Date(activity.startTime);
73+
74+
return {
75+
...activity,
76+
date: dateTime.toLocaleDateString([], {
77+
weekday: 'long',
78+
year: 'numeric',
79+
month: 'numeric',
80+
day: 'numeric',
81+
timeZone: venue?.timezone,
82+
}),
83+
};
84+
})
5085
.sort((a, b) => byDate(a, b));
5186

5287
const getActivitiesByDate = useCallback(

0 commit comments

Comments
 (0)