Skip to content

Commit

Permalink
Merge pull request #1136 from 42organization/feat/관리자-토너먼트-페이지-api-연동-#…
Browse files Browse the repository at this point in the history
…1131

Feat/관리자 토너먼트 페이지 api 연동 #1131
  • Loading branch information
greatSweetMango authored Dec 7, 2023
2 parents d288a71 + 0923060 commit fb3b520
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 36 deletions.
23 changes: 12 additions & 11 deletions components/admin/tournament/TournamentEdit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,16 @@ export default function TournamentEdit({

const patchHandler = async () => {
try {
const req = {
title: tournamentEditInfo.title,
contents: tournamentEditInfo.contents,
startTime: tournamentEditInfo.startTime,
endTime: tournamentEditInfo.endTime,
type: tournamentEditInfo.type,
};
await instanceInManage.patch(
`/tournament/${tournamentEditInfo.tournamentId}`,
{
title: tournamentEditInfo.title,
contents: tournamentEditInfo.contents,
startTime: tournamentEditInfo.startTime,
endTime: tournamentEditInfo.endTime,
type: tournamentEditInfo.type,
}
`/tournaments/${tournamentEditInfo.tournamentId}`,
req
);
setSnackbar({
toastName: `patch request`,
Expand All @@ -89,15 +90,15 @@ export default function TournamentEdit({
setSnackbar({
toastName: `bad request`,
severity: 'error',
// message: `🔥 ${announceCreateResponse[e.response.data.code]} 🔥`,
message: `🔥 ${e.response.data.message} 🔥`,
clicked: true,
});
}
};

const postHandler = async () => {
try {
await instanceInManage.post(`/tournament`, {
await instanceInManage.post(`/tournaments`, {
title: tournamentEditInfo.title,
contents: tournamentEditInfo.contents,
startTime: tournamentEditInfo.startTime,
Expand All @@ -114,7 +115,7 @@ export default function TournamentEdit({
setSnackbar({
toastName: `bad request`,
severity: 'error',
// message: `🔥 ${announceCreateResponse[e.response.data.code]} 🔥`,
message: `🔥 ${e.response.data.message} 🔥`,
clicked: true,
});
}
Expand Down
53 changes: 29 additions & 24 deletions components/admin/tournament/TournamentList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@ import {
ITournamentEditInfo,
ITournamentTable,
} from 'types/admin/adminTournamentTypes';
import { instanceInManage } from 'utils/axios';
import { instance, instanceInManage } from 'utils/axios';
import { dateToString } from 'utils/handleTime';
import { mockInstance } from 'utils/mockAxios';
import { modalState } from 'utils/recoil/modal';
import { toastState } from 'utils/recoil/toast';
import { tableFormat } from 'constants/admin/table';
Expand Down Expand Up @@ -68,7 +67,10 @@ export default function TournamentList({

const fetchTournaments = useCallback(async () => {
try {
const res = await mockInstance.get(`/tournament?page=${currentPage}`);
const res = await instance.get(
`pingpong/tournaments?page=${currentPage}&size=20`
);
console.log(res.data.tournaments);
setTournamentInfo({
tournamentList: res.data.tournaments,
totalPage: res.data.totalPage,
Expand All @@ -85,7 +87,7 @@ export default function TournamentList({

const deleteHandler = async (tournamentId: number) => {
try {
await instanceInManage.delete(`/tournament/${tournamentId}`);
await instanceInManage.delete(`/tournaments/${tournamentId}`);
setSnackbar({
toastName: `delete request`,
severity: 'success',
Expand All @@ -96,7 +98,7 @@ export default function TournamentList({
setSnackbar({
toastName: `bad request`,
severity: 'error',
// message: `🔥 ${announceDeleteResponse[e.response.data.code]} 🔥`,
message: `🔥 ${e.response.data.message} 🔥`,
clicked: true,
});
}
Expand Down Expand Up @@ -140,26 +142,29 @@ export default function TournamentList({
)
)
) : columnName === 'edit' ? (
tournament.status === 'BEFORE' ? (
tournament.status === 'BEFORE' ||
tournament.status === 'READY' ? (
<div className={styles.listBtnContainer}>
<button
className={styles.edit}
onClick={() => {
setTournamentEditInfo({
tournamentId: tournament.tournamentId,
title: tournament.title,
contents: tournament.contents,
type: tournament.type,
startTime: new Date(
tournament.startTime
),
endTime: new Date(tournament.endTime),
});
scrollToEditor();
}}
>
내용 수정
</button>
{tournament.status === 'BEFORE' && (
<button
className={styles.edit}
onClick={() => {
setTournamentEditInfo({
tournamentId: tournament.tournamentId,
title: tournament.title,
contents: tournament.contents,
type: tournament.type,
startTime: new Date(
tournament.startTime
),
endTime: new Date(tournament.endTime),
});
scrollToEditor();
}}
>
내용 수정
</button>
)}
<button
className={styles.editParticipants}
onClick={() => {
Expand Down
2 changes: 1 addition & 1 deletion components/modal/admin/AdminEditTournamentBraket.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Match } from '@g-loot/react-tournament-brackets/dist/src/types';
import { useCallback, useEffect, useState, useRef } from 'react';
import { ITournament } from 'types/admin/adminTournamentTypes';
import { TournamentGame, TournamentInfo } from 'types/tournamentTypes';
import { TournamentGame } from 'types/tournamentTypes';
import { convertTournamentGamesToBracketMatchs } from 'utils/handleTournamentGame';
import { mockInstance } from 'utils/mockAxios';
import TournamentBraket from 'components/tournament/TournamentBraket';
Expand Down

0 comments on commit fb3b520

Please sign in to comment.