From 82e7de0250fe5c3d229fc2a5d9615df74507ec74 Mon Sep 17 00:00:00 2001 From: kimjaehyuk Date: Wed, 20 Dec 2023 14:47:14 +0900 Subject: [PATCH 1/3] =?UTF-8?q?[Fix]=20=EB=B2=84=EA=B7=B8=EC=88=98?= =?UTF-8?q?=EC=A0=95=20#1131?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/admin/tournament/TournamentEdit.tsx | 16 ++++------------ .../admin/tournament/TournamentEditMatch.tsx | 11 +++++------ components/admin/tournament/TournamentList.tsx | 14 ++++++++++---- .../admin/tournament/TournamentModalPreview.tsx | 4 +--- components/tournament/TournamentMatch.tsx | 5 ++--- hooks/tournament/useTournamentEditInfo.ts | 13 ++++++++----- .../[tournamentId]/games/dummyTournamentGame.ts | 0 .../games/generateTournamentGames.ts | 0 .../[tournamentId]/games/index.ts | 0 .../[tournamentId]/users/dummyData.ts | 0 .../[tournamentId]/users/index.ts | 0 .../dummyTournamentData.ts | 0 .../{tournament => tournaments}/index.ts | 0 .../tournament/TournamentEditMatch.module.scss | 15 +++++++++++---- styles/tournament/TournamentMatch.module.scss | 7 +++++++ types/admin/adminTournamentTypes.ts | 4 ++-- utils/handleTime.ts | 12 ++++++++++++ utils/handleTournamentGame.ts | 6 +++++- 18 files changed, 67 insertions(+), 40 deletions(-) rename pages/api/pingpong/{tournament => tournaments}/[tournamentId]/games/dummyTournamentGame.ts (100%) rename pages/api/pingpong/{tournament => tournaments}/[tournamentId]/games/generateTournamentGames.ts (100%) rename pages/api/pingpong/{tournament => tournaments}/[tournamentId]/games/index.ts (100%) rename pages/api/pingpong/{tournament => tournaments}/[tournamentId]/users/dummyData.ts (100%) rename pages/api/pingpong/{tournament => tournaments}/[tournamentId]/users/index.ts (100%) rename pages/api/pingpong/{tournament => tournaments}/dummyTournamentData.ts (100%) rename pages/api/pingpong/{tournament => tournaments}/index.ts (100%) diff --git a/components/admin/tournament/TournamentEdit.tsx b/components/admin/tournament/TournamentEdit.tsx index 6982eedb2..76d59228f 100644 --- a/components/admin/tournament/TournamentEdit.tsx +++ b/components/admin/tournament/TournamentEdit.tsx @@ -145,13 +145,8 @@ export default function TournamentEdit({ @@ -159,11 +154,8 @@ export default function TournamentEdit({ diff --git a/components/admin/tournament/TournamentEditMatch.tsx b/components/admin/tournament/TournamentEditMatch.tsx index 946fc9ba8..9658464da 100644 --- a/components/admin/tournament/TournamentEditMatch.tsx +++ b/components/admin/tournament/TournamentEditMatch.tsx @@ -1,3 +1,4 @@ +import Image from 'next/legacy/image'; import { Match, MatchComponentProps, @@ -27,10 +28,9 @@ function TournamentMatchParty({ className={styles.tournamentPartyWrapper} onMouseEnter={() => onMouseEnter(party.id)} > -
{party.name || teamNameFallback}
@@ -87,10 +87,9 @@ function TournamentEditMatchParty({ return (
-
{party.name}
diff --git a/components/admin/tournament/TournamentList.tsx b/components/admin/tournament/TournamentList.tsx index 0d5d2883e..b90337d6f 100644 --- a/components/admin/tournament/TournamentList.tsx +++ b/components/admin/tournament/TournamentList.tsx @@ -20,7 +20,11 @@ import { ITournamentTable, } from 'types/admin/adminTournamentTypes'; import { instance, instanceInManage } from 'utils/axios'; -import { dateToString } from 'utils/handleTime'; +import { + dateToDateTimeLocalString, + dateToString, + dateToStringShort, +} from 'utils/handleTime'; import { modalState } from 'utils/recoil/modal'; import { toastState } from 'utils/recoil/toast'; import { tableFormat } from 'constants/admin/table'; @@ -133,7 +137,7 @@ export default function TournamentList({ > {columnName === 'startTime' || columnName === 'endTime' ? ( - dateToString( + dateToStringShort( new Date( tournament[ columnName as keyof ITournament @@ -153,10 +157,12 @@ export default function TournamentList({ title: tournament.title, contents: tournament.contents, type: tournament.type, - startTime: new Date( + startTime: dateToDateTimeLocalString( tournament.startTime ), - endTime: new Date(tournament.endTime), + endTime: dateToDateTimeLocalString( + tournament.endTime + ), }); scrollToEditor(); }} diff --git a/components/admin/tournament/TournamentModalPreview.tsx b/components/admin/tournament/TournamentModalPreview.tsx index c84bfe62e..e94875cbd 100644 --- a/components/admin/tournament/TournamentModalPreview.tsx +++ b/components/admin/tournament/TournamentModalPreview.tsx @@ -28,9 +28,7 @@ export default function TournamentModalPreview({
{tournamentEditInfo.title}
-
- {dateToString(tournamentEditInfo.startTime)} -
+
{tournamentEditInfo.startTime}
0 / 8
diff --git a/components/tournament/TournamentMatch.tsx b/components/tournament/TournamentMatch.tsx index ad121aa1a..099ac91d2 100644 --- a/components/tournament/TournamentMatch.tsx +++ b/components/tournament/TournamentMatch.tsx @@ -38,10 +38,9 @@ function TournamentMatchParty({ onPartyClick(party, false); }} > -
{party.name || teamNameFallback}
diff --git a/hooks/tournament/useTournamentEditInfo.ts b/hooks/tournament/useTournamentEditInfo.ts index e91605e1f..b74c00eb3 100644 --- a/hooks/tournament/useTournamentEditInfo.ts +++ b/hooks/tournament/useTournamentEditInfo.ts @@ -6,8 +6,8 @@ const emptyTournamentEditInfo: ITournamentEditInfo = { title: '', contents: '', type: 'CUSTOM', - startTime: new Date(), - endTime: new Date(), + startTime: '', + endTime: '', }; function useTournamentEditInfo() { @@ -17,9 +17,12 @@ function useTournamentEditInfo() { // change const inputChangeHandler = (event: React.ChangeEvent) => { const { name, value } = event.target; - if (name === 'startTime' || name === 'endTime') - setTournamentEditInfo((prev) => ({ ...prev, [name]: new Date(value) })); - else setTournamentEditInfo((prev) => ({ ...prev, [name]: value })); + if (name === 'startTime' || name === 'endTime') { + setTournamentEditInfo((prev) => ({ + ...prev, + [name]: value.slice(0, -2) + '00', + })); + } else setTournamentEditInfo((prev) => ({ ...prev, [name]: value })); }; const selectChangeHandler = (event: React.ChangeEvent) => { diff --git a/pages/api/pingpong/tournament/[tournamentId]/games/dummyTournamentGame.ts b/pages/api/pingpong/tournaments/[tournamentId]/games/dummyTournamentGame.ts similarity index 100% rename from pages/api/pingpong/tournament/[tournamentId]/games/dummyTournamentGame.ts rename to pages/api/pingpong/tournaments/[tournamentId]/games/dummyTournamentGame.ts diff --git a/pages/api/pingpong/tournament/[tournamentId]/games/generateTournamentGames.ts b/pages/api/pingpong/tournaments/[tournamentId]/games/generateTournamentGames.ts similarity index 100% rename from pages/api/pingpong/tournament/[tournamentId]/games/generateTournamentGames.ts rename to pages/api/pingpong/tournaments/[tournamentId]/games/generateTournamentGames.ts diff --git a/pages/api/pingpong/tournament/[tournamentId]/games/index.ts b/pages/api/pingpong/tournaments/[tournamentId]/games/index.ts similarity index 100% rename from pages/api/pingpong/tournament/[tournamentId]/games/index.ts rename to pages/api/pingpong/tournaments/[tournamentId]/games/index.ts diff --git a/pages/api/pingpong/tournament/[tournamentId]/users/dummyData.ts b/pages/api/pingpong/tournaments/[tournamentId]/users/dummyData.ts similarity index 100% rename from pages/api/pingpong/tournament/[tournamentId]/users/dummyData.ts rename to pages/api/pingpong/tournaments/[tournamentId]/users/dummyData.ts diff --git a/pages/api/pingpong/tournament/[tournamentId]/users/index.ts b/pages/api/pingpong/tournaments/[tournamentId]/users/index.ts similarity index 100% rename from pages/api/pingpong/tournament/[tournamentId]/users/index.ts rename to pages/api/pingpong/tournaments/[tournamentId]/users/index.ts diff --git a/pages/api/pingpong/tournament/dummyTournamentData.ts b/pages/api/pingpong/tournaments/dummyTournamentData.ts similarity index 100% rename from pages/api/pingpong/tournament/dummyTournamentData.ts rename to pages/api/pingpong/tournaments/dummyTournamentData.ts diff --git a/pages/api/pingpong/tournament/index.ts b/pages/api/pingpong/tournaments/index.ts similarity index 100% rename from pages/api/pingpong/tournament/index.ts rename to pages/api/pingpong/tournaments/index.ts diff --git a/styles/admin/tournament/TournamentEditMatch.module.scss b/styles/admin/tournament/TournamentEditMatch.module.scss index 30b144069..c7b8bace9 100644 --- a/styles/admin/tournament/TournamentEditMatch.module.scss +++ b/styles/admin/tournament/TournamentEditMatch.module.scss @@ -10,6 +10,13 @@ border-radius: 0.6rem; justify-content: space-between; align-items: center; + + .playerImage { + width: 2.5rem; + height: 2.5rem; + border-radius: 100%; + } + .partyName { margin-left: 1rem; } @@ -67,13 +74,13 @@ } .buttonsContainer { - // z-index: 1; - // margin-top: 10px; - // position: absolute; + position: absolute; bottom: 0; + z-index: 1; display: flex; width: 100%; - // padding: 10px; /* 선택적인 여백 추가 */ + padding: 10px; /* 선택적인 여백 추가 */ + margin-top: 10px; background-color: rgba(255, 255, 255, 0.7); /* 반투명한 배경색 */ justify-content: space-around; /* 가로 정렬 */ } diff --git a/styles/tournament/TournamentMatch.module.scss b/styles/tournament/TournamentMatch.module.scss index d3798e251..485fea9b8 100644 --- a/styles/tournament/TournamentMatch.module.scss +++ b/styles/tournament/TournamentMatch.module.scss @@ -10,6 +10,13 @@ border-radius: 0.6rem; justify-content: space-between; align-items: center; + + .playerImage { + width: 2.5rem; + height: 2.5rem; + border-radius: 100%; + } + .partyName { margin-left: 1rem; } diff --git a/types/admin/adminTournamentTypes.ts b/types/admin/adminTournamentTypes.ts index 26465704a..87615ee93 100644 --- a/types/admin/adminTournamentTypes.ts +++ b/types/admin/adminTournamentTypes.ts @@ -29,6 +29,6 @@ export interface ITournamentEditInfo { title: string; contents: string; type: 'CUSTOM' | 'MASTER' | 'ROOKIE' | null; - startTime: Date; - endTime: Date; + startTime: string; + endTime: string; } diff --git a/utils/handleTime.ts b/utils/handleTime.ts index 77e704102..5de305989 100644 --- a/utils/handleTime.ts +++ b/utils/handleTime.ts @@ -126,6 +126,18 @@ export const getFormattedDateToString = ( return { year, month, date, hour, min }; }; +export const dateToDateTimeLocalString = (d: Date) => { + if (!(d instanceof Date)) { + d = new Date(d); + } + + const offset = d.getTimezoneOffset() * 60000; + const dateOffset = new Date(d.getTime() - offset); + + const dateString = dateOffset.toISOString().slice(0, 16); + return dateString; +}; + /** * 시간 문자열에서 hour와 min을 분리하여 반환하는 * @return : number 타입과 string 타입 둘 다 반환 diff --git a/utils/handleTournamentGame.ts b/utils/handleTournamentGame.ts index a2108a0a5..fbd81092d 100644 --- a/utils/handleTournamentGame.ts +++ b/utils/handleTournamentGame.ts @@ -11,7 +11,11 @@ import { TournamentGame } from 'types/tournamentTypes'; export const setModifiabilityFlag = (matches: Match[]) => { matches.forEach((match) => { match.isModifiable = false; - if (match.state === 'WAIT' || match.state === 'END') { + if ( + match.state === 'LIVE' || + match.state === 'WAIT' || + match.state === 'END' + ) { const nextMatch = matches.find( (nextMatch) => match.nextMatchId === nextMatch.id ); From dce3dfe22fca2a403093203b103732a6212768ca Mon Sep 17 00:00:00 2001 From: kimjaehyuk Date: Wed, 20 Dec 2023 18:43:43 +0900 Subject: [PATCH 2/3] =?UTF-8?q?[Fix]=20=EC=8B=9C=EA=B0=84=EB=8C=80=20?= =?UTF-8?q?=EC=95=88=EB=A7=9E=EB=8A=94=20=EB=B2=84=EA=B7=B8=20=EC=88=98?= =?UTF-8?q?=EC=A0=95=20#1131?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/admin/tournament/TournamentEdit.tsx | 13 +++++++++---- .../tournament/TournamentEditMatch.module.scss | 8 ++------ utils/handleTime.ts | 7 +++++++ utils/handleTournamentGame.ts | 2 +- 4 files changed, 19 insertions(+), 11 deletions(-) diff --git a/components/admin/tournament/TournamentEdit.tsx b/components/admin/tournament/TournamentEdit.tsx index 76d59228f..8ca4a2e7d 100644 --- a/components/admin/tournament/TournamentEdit.tsx +++ b/components/admin/tournament/TournamentEdit.tsx @@ -12,6 +12,7 @@ import { import { ITournamentEditInfo } from 'types/admin/adminTournamentTypes'; import { QUILL_EDIT_MODULES, QUILL_FORMATS } from 'types/quillTypes'; import { instanceInManage } from 'utils/axios'; +import { dateToKRIOSString, dateToKRLocaleTimeString } from 'utils/handleTime'; import { toastState } from 'utils/recoil/toast'; import styles from 'styles/admin/tournament/TournamentEdit.module.scss'; import 'react-quill/dist/quill.snow.css'; @@ -71,8 +72,8 @@ export default function TournamentEdit({ const req = { title: tournamentEditInfo.title, contents: tournamentEditInfo.contents, - startTime: tournamentEditInfo.startTime, - endTime: tournamentEditInfo.endTime, + startTime: dateToKRIOSString(new Date(tournamentEditInfo.startTime)), + endTime: dateToKRIOSString(new Date(tournamentEditInfo.endTime)), type: tournamentEditInfo.type, }; await instanceInManage.patch( @@ -97,11 +98,15 @@ export default function TournamentEdit({ const postHandler = async () => { try { + console.log('startTime : ', tournamentEditInfo.startTime); + console.log('endTime : ', tournamentEditInfo.endTime); + console.log('startTime Date : ', new Date(tournamentEditInfo.startTime)); + console.log('endTime Date : ', new Date(tournamentEditInfo.endTime)); await instanceInManage.post(`/tournaments`, { title: tournamentEditInfo.title, contents: tournamentEditInfo.contents, - startTime: tournamentEditInfo.startTime, - endTime: tournamentEditInfo.endTime, + startTime: dateToKRIOSString(new Date(tournamentEditInfo.startTime)), + endTime: dateToKRIOSString(new Date(tournamentEditInfo.endTime)), type: tournamentEditInfo.type, }); setSnackbar({ diff --git a/styles/admin/tournament/TournamentEditMatch.module.scss b/styles/admin/tournament/TournamentEditMatch.module.scss index c7b8bace9..422d7a2b6 100644 --- a/styles/admin/tournament/TournamentEditMatch.module.scss +++ b/styles/admin/tournament/TournamentEditMatch.module.scss @@ -74,13 +74,9 @@ } .buttonsContainer { - position: absolute; bottom: 0; - z-index: 1; display: flex; width: 100%; - padding: 10px; /* 선택적인 여백 추가 */ - margin-top: 10px; - background-color: rgba(255, 255, 255, 0.7); /* 반투명한 배경색 */ - justify-content: space-around; /* 가로 정렬 */ + background-color: rgba(255, 255, 255, 0.7); + justify-content: space-around; } diff --git a/utils/handleTime.ts b/utils/handleTime.ts index 5de305989..cde07ee22 100644 --- a/utils/handleTime.ts +++ b/utils/handleTime.ts @@ -138,6 +138,13 @@ export const dateToDateTimeLocalString = (d: Date) => { return dateString; }; +export const dateToKRIOSString = (d: Date) => { + const offset = d.getTimezoneOffset() * 60000; + const dateOffset = new Date(d.getTime() - offset); + + return dateOffset.toISOString(); +}; + /** * 시간 문자열에서 hour와 min을 분리하여 반환하는 * @return : number 타입과 string 타입 둘 다 반환 diff --git a/utils/handleTournamentGame.ts b/utils/handleTournamentGame.ts index fbd81092d..2ad294338 100644 --- a/utils/handleTournamentGame.ts +++ b/utils/handleTournamentGame.ts @@ -46,7 +46,7 @@ export const addExpectedMatchParticipants = (matches: Match[]) => { if (winner) { const modifiedWinner = { ...winner, - isWinner: true, + isWinner: false, resultText: null, }; matches[i].participants.push(modifiedWinner); From eb5af403e4f33b79aa3d9ae23ad04d4d2ae64548 Mon Sep 17 00:00:00 2001 From: kimjaehyuk Date: Wed, 20 Dec 2023 18:48:45 +0900 Subject: [PATCH 3/3] =?UTF-8?q?[Style]=20=EB=AF=B8=EC=82=AC=EC=9A=A9=20?= =?UTF-8?q?=EB=A9=94=EC=84=9C=EB=93=9C=20=EC=A0=9C=EA=B1=B0=20#1131?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/admin/tournament/TournamentList.tsx | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/components/admin/tournament/TournamentList.tsx b/components/admin/tournament/TournamentList.tsx index b90337d6f..9d90fd911 100644 --- a/components/admin/tournament/TournamentList.tsx +++ b/components/admin/tournament/TournamentList.tsx @@ -20,11 +20,7 @@ import { ITournamentTable, } from 'types/admin/adminTournamentTypes'; import { instance, instanceInManage } from 'utils/axios'; -import { - dateToDateTimeLocalString, - dateToString, - dateToStringShort, -} from 'utils/handleTime'; +import { dateToDateTimeLocalString, dateToStringShort } from 'utils/handleTime'; import { modalState } from 'utils/recoil/modal'; import { toastState } from 'utils/recoil/toast'; import { tableFormat } from 'constants/admin/table';