Skip to content

Commit cb7340e

Browse files
committed
fix: normalize hackathon countdown target
1 parent 00f8e86 commit cb7340e

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

components/Activity/Hackathon/utility.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,12 @@ export interface CountdownWindow {
128128
endedAt?: TableCellValue;
129129
}
130130

131+
const countdownTextOf = (value?: TableCellValue) => {
132+
const time = timeOf(value);
133+
134+
return Number.isFinite(time) ? new Date(time).toISOString() : undefined;
135+
};
136+
131137
export const resolveCountdownState = <T extends CountdownWindow>(
132138
items: T[],
133139
referenceTime: number,
@@ -146,10 +152,7 @@ export const resolveCountdownState = <T extends CountdownWindow>(
146152
? nextItem?.startedAt
147153
: nextItem?.endedAt;
148154
const fallbackCountdownTarget = timeOf(startTime) > referenceTime ? startTime : endTime;
149-
const countdownTo =
150-
firstTextOf(nextCountdownTarget as TextListLike) ||
151-
firstTextOf(fallbackCountdownTarget as TextListLike) ||
152-
undefined;
155+
const countdownTo = countdownTextOf(nextCountdownTarget) || countdownTextOf(fallbackCountdownTarget);
153156

154157
return { nextItem, countdownTo };
155158
};

0 commit comments

Comments
 (0)