feat: Add isPassedGame logic and update GroupingPrediction component

- Added `dayjs` import for date manipulation in `GamePanel.tsx`.
- Introduced `isPassedGame` memoized value in `GamePanel.tsx` to determine if the game date has passed.
- Updated `GroupingPrediction` component to accept `isPassedGame` prop and adjust `nowScoreGroup` state accordingly.
This commit is contained in:
kyuuseiryuu 2026-03-03 18:11:17 +09:00
parent da35e0f623
commit ac3beb5d8f
2 changed files with 22 additions and 2 deletions

View File

@ -4,6 +4,7 @@ import { Tabs } from "antd";
import { PlayerList } from "./PlayerList";
import { GroupingPrediction } from "./GroupingPrediction";
import { useMemo } from "react";
import dayjs from "dayjs";
interface Props {
title: string;
@ -15,6 +16,14 @@ export const GamePanel: React.FC<Props> = props => {
const sneckMode = useMemo(() => {
return !!props.title?.includes('争霸赛');
}, [props.title]);
const isPassedGame = useMemo(() => {
const match = /(?<year>\d{4})年(?<month>\d{1,2})月(?<day>\d{1,2})/.exec(props.title);
const { year, month, day } = match?.groups ?? {};
const date = dayjs(`${year}-${month}-${day}`);
console.debug('date %s', date.format('YYYY-MM-DD'));
if (!date.isValid()) return true;
return date.isBefore(dayjs());
}, []);
return (
<>
<Tabs
@ -22,7 +31,13 @@ export const GamePanel: React.FC<Props> = props => {
{
key: 'groups',
label: '分组预测',
children: <GroupingPrediction sneckMode={sneckMode} players={props.members} />
children: (
<GroupingPrediction
sneckMode={sneckMode}
isPassedGame={isPassedGame}
players={props.members}
/>
),
},
{
key: 'players',

View File

@ -18,6 +18,7 @@ interface CustomPlayer extends Player {
interface Props {
players?: Player[];
sneckMode: boolean;
isPassedGame: boolean;
}
enum OrderScore {
@ -27,7 +28,11 @@ enum OrderScore {
export const GroupingPrediction: React.FC<Props> = props => {
const [maxPlayerSize, setMaxPlayerSize] = useState(48);
const [nowScoreGroup, setNowScoreGroup] = useState(OrderScore.);
const [nowScoreGroup, setNowScoreGroup] = useState(
props.isPassedGame
? OrderScore.
: OrderScore.
);
const refactoredPlayers = useMemo(() => {
return nowScoreGroup === OrderScore. ? props.players?.map(e => ({
...e,