+ {requestClubSummary.loading ? (
+
+ ) : (
+
+
+
+ {info?.name}
+
+
+
+ setIsArticleOpen(false)} placement="bottom">
+
+ {info?.article}
+
+
+
+ )}
+
+ );
+}
\ No newline at end of file
diff --git a/src/components/EventCard.tsx b/src/components/EventCard.tsx
index 03670f1..ebde926 100644
--- a/src/components/EventCard.tsx
+++ b/src/components/EventCard.tsx
@@ -4,8 +4,12 @@ import dayjs from "dayjs";
import utc from 'dayjs/plugin/utc';
import timezone from 'dayjs/plugin/timezone';
import { EyeOutlined } from "@ant-design/icons";
-import { useCallback, useMemo } from "react";
+import { useCallback, useEffect, useMemo, useState } from "react";
import { useNavigate } from "react-router";
+import { useRunOnce } from "../hooks/useRunOnce";
+
+dayjs.extend(utc);
+dayjs.extend(timezone);
interface EventCardProps {
eventInfo: IEventInfo;
@@ -13,20 +17,35 @@ interface EventCardProps {
export function EventCard(props: EventCardProps) {
const { eventInfo: e } = props;
- const day = dayjs(e.startDate);
+ const day = useMemo(() => dayjs.tz(e.startDate, 'Asia/Tokyo'), [e]);
const navigate = useNavigate();
const handleView = useCallback(() => {
navigate(`/event/${e.matchId}`);
}, [e]);
- const messageFormat = useMemo(() => {
+ const [messageFormat, setMessageFormat] = useState('');
+ const getMessageFormat = useCallback(() => {
if (e.isFinished) {
+ if (dayjs().diff(day, 'days') < 1) return `已结束`;
return `已结束 DD 天`;
}
if (e.isProcessing) {
- return '比赛进行中';
+ return '比赛进行中 HH:mm:ss';
}
- return `还有 DD 天 HH 时开始`;
- }, [e]);
+ return `距离比赛开始还有 DD 天 HH:mm:ss`;
+ }, [e, day]);
+ const updateMessageFormat = useCallback(() => {
+ const format = getMessageFormat();
+ setMessageFormat(format);
+ console.debug('format: %s', format);
+ }, [getMessageFormat])
+ useRunOnce(updateMessageFormat);
+ useEffect(() => {
+ const timeout = day.toDate().getTime() - Date.now();
+ const id = setTimeout(() => {
+ updateMessageFormat();
+ }, timeout);
+ return () => clearTimeout(id);
+ }, [updateMessageFormat]);
return (