From 2207fed07eb92fd6b7c535632f75e26ced5c5f0a Mon Sep 17 00:00:00 2001 From: Yusuke Nakamura Date: Wed, 15 May 2024 23:52:36 +0900 Subject: [PATCH 1/9] fix: leaguePage route --- .../sports/[id]/league/page.tsx | 29 +++++++++++++++++++ app/(authenticated)/sports/[id]/page.tsx | 2 +- 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 app/(authenticated)/sports/[id]/league/page.tsx diff --git a/app/(authenticated)/sports/[id]/league/page.tsx b/app/(authenticated)/sports/[id]/league/page.tsx new file mode 100644 index 0000000..78b9f3b --- /dev/null +++ b/app/(authenticated)/sports/[id]/league/page.tsx @@ -0,0 +1,29 @@ +import {Breadcrumbs, Link, Stack, Typography} from "@mui/material"; +import CardBackground from "@/components/layout/cardBackground"; +import LeagueDnd from "@/components/league/leagueDnd"; +import {sportFactory} from "@/src/models/SportModel"; + +export default async function LeagueTestPage({params}: { params: { id: string } }) { + const sportId = parseInt(params.id, 10) + const sport = await sportFactory().show(sportId) + const sportLink = `/sports/${sportId}` + return ( + + + + 管理者のダッシュボード + + + 競技管理 + + + {sport.name} + + リーグを作成・編集 + + + + + + ); +} diff --git a/app/(authenticated)/sports/[id]/page.tsx b/app/(authenticated)/sports/[id]/page.tsx index 468a3bb..d7d7c1c 100644 --- a/app/(authenticated)/sports/[id]/page.tsx +++ b/app/(authenticated)/sports/[id]/page.tsx @@ -27,7 +27,7 @@ export default async function SportPage({params}: { params: { id: string } }) { - + From 11702fbba9b2dea21933e8f7543b45abf3981538 Mon Sep 17 00:00:00 2001 From: Yusuke Nakamura Date: Thu, 16 May 2024 00:12:58 +0900 Subject: [PATCH 2/9] feat: gamePage --- .../sports/[id]/[gameId]/page.tsx | 36 +++++++++++++++++++ app/(authenticated)/sports/[id]/page.tsx | 21 +++++++---- components/sports/leagueList.tsx | 4 ++- 3 files changed, 54 insertions(+), 7 deletions(-) create mode 100644 app/(authenticated)/sports/[id]/[gameId]/page.tsx diff --git a/app/(authenticated)/sports/[id]/[gameId]/page.tsx b/app/(authenticated)/sports/[id]/[gameId]/page.tsx new file mode 100644 index 0000000..a2293b5 --- /dev/null +++ b/app/(authenticated)/sports/[id]/[gameId]/page.tsx @@ -0,0 +1,36 @@ +import CardBackground from "@/components/layout/cardBackground"; +import {Stack, Grid, Link, Typography, Breadcrumbs} from "@mui/material"; +import CardList from "@/components/layout/cardList"; +import {sportFactory} from "@/src/models/SportModel"; +import {gameFactory} from "@/src/models/GameModel"; + +export default async function GamePage({params}: { params: { gameId:string, id: string } }) { + const gameId = parseInt(params.gameId, 10) + const game = await gameFactory().show(gameId) + const sportId = parseInt(params.id, 10) + const sport = await sportFactory().show(sportId) + + return( + + + + 管理者のダッシュボード + + + 競技管理 + + + {sport.name} + + {game.name}(id:{gameId}) + + + + + + + + + + ) +} \ No newline at end of file diff --git a/app/(authenticated)/sports/[id]/page.tsx b/app/(authenticated)/sports/[id]/page.tsx index d7d7c1c..2ab5422 100644 --- a/app/(authenticated)/sports/[id]/page.tsx +++ b/app/(authenticated)/sports/[id]/page.tsx @@ -1,6 +1,5 @@ import CardBackground from "@/components/layout/cardBackground"; import {Stack, Grid, Link, Typography, Breadcrumbs} from "@mui/material"; -import {ButtonLarge} from "@/components/layout/buttonLarge"; import CardList from "@/components/layout/cardList"; import {sportFactory} from "@/src/models/SportModel"; import SportEditor from "@/components/sports/sportEditor"; @@ -12,6 +11,7 @@ export default async function SportPage({params}: { params: { id: string } }) { const sport = await sportFactory().show(sportId) const games = await gameFactory().index() const filteredGames = games.filter((game) => game.sportId == sportId) + const gameType = filteredGames.find(game => game)?.type; return( @@ -27,11 +27,20 @@ export default async function SportPage({params}: { params: { id: string } }) { - - - - - + {gameType === "league" && ( + + + + + + )} + {gameType === "tournament" && ( + + + + + + )} diff --git a/components/sports/leagueList.tsx b/components/sports/leagueList.tsx index bb27b74..298fd11 100644 --- a/components/sports/leagueList.tsx +++ b/components/sports/leagueList.tsx @@ -3,9 +3,11 @@ import {Game} from "@/src/models/GameModel"; export type LeagueListProps = { games: Game[] + sportId: number } export default function LeagueList(props: LeagueListProps) { + const sportId = props.sportId return ( @@ -14,7 +16,7 @@ export default function LeagueList(props: LeagueListProps) { {game.name} From 2e4e10ddc6fb6f729efa28c603d77843fe212032 Mon Sep 17 00:00:00 2001 From: Yusuke Nakamura Date: Thu, 16 May 2024 16:21:10 +0900 Subject: [PATCH 3/9] fix: card titles --- app/(authenticated)/page.tsx | 12 +++--- .../sports/[id]/[gameId]/[matchId]/page.tsx | 39 +++++++++++++++++++ .../sports/[id]/[gameId]/page.tsx | 2 +- .../sports/[id]/league/page.tsx | 2 +- app/(authenticated)/sports/[id]/page.tsx | 2 +- components/sports/sportEditor.tsx | 2 +- 6 files changed, 49 insertions(+), 10 deletions(-) create mode 100644 app/(authenticated)/sports/[id]/[gameId]/[matchId]/page.tsx diff --git a/app/(authenticated)/page.tsx b/app/(authenticated)/page.tsx index 559ba9d..204f1e0 100644 --- a/app/(authenticated)/page.tsx +++ b/app/(authenticated)/page.tsx @@ -12,17 +12,17 @@ export default async function Home() { 管理者のダッシュボード - - - - - この機能は開発中です - + + + + + + + + + 管理者のダッシュボード + + + 競技管理 + + + {sport.name} + + {game.name}(id:{gameId}) + + + + + + + + + + ) +} \ No newline at end of file diff --git a/app/(authenticated)/sports/[id]/[gameId]/page.tsx b/app/(authenticated)/sports/[id]/[gameId]/page.tsx index a2293b5..dca5e6a 100644 --- a/app/(authenticated)/sports/[id]/[gameId]/page.tsx +++ b/app/(authenticated)/sports/[id]/[gameId]/page.tsx @@ -26,7 +26,7 @@ export default async function GamePage({params}: { params: { gameId:string, id: - + diff --git a/app/(authenticated)/sports/[id]/league/page.tsx b/app/(authenticated)/sports/[id]/league/page.tsx index 78b9f3b..f82375b 100644 --- a/app/(authenticated)/sports/[id]/league/page.tsx +++ b/app/(authenticated)/sports/[id]/league/page.tsx @@ -3,7 +3,7 @@ import CardBackground from "@/components/layout/cardBackground"; import LeagueDnd from "@/components/league/leagueDnd"; import {sportFactory} from "@/src/models/SportModel"; -export default async function LeagueTestPage({params}: { params: { id: string } }) { +export default async function LeaguePage({params}: { params: { id: string } }) { const sportId = parseInt(params.id, 10) const sport = await sportFactory().show(sportId) const sportLink = `/sports/${sportId}` diff --git a/app/(authenticated)/sports/[id]/page.tsx b/app/(authenticated)/sports/[id]/page.tsx index 2ab5422..3b8abc2 100644 --- a/app/(authenticated)/sports/[id]/page.tsx +++ b/app/(authenticated)/sports/[id]/page.tsx @@ -41,7 +41,7 @@ export default async function SportPage({params}: { params: { id: string } }) { )} - + diff --git a/components/sports/sportEditor.tsx b/components/sports/sportEditor.tsx index 1386b7e..efce5ae 100644 --- a/components/sports/sportEditor.tsx +++ b/components/sports/sportEditor.tsx @@ -67,7 +67,7 @@ export default function SportEditor(props: SportEditorProps) { <> - 競技の情報 + 競技を編集する Date: Fri, 17 May 2024 19:44:40 +0900 Subject: [PATCH 4/9] feat: matchEditor --- .../sports/[id]/[gameId]/[matchId]/page.tsx | 22 +- .../sports/[id]/[gameId]/page.tsx | 2 +- app/(authenticated)/sports/[id]/page.tsx | 6 +- components/match/matchEditor.tsx | 378 ++++++++++++++++++ 4 files changed, 392 insertions(+), 16 deletions(-) create mode 100644 components/match/matchEditor.tsx diff --git a/app/(authenticated)/sports/[id]/[gameId]/[matchId]/page.tsx b/app/(authenticated)/sports/[id]/[gameId]/[matchId]/page.tsx index a4af50c..0a61507 100644 --- a/app/(authenticated)/sports/[id]/[gameId]/[matchId]/page.tsx +++ b/app/(authenticated)/sports/[id]/[gameId]/[matchId]/page.tsx @@ -1,9 +1,8 @@ -import CardBackground from "@/components/layout/cardBackground"; -import {Stack, Grid, Link, Typography, Breadcrumbs} from "@mui/material"; -import CardList from "@/components/layout/cardList"; +import {Stack, Link, Typography, Breadcrumbs} from "@mui/material"; import {sportFactory} from "@/src/models/SportModel"; import {gameFactory} from "@/src/models/GameModel"; import {matchFactory} from "@/src/models/MatchModel"; +import MatchEditor from "@/components/match/matchEditor"; export default async function MatchPage({params}: { params: { matchId:string, gameId:string, id: string } }) { const matchId = parseInt(params.matchId, 10) @@ -19,21 +18,20 @@ export default async function MatchPage({params}: { params: { matchId:string, ga 管理者のダッシュボード - + 競技管理 {sport.name} - {game.name}(id:{gameId}) + + {game.name}(ID:{gameId}) + + 試合(ID:{match.id}) - - - - - - - + + + ) } \ No newline at end of file diff --git a/app/(authenticated)/sports/[id]/[gameId]/page.tsx b/app/(authenticated)/sports/[id]/[gameId]/page.tsx index dca5e6a..a0415de 100644 --- a/app/(authenticated)/sports/[id]/[gameId]/page.tsx +++ b/app/(authenticated)/sports/[id]/[gameId]/page.tsx @@ -22,7 +22,7 @@ export default async function GamePage({params}: { params: { gameId:string, id: {sport.name} - {game.name}(id:{gameId}) + {game.name}(ID:{gameId}) diff --git a/app/(authenticated)/sports/[id]/page.tsx b/app/(authenticated)/sports/[id]/page.tsx index 3b8abc2..bc57aec 100644 --- a/app/(authenticated)/sports/[id]/page.tsx +++ b/app/(authenticated)/sports/[id]/page.tsx @@ -24,9 +24,6 @@ export default async function SportPage({params}: { params: { id: string } }) { {sport.name} - - - {gameType === "league" && ( @@ -41,6 +38,9 @@ export default async function SportPage({params}: { params: { id: string } }) { )} + + + diff --git a/components/match/matchEditor.tsx b/components/match/matchEditor.tsx new file mode 100644 index 0000000..a9aa5d4 --- /dev/null +++ b/components/match/matchEditor.tsx @@ -0,0 +1,378 @@ +'use client' +import React, {useRef} from "react"; +import {useAsync} from "react-use"; +import {useRouter} from "next/navigation"; +import { + Accordion, + AccordionDetails, + AccordionSummary, + Alert, + Button, + Card, Divider, FormControl, + InputLabel, + MenuItem, + Select, + Snackbar, + Stack, + TextField, + TextFieldProps, + Typography, + ToggleButton, + ToggleButtonGroup +} from "@mui/material"; +import CardBackground from "@/components/layout/cardBackground"; +import {HiCheck, HiChevronDown, HiArrowPath} from "react-icons/hi2"; + +import {Sport} from "@/src/models/SportModel"; +import {Game} from "@/src/models/GameModel"; +import {Match, matchFactory, MatchResult, MatchStatus} from "@/src/models/MatchModel"; +import {Team, teamFactory} from "@/src/models/TeamModel"; +import {Location, locationFactory} from "@/src/models/LocationModel"; +import Loading from "@/app/(authenticated)/loading"; + +export type MatchEditorProps = { + sport: Sport + game: Game + match: Match +} + +export default function MatchEditor(props: MatchEditorProps) { + const router = useRouter() + const useState = React.useState; + + const teamUndefined = { + id: 0, + name: "取得中", + description: "取得中", + classId: 0, + teamTagId: 0, + userIds: [], + enteredGameIds: [], + createdAt: "0", + updatedAt: "0" + }; + + // state + const [isFetching, setIsFetching] = useState(true) + const [leftTeam, setLeftTeam] = useState(teamUndefined); + const [rightTeam, setRightTeam] = useState(teamUndefined); + const [judgeTeam, setJudgeTeam] = useState(teamUndefined); + const [matchResult, setMatchResult] = useState(props.match.result); + const [matchStatus, setMatchStatus] = useState(props.match.status); + const [locations, setLocations] = useState([]); + const [locationId, setLocationId] = useState(props.match.locationId); + const [teams, setTeams] = useState([]); + const [judgeTeamId, setJudgeTeamId] = useState(props.match.judgeTeamId); + const [snackOpen, setSnackOpen] = React.useState(false) + const leftRef = useRef(null) + const rightRef = useRef(null) + const noteRef = useRef(null) + + + // fetch data + useAsync(async () => { + const fetchMatchEditor = async () => { + const left = await teamFactory().show(Number(props.match.leftTeamId)); + const right = await teamFactory().show(Number(props.match.rightTeamId)); + const judge = await teamFactory().show(Number(props.match.judgeTeamId)); + const location = await locationFactory().index(); + const teams = await teamFactory().index(); + setLeftTeam(left); + setRightTeam(right); + setJudgeTeam(judge); + setLocations(location); + setTeams(teams); + setIsFetching(false); + }; + + return fetchMatchEditor(); + }) + + // reformat data + const locationName = locations.find(location => location.id === props.match.locationId)?.name; + const date = new Date(props.match.startAt); + const formattedDate = `${date.getMonth() + 1}月${date.getDate()}日 ${date.getHours()}時${date.getMinutes() < 10 ? '0' : ''}${date.getMinutes()}分`; + + // handler + const handleSnackClose = () => { + setSnackOpen(false) + } + const handleResultChange = ( + event: React.MouseEvent, + newResult: string, + ) => { + setMatchResult(newResult as MatchResult); + }; + const handleStatusChange = ( + event: React.MouseEvent, + newStatus: string, + ) => { + setMatchStatus(newStatus as MatchStatus); + }; + + // cancel + const handleCancel = () => { + setMatchResult(props.match.result) + setMatchStatus(props.match.status) + setLocationId(props.match.locationId) + setJudgeTeamId(props.match.judgeTeamId) + noteRef.current!.value = props.match.note + leftRef.current!.value = props.match.leftScore + rightRef.current!.value = props.match.rightScore + } + + // update data + const handleUpdate = async () => { + await matchFactory().update(props.match.id,{ + locationId: locationId, + gameId: props.match.gameId, + sportId: props.match.sportId, + startAt: props.match.startAt, + leftTeamId: props.match.leftTeamId, + rightTeamId: props.match.rightTeamId, + leftScore: leftRef.current?.value as number, + rightScore: rightRef.current?.value as number, + result: matchResult, + status: matchStatus, + note: noteRef.current?.value as string, + judgeTeamId: judgeTeamId + }) + + router.refresh() + setSnackOpen(true) + } + + if (isFetching) { + return ( + + ) + } else { + return ( + + + + + 結果を登録 + + + 審判:{judgeTeam.name} + 試合場所:{locationName} + 試合開始:{formattedDate} + + + + + + + {leftTeam.name}のスコア + + + + VS + + + {rightTeam.name}のスコア + + + + + + + + + 結果 + + {leftTeam.name} + 引き分け + {rightTeam.name} + + + + 試合の状態 + + 中止 + スタンバイ + 進行中 + 完了 + + + + + + + + + + + + + + + } + aria-controls="panel-content" + id="panel-header" + > + 編集する + + + + + 補足 + + + 審判 + + 審判 + + + + 試合の場所 + + 場所 + + + + + + + + + + + + + + 変更が保存されました + + + + ) + } +} \ No newline at end of file From 512f0f9a4fba42f0048de9638825be518cb0ac1b Mon Sep 17 00:00:00 2001 From: Yusuke Nakamura Date: Fri, 17 May 2024 21:51:38 +0900 Subject: [PATCH 5/9] fix: removed unused routes --- app/(authenticated)/league/[id]/page.tsx | 25 ------------------------ app/(authenticated)/league/page.tsx | 24 ----------------------- components/league/leagueSportsList.tsx | 23 ---------------------- 3 files changed, 72 deletions(-) delete mode 100644 app/(authenticated)/league/[id]/page.tsx delete mode 100644 app/(authenticated)/league/page.tsx delete mode 100644 components/league/leagueSportsList.tsx diff --git a/app/(authenticated)/league/[id]/page.tsx b/app/(authenticated)/league/[id]/page.tsx deleted file mode 100644 index 4347fa5..0000000 --- a/app/(authenticated)/league/[id]/page.tsx +++ /dev/null @@ -1,25 +0,0 @@ -import {Breadcrumbs, Link, Stack, Typography} from "@mui/material"; -import CardBackground from "@/components/layout/cardBackground"; -import LeagueDnd from "@/components/league/leagueDnd"; -import {sportFactory} from "@/src/models/SportModel"; - -export default async function LeagueTestPage({params}: { params: { id: string } }) { - const sportId = parseInt(params.id, 10) - const sport = await sportFactory().show(sportId) - return ( - - - - 管理者のダッシュボード - - - リーグ管理 - - {sport.name} - - - - - - ); -} diff --git a/app/(authenticated)/league/page.tsx b/app/(authenticated)/league/page.tsx deleted file mode 100644 index f39e61e..0000000 --- a/app/(authenticated)/league/page.tsx +++ /dev/null @@ -1,24 +0,0 @@ -import {Stack, Grid, Typography, Link, Breadcrumbs} from "@mui/material"; -import CardBackground from "@/components/layout/cardBackground"; -import {sportFactory} from "@/src/models/SportModel"; -import LeagueSportsList from "@/components/league/leagueSportsList"; - - -export default async function LeaguePage() { - const sports = await sportFactory().index() - return ( - - - - 管理者のダッシュボード - - リーグ管理 - - - - - - - - ); -} diff --git a/components/league/leagueSportsList.tsx b/components/league/leagueSportsList.tsx deleted file mode 100644 index 0e180f7..0000000 --- a/components/league/leagueSportsList.tsx +++ /dev/null @@ -1,23 +0,0 @@ -import {ButtonLarge} from "@/components/layout/buttonLarge"; -import {Sport} from "@/src/models/SportModel"; - -export type SportsListProps = { - sports: Sport[] -} - -export default function LeagueSportsList(props: SportsListProps) { - props.sports.sort((a, b) => b.weight - a.weight); - return ( - <> - {props.sports.map((sport) => ( - - {sport.name} - - ))} - - ) -} \ No newline at end of file From 41ba895bfe3fda2c200db8a29877314c6d738fac Mon Sep 17 00:00:00 2001 From: Yusuke Nakamura Date: Fri, 17 May 2024 21:51:57 +0900 Subject: [PATCH 6/9] fix: matchEditor input error hundle --- app/(authenticated)/locations/page.tsx | 2 +- components/layout/navigation.tsx | 65 +++------ components/match/matchEditor.tsx | 178 ++++++++++++++++++++----- 3 files changed, 164 insertions(+), 81 deletions(-) diff --git a/app/(authenticated)/locations/page.tsx b/app/(authenticated)/locations/page.tsx index e8973bb..1ff6e70 100644 --- a/app/(authenticated)/locations/page.tsx +++ b/app/(authenticated)/locations/page.tsx @@ -12,7 +12,7 @@ export default function LocationPage() { 場所管理 - none + この機能は開発中です。 ) diff --git a/components/layout/navigation.tsx b/components/layout/navigation.tsx index 9674d2b..eee4a79 100644 --- a/components/layout/navigation.tsx +++ b/components/layout/navigation.tsx @@ -101,107 +101,78 @@ export const Navigation = () => { - ユーザー + スポーツ - - 競技 + 情報 - - - - - 編成 + diff --git a/components/match/matchEditor.tsx b/components/match/matchEditor.tsx index a9aa5d4..5e9db00 100644 --- a/components/match/matchEditor.tsx +++ b/components/match/matchEditor.tsx @@ -1,5 +1,5 @@ 'use client' -import React, {useRef} from "react"; +import React, {useRef, useEffect} from "react"; import {useAsync} from "react-use"; import {useRouter} from "next/navigation"; import { @@ -18,10 +18,10 @@ import { TextFieldProps, Typography, ToggleButton, - ToggleButtonGroup + ToggleButtonGroup, Chip, SvgIcon, Avatar } from "@mui/material"; import CardBackground from "@/components/layout/cardBackground"; -import {HiCheck, HiChevronDown, HiArrowPath} from "react-icons/hi2"; +import {HiCheck, HiChevronDown, HiArrowPath, HiArrowUturnLeft, HiFlag, HiMapPin, HiClock} from "react-icons/hi2"; import {Sport} from "@/src/models/SportModel"; import {Game} from "@/src/models/GameModel"; @@ -29,6 +29,7 @@ import {Match, matchFactory, MatchResult, MatchStatus} from "@/src/models/MatchM import {Team, teamFactory} from "@/src/models/TeamModel"; import {Location, locationFactory} from "@/src/models/LocationModel"; import Loading from "@/app/(authenticated)/loading"; +import Link from "next/link"; export type MatchEditorProps = { sport: Sport @@ -63,7 +64,9 @@ export default function MatchEditor(props: MatchEditorProps) { const [locationId, setLocationId] = useState(props.match.locationId); const [teams, setTeams] = useState([]); const [judgeTeamId, setJudgeTeamId] = useState(props.match.judgeTeamId); - const [snackOpen, setSnackOpen] = React.useState(false) + const [updateSnackOpen, setUpdateSnackOpen] = React.useState(false) + const [cancelSnackOpen, setCancelSnackOpen] = React.useState(false) + const [scoreError, setScoreError] = useState(false); const leftRef = useRef(null) const rightRef = useRef(null) const noteRef = useRef(null) @@ -94,8 +97,11 @@ export default function MatchEditor(props: MatchEditorProps) { const formattedDate = `${date.getMonth() + 1}月${date.getDate()}日 ${date.getHours()}時${date.getMinutes() < 10 ? '0' : ''}${date.getMinutes()}分`; // handler - const handleSnackClose = () => { - setSnackOpen(false) + const handleUpdateSnackClose = () => { + setUpdateSnackOpen(false) + } + const handleCancelSnackClose = () => { + setCancelSnackOpen(false) } const handleResultChange = ( event: React.MouseEvent, @@ -109,6 +115,25 @@ export default function MatchEditor(props: MatchEditorProps) { ) => { setMatchStatus(newStatus as MatchStatus); }; + const handleCompare = () => { + const leftScore = Number(leftRef.current?.value); + const rightScore = Number(rightRef.current?.value); + + if (leftScore !== 0 || rightScore !== 0) { + setMatchStatus('finished'); + } else { + setMatchStatus('standby'); + } + + if (leftScore > rightScore) { + setMatchResult('left_win'); + } else if (leftScore < rightScore) { + setMatchResult('right_win'); + } else { + setMatchResult('draw'); + } + setScoreError(false) + } // cancel const handleCancel = () => { @@ -119,10 +144,22 @@ export default function MatchEditor(props: MatchEditorProps) { noteRef.current!.value = props.match.note leftRef.current!.value = props.match.leftScore rightRef.current!.value = props.match.rightScore + setCancelSnackOpen(true) } // update data const handleUpdate = async () => { + const leftScoreValue = leftRef.current?.value; + const rightScoreValue = rightRef.current?.value; + + if (!leftScoreValue || !rightScoreValue || isNaN(Number(leftScoreValue)) || isNaN(Number(rightScoreValue || Number(leftScoreValue) < 0 || Number(rightScoreValue) < 0 ))){ + setScoreError(true); + return; + } + + const leftScore = Number(leftScoreValue); + const rightScore = Number(rightScoreValue); + await matchFactory().update(props.match.id,{ locationId: locationId, gameId: props.match.gameId, @@ -130,8 +167,8 @@ export default function MatchEditor(props: MatchEditorProps) { startAt: props.match.startAt, leftTeamId: props.match.leftTeamId, rightTeamId: props.match.rightTeamId, - leftScore: leftRef.current?.value as number, - rightScore: rightRef.current?.value as number, + leftScore: leftScore, + rightScore: rightScore, result: matchResult, status: matchStatus, note: noteRef.current?.value as string, @@ -139,7 +176,8 @@ export default function MatchEditor(props: MatchEditorProps) { }) router.refresh() - setSnackOpen(true) + setUpdateSnackOpen(true) + setScoreError(false) } if (isFetching) { @@ -149,45 +187,72 @@ export default function MatchEditor(props: MatchEditorProps) { } else { return ( - + 結果を登録 - 審判:{judgeTeam.name} - 試合場所:{locationName} - 試合開始:{formattedDate} + } color={"primary"} + /> + } color={"primary"} + /> + } color={"primary"} + /> - + {leftTeam.name}のスコア VS - + {rightTeam.name}のスコア @@ -196,7 +261,7 @@ export default function MatchEditor(props: MatchEditorProps) { - 結果 + 勝ったのは - {leftTeam.name} + {leftTeam.name} 引き分け - {rightTeam.name} + {rightTeam.name} @@ -220,10 +285,10 @@ export default function MatchEditor(props: MatchEditorProps) { onChange={handleStatusChange} aria-label="Platform" > - 中止 - スタンバイ - 進行中 - 完了 + 中止 + スタンバイ + 進行中 + 完了 @@ -239,7 +304,7 @@ export default function MatchEditor(props: MatchEditorProps) { > + + + + + + + + + + + 変更を元に戻しました + + + From 57529ce381075310113e3d665d6e293aa82b2a27 Mon Sep 17 00:00:00 2001 From: Yusuke Nakamura Date: Fri, 17 May 2024 22:11:36 +0900 Subject: [PATCH 7/9] fix: matchEditor information appearance --- components/match/matchEditor.tsx | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/components/match/matchEditor.tsx b/components/match/matchEditor.tsx index 5e9db00..8033b27 100644 --- a/components/match/matchEditor.tsx +++ b/components/match/matchEditor.tsx @@ -187,23 +187,22 @@ export default function MatchEditor(props: MatchEditorProps) { } else { return ( - + - 結果を登録 } color={"primary"} + avatar={} color={"secondary"} /> } color={"primary"} + avatar={} color={"secondary"} /> } color={"primary"} + avatar={} color={"secondary"} /> From e8b661e7ed4caffc146d05fd2c29371393073a2e Mon Sep 17 00:00:00 2001 From: Yusuke Nakamura Date: Fri, 17 May 2024 22:14:29 +0900 Subject: [PATCH 8/9] fix: reformat codes --- app/(authenticated)/locations/page.tsx | 1 - .../sports/[id]/[gameId]/page.tsx | 2 +- .../sports/[id]/league/page.tsx | 2 +- components/layout/navigation.tsx | 2 - components/match/matchEditor.tsx | 210 +++++++++--------- 5 files changed, 112 insertions(+), 105 deletions(-) diff --git a/app/(authenticated)/locations/page.tsx b/app/(authenticated)/locations/page.tsx index 1ff6e70..10f93c6 100644 --- a/app/(authenticated)/locations/page.tsx +++ b/app/(authenticated)/locations/page.tsx @@ -1,6 +1,5 @@ import {Breadcrumbs, Link, Stack, Typography} from "@mui/material"; import CardBackground from "@/components/layout/cardBackground"; -import TeamsAgGrid from "@/components/teams/teamsTable"; export default function LocationPage() { return ( diff --git a/app/(authenticated)/sports/[id]/[gameId]/page.tsx b/app/(authenticated)/sports/[id]/[gameId]/page.tsx index a0415de..bde3291 100644 --- a/app/(authenticated)/sports/[id]/[gameId]/page.tsx +++ b/app/(authenticated)/sports/[id]/[gameId]/page.tsx @@ -16,7 +16,7 @@ export default async function GamePage({params}: { params: { gameId:string, id: 管理者のダッシュボード - + 競技管理 diff --git a/app/(authenticated)/sports/[id]/league/page.tsx b/app/(authenticated)/sports/[id]/league/page.tsx index f82375b..2806e9e 100644 --- a/app/(authenticated)/sports/[id]/league/page.tsx +++ b/app/(authenticated)/sports/[id]/league/page.tsx @@ -13,7 +13,7 @@ export default async function LeaguePage({params}: { params: { id: string } }) { 管理者のダッシュボード - + 競技管理 diff --git a/components/layout/navigation.tsx b/components/layout/navigation.tsx index eee4a79..0b9ca9f 100644 --- a/components/layout/navigation.tsx +++ b/components/layout/navigation.tsx @@ -8,8 +8,6 @@ import { HiMiniNewspaper, HiUser, HiUserGroup, - HiTableCells, - HiRectangleGroup, HiTrophy, HiMapPin, HiIdentification } from "react-icons/hi2"; diff --git a/components/match/matchEditor.tsx b/components/match/matchEditor.tsx index 8033b27..daa9197 100644 --- a/components/match/matchEditor.tsx +++ b/components/match/matchEditor.tsx @@ -1,5 +1,5 @@ 'use client' -import React, {useRef, useEffect} from "react"; +import React, {useRef} from "react"; import {useAsync} from "react-use"; import {useRouter} from "next/navigation"; import { @@ -21,7 +21,7 @@ import { ToggleButtonGroup, Chip, SvgIcon, Avatar } from "@mui/material"; import CardBackground from "@/components/layout/cardBackground"; -import {HiCheck, HiChevronDown, HiArrowPath, HiArrowUturnLeft, HiFlag, HiMapPin, HiClock} from "react-icons/hi2"; +import {HiCheck, HiChevronDown, HiArrowPath, HiFlag, HiMapPin, HiClock} from "react-icons/hi2"; import {Sport} from "@/src/models/SportModel"; import {Game} from "@/src/models/GameModel"; @@ -152,7 +152,7 @@ export default function MatchEditor(props: MatchEditorProps) { const leftScoreValue = leftRef.current?.value; const rightScoreValue = rightRef.current?.value; - if (!leftScoreValue || !rightScoreValue || isNaN(Number(leftScoreValue)) || isNaN(Number(rightScoreValue || Number(leftScoreValue) < 0 || Number(rightScoreValue) < 0 ))){ + if (!leftScoreValue || !rightScoreValue || isNaN(Number(leftScoreValue)) || isNaN(Number(rightScoreValue || Number(leftScoreValue) < 0 || Number(rightScoreValue) < 0))) { setScoreError(true); return; } @@ -160,7 +160,7 @@ export default function MatchEditor(props: MatchEditorProps) { const leftScore = Number(leftScoreValue); const rightScore = Number(rightScoreValue); - await matchFactory().update(props.match.id,{ + await matchFactory().update(props.match.id, { locationId: locationId, gameId: props.match.gameId, sportId: props.match.sportId, @@ -187,8 +187,10 @@ export default function MatchEditor(props: MatchEditorProps) { } else { return ( - - + + @@ -208,12 +210,13 @@ export default function MatchEditor(props: MatchEditorProps) { - + {leftTeam.name}のスコア @@ -258,7 +261,8 @@ export default function MatchEditor(props: MatchEditorProps) { - + 勝ったのは } + sx={{py: 1.5}} + startIcon={} onClick={handleCancel} > 元に戻す @@ -313,8 +317,8 @@ export default function MatchEditor(props: MatchEditorProps) { + - - + すべて保存 + + @@ -425,13 +435,13 @@ export default function MatchEditor(props: MatchEditorProps) { open={updateSnackOpen} autoHideDuration={8000} onClose={handleUpdateSnackClose} - anchorOrigin={{ vertical: 'bottom', horizontal: 'right' }} + anchorOrigin={{vertical: 'bottom', horizontal: 'right'}} > @@ -445,7 +455,7 @@ export default function MatchEditor(props: MatchEditorProps) { color={"info"} component={Link} href={`/sports/${props.sport.id}/${props.game.id}`} - sx={{border: "1px solid #5f6dc2", py:2}} + sx={{border: "1px solid #5f6dc2", py: 2}} > リーグに戻る @@ -456,13 +466,13 @@ export default function MatchEditor(props: MatchEditorProps) { open={cancelSnackOpen} autoHideDuration={8000} onClose={handleCancelSnackClose} - anchorOrigin={{ vertical: 'bottom', horizontal: 'right' }} + anchorOrigin={{vertical: 'bottom', horizontal: 'right'}} > @@ -476,7 +486,7 @@ export default function MatchEditor(props: MatchEditorProps) { color={"info"} component={Link} href={`/sports/${props.sport.id}/${props.game.id}`} - sx={{border: "1px solid #5f6dc2", py:2}} + sx={{border: "1px solid #5f6dc2", py: 2}} > リーグに戻る From 0bafce9a5bd54c1f4b94585b2e768988a5de52a5 Mon Sep 17 00:00:00 2001 From: Yusuke Nakamura Date: Fri, 17 May 2024 22:16:58 +0900 Subject: [PATCH 9/9] fix: change tournament route --- .../[id] => sports/[id]/tournament}/page.tsx | 0 app/(authenticated)/tournament/page.tsx | 24 ------------------- 2 files changed, 24 deletions(-) rename app/(authenticated)/{tournament/[id] => sports/[id]/tournament}/page.tsx (100%) delete mode 100644 app/(authenticated)/tournament/page.tsx diff --git a/app/(authenticated)/tournament/[id]/page.tsx b/app/(authenticated)/sports/[id]/tournament/page.tsx similarity index 100% rename from app/(authenticated)/tournament/[id]/page.tsx rename to app/(authenticated)/sports/[id]/tournament/page.tsx diff --git a/app/(authenticated)/tournament/page.tsx b/app/(authenticated)/tournament/page.tsx deleted file mode 100644 index 98e6c58..0000000 --- a/app/(authenticated)/tournament/page.tsx +++ /dev/null @@ -1,24 +0,0 @@ -import {Stack, Grid, Typography, Link, Breadcrumbs} from "@mui/material"; -import CardBackground from "@/components/layout/cardBackground"; -import CardLarge from "@/components/layout/cardLarge"; -import {ButtonLarge} from "@/components/layout/buttonLarge"; - -export default function LeaguePage() { - return ( - - - - 管理者のダッシュボード - - トーナメント管理 - - - - - フットサル - - - - - ); -}