Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions app/student/miro/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -747,9 +747,12 @@ export default function MiroThonLandingPage() {
const eventStart = useMemo(() => new Date("2026-02-13T18:00:00+08:00"), []); // REAL DATE
const eventEnd = useMemo(() => new Date("2026-02-15T00:00:00+08:00"), []);

const [countdown, setCountdown] = useState<Countdown>(
getCountdown(eventStart),
);
const [countdown, setCountdown] = useState<Countdown>(() => {
const now = new Date().getTime();
const isLive = now >= eventStart.getTime() && now < eventEnd.getTime();
const isPast = now > eventEnd.getTime();
return getCountdown(isPast ? eventStart : isLive ? eventEnd : eventStart);
});

const [isEventLive, setIsEventLive] = useState(() => {
const now = new Date().getTime();
Expand All @@ -768,6 +771,17 @@ export default function MiroThonLandingPage() {
const endAnimationTriggeredRef = useRef(false);

useEffect(() => {
// Immediately calculate correct countdown on first render
const now = new Date().getTime();
const isLive = now >= eventStart.getTime() && now < eventEnd.getTime();
const isPast = now > eventEnd.getTime();
const initialCountdown = getCountdown(
isPast ? eventStart : isLive ? eventEnd : eventStart,
);
setCountdown(initialCountdown);
setIsEventLive(isLive);
setIsEventPast(isPast);

const interval = setInterval(() => {
const now = new Date().getTime();
const isLive = now >= eventStart.getTime() && now < eventEnd.getTime();
Expand Down