Skip to content

Commit 703ff41

Browse files
committed
Fixed schedule page weekdays
1 parent 31a01aa commit 703ff41

File tree

2 files changed

+35
-9
lines changed

2 files changed

+35
-9
lines changed

src/pages/Competition/Person/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,9 @@ export default function PersonPage() {
135135
.map((a) => {
136136
const venue = a?.activity?.room?.id
137137
? wcif?.schedule.venues?.find((v) =>
138-
v.rooms.some((r) => r.id === a.activity?.room?.id || a.activity?.parent?.room?.id)
138+
v.rooms.some(
139+
(r) => r.id === a.activity?.room?.id || r.id === a.activity?.parent?.room?.id
140+
)
139141
)
140142
: wcif?.schedule.venues?.[0];
141143

src/pages/Competition/Schedule.tsx

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,47 @@ export default function Round() {
2727

2828
const scheduleDays = activities
2929
.map((a) => {
30+
const room = a.room || a.parent?.room;
31+
const venue =
32+
wcif?.schedule.venues?.find((v) => v.rooms.some((r) => r.id === room?.id)) ||
33+
wcif?.schedule.venues?.[0];
34+
3035
const dateTime = new Date(a.startTime);
3136
return {
3237
approxDateTime: dateTime.getTime(),
33-
date: formatDate(dateTime) || 'foo',
38+
date: dateTime.toLocaleDateString([], {
39+
weekday: 'long',
40+
year: 'numeric',
41+
month: 'numeric',
42+
day: 'numeric',
43+
timeZone: venue?.timezone,
44+
}),
3445
dateParts: formatToParts(dateTime),
3546
};
3647
})
3748
.filter((v, i, arr) => arr.findIndex(({ date }) => date === v.date) === i)
3849
.sort((a, b) => a.approxDateTime - b.approxDateTime);
3950

4051
const activitiesWithParsedDate = activities
41-
.map((a) => ({
42-
...a,
43-
date: formatDate(new Date(a.startTime)),
44-
}))
52+
.map((a) => {
53+
const room = a.room || a.parent?.room;
54+
const venue =
55+
wcif?.schedule.venues?.find((v) => v.rooms.some((r) => r.id === room?.id)) ||
56+
wcif?.schedule.venues?.[0];
57+
58+
const dateTime = new Date(a.startTime);
59+
60+
return {
61+
...a,
62+
date: dateTime.toLocaleDateString([], {
63+
weekday: 'long',
64+
year: 'numeric',
65+
month: 'numeric',
66+
day: 'numeric',
67+
timeZone: venue?.timezone,
68+
}),
69+
};
70+
})
4571
.sort((a, b) => byDate(a, b));
4672

4773
const getActivitiesByDate = useCallback(
@@ -71,9 +97,7 @@ export default function Round() {
7197
const venue = wcif?.schedule?.venues?.find((v) =>
7298
v.rooms.some(
7399
(r) =>
74-
r.id === activity.parent?.parent?.room?.id ||
75-
r.id === activity.parent?.room?.id ||
76-
activity?.room?.id
100+
r.id === activity.parent?.parent?.room?.id || r.id === activity.parent?.room?.id
77101
)
78102
);
79103
const timeZone = venue?.timezone ?? wcif?.schedule.venues?.[0]?.timezone ?? '';

0 commit comments

Comments
 (0)