[fix] 沒滿21分bug
This commit is contained in:
parent
4279c449b5
commit
8f169badee
10
src/Play.tsx
10
src/Play.tsx
@ -49,13 +49,19 @@ export default function Play() {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (data) {
|
if (data) {
|
||||||
const score: number[] = JSON.parse(data.score);
|
const score: number[] = JSON.parse(data.score);
|
||||||
const win: number = score.indexOf(data.winScore);
|
const win: number = score.indexOf(data.winScore) === -1
|
||||||
|
? score.indexOf(score[0] > score[1] ? score[0] : score[1])
|
||||||
|
: score.indexOf(data.winScore);
|
||||||
const team: string[] = JSON.parse(data.team).flat();
|
const team: string[] = JSON.parse(data.team).flat();
|
||||||
const winTeam: string[] = JSON.parse(data.team)[win];
|
const winTeam: string[] = JSON.parse(data.team)[win];
|
||||||
const scoreList: number[] = JSON.parse(data.scoreList);
|
const scoreList: number[] = JSON.parse(data.scoreList);
|
||||||
setTime(dayjs(data.time * 1000).format("YYYY-MM-DD HH:mm:ss"));
|
setTime(dayjs(data.time * 1000).format("YYYY-MM-DD HH:mm:ss"));
|
||||||
setTeam(team);
|
setTeam(team);
|
||||||
setWinTeam(winTeam[0] + "、" + winTeam[1]);
|
if (win === -1) {
|
||||||
|
setWinTeam("不明");
|
||||||
|
} else {
|
||||||
|
setWinTeam(winTeam[0] + "、" + winTeam[1]);
|
||||||
|
}
|
||||||
setScore(score[0] + ":" + score[1]);
|
setScore(score[0] + ":" + score[1]);
|
||||||
setScoreList(scoreList);
|
setScoreList(scoreList);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user