From 8dcc5c08de8202835c0a8eb206f04679a1979437 Mon Sep 17 00:00:00 2001 From: kimjaehyuk Date: Tue, 7 Nov 2023 15:27:08 +0900 Subject: [PATCH 1/3] [] --- components/admin/SideNav.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/components/admin/SideNav.tsx b/components/admin/SideNav.tsx index e4d91804f..3d01b48fb 100644 --- a/components/admin/SideNav.tsx +++ b/components/admin/SideNav.tsx @@ -9,7 +9,7 @@ import { } from 'react-icons/gr'; import { IoGameControllerOutline, IoReceiptOutline } from 'react-icons/io5'; import { MdOutlineMessage } from 'react-icons/md'; -import { TbCalendarTime, TbCoin, TbPaperBag } from 'react-icons/tb'; +import { TbCalendarTime, TbCoin, TbPaperBag, TbTrophy } from 'react-icons/tb'; import SideNavContent from 'components/admin/SideNavContent'; import styles from 'styles/admin/SideNav.module.scss'; @@ -113,6 +113,14 @@ export default function SideNav() { > + + + + ); } From 7b43a5ae052dcfcf0eb8ff09d0f585505c7b010c Mon Sep 17 00:00:00 2001 From: kimjaehyuk Date: Tue, 7 Nov 2023 17:45:53 +0900 Subject: [PATCH 2/3] =?UTF-8?q?feat:=ED=86=A0=EB=84=88=EB=A8=BC=ED=8A=B8?= =?UTF-8?q?=20=ED=85=8C=EC=9D=B4=EB=B8=94=20=ED=83=80=EC=9E=85=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80#1075?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- constants/admin/table.ts | 14 ++++++++++++++ types/admin/tableTypes.ts | 4 +++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/constants/admin/table.ts b/constants/admin/table.ts index c95b6ff5d..456a0fbb6 100644 --- a/constants/admin/table.ts +++ b/constants/admin/table.ts @@ -150,4 +150,18 @@ export const tableFormat: TableFormat = { 'rankLose', ], }, + tournament: { + name: '토너먼트', + columns: [ + 'tournamentName', + 'content', + 'startTime', + 'endTime', + 'tournamentType', + ], + }, + tournamentCreate: { + name: '토너먼트 생성', + columns: ['tournamentName', 'startTime', 'endTime', 'tournamentType'], + }, }; diff --git a/types/admin/tableTypes.ts b/types/admin/tableTypes.ts index 056ba85e8..333b85d68 100644 --- a/types/admin/tableTypes.ts +++ b/types/admin/tableTypes.ts @@ -15,7 +15,9 @@ export type TableName = | 'itemList' | 'itemHistory' | 'coinPolicy' - | 'coinPolicyHistory'; + | 'coinPolicyHistory' + | 'tournament' + | 'tournamentCreate'; export type EtcType = 'button' | 'toggle'; From 817130a0b4dae0dec9bd056e22d23b9e01f4f740 Mon Sep 17 00:00:00 2001 From: kimjaehyuk Date: Thu, 9 Nov 2023 15:45:53 +0900 Subject: [PATCH 3/3] =?UTF-8?q?feat:=20=EB=A6=AC=EC=8A=A4=ED=8A=B8?= =?UTF-8?q?=EC=97=90=20=EB=B2=84=ED=8A=BC=20=EC=B6=94=EA=B0=80#1075?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/tournament/TournamentEdit.tsx | 193 ++++++++++++++++++ .../admin/tournament/TournamentList.tsx | 136 ++++++++++++ constants/admin/table.ts | 1 + pages/admin/tournament.tsx | 12 ++ types/admin/adminTournamentTypes.ts | 13 ++ 5 files changed, 355 insertions(+) create mode 100644 components/admin/tournament/TournamentEdit.tsx create mode 100644 components/admin/tournament/TournamentList.tsx create mode 100644 pages/admin/tournament.tsx create mode 100644 types/admin/adminTournamentTypes.ts diff --git a/components/admin/tournament/TournamentEdit.tsx b/components/admin/tournament/TournamentEdit.tsx new file mode 100644 index 000000000..136ee855b --- /dev/null +++ b/components/admin/tournament/TournamentEdit.tsx @@ -0,0 +1,193 @@ +import dynamic from 'next/dynamic'; +import { useEffect, useState } from 'react'; +import { useSetRecoilState } from 'recoil'; +import { + Paper, + Table, + TableBody, + TableCell, + TableContainer, + TableRow, +} from '@mui/material'; +import { QUILL_EDIT_MODULES, QUILL_FORMATS } from 'types/quillTypes'; +import { toastState } from 'utils/recoil/toast'; +import { useUser } from 'hooks/Layout/useUser'; +import styles from 'styles/admin/announcement/AnnounceEdit.module.scss'; +import 'react-quill/dist/quill.snow.css'; +import 'react-quill/dist/quill.bubble.css'; +import { AdminTableHead } from '../common/AdminTable'; + +const Quill = dynamic(() => import('react-quill'), { + ssr: false, + loading: () =>

Loading ...

, +}); + +const tableTitle: { [key: string]: string } = { + tournamentName: '토너먼트 이름', + startTime: '시작 시간', + endTime: '종료 시간', + tournamentType: '토너먼트 유형', +}; + +export default function TournamentEdit() { + const user = useUser(); + const setSnackbar = useSetRecoilState(toastState); + const [content, setContent] = useState(''); + const announceCreateResponse: { [key: string]: string } = { + SUCCESS: '공지사항이 성공적으로 등록되었습니다.', + AN300: + '이미 활성화된 공지사항이 있습니다. 새로운 공지사항을 등록하시려면 활성화된 공지사항을 삭제해 주세요.', + }; + const announceDeleteResponse: { [key: string]: string } = { + SUCCESS: '공지사항이 성공적으로 삭제되었습니다.', + AN100: '삭제 할 활성화된 공지사항이 없습니다.', + }; + + useEffect(() => { + resetHandler(); + }, []); + + const resetHandler = async () => { + try { + //const res = await instance.get('/pingpong/announcement'); + setContent('가장 최근 토너먼트 내용'); //setContent(res?.data.content); + } catch (e) { + alert(e); + } + }; + + if (!user) return null; + + const currentUserId = user.intraId; + + const postHandler = async () => { + // try { + // await instanceInManage.post(`/announcement`, { + // content, + // creatorIntraId: currentUserId, + // }); + // setSnackbar({ + // toastName: `post request`, + // severity: 'success', + // message: `🔥 ${announceCreateResponse.SUCCESS} 🔥`, + // clicked: true, + // }); + // } catch (e: any) { + // setSnackbar({ + // toastName: `bad request`, + // severity: 'error', + // message: `🔥 ${announceCreateResponse[e.response.data.code]} 🔥`, + // clicked: true, + // }); + // } + }; + + const deleteHandler = async () => { + // try { + // await instanceInManage.delete(`/announcement/${currentUserId}`); + // setSnackbar({ + // toastName: `delete request`, + // severity: 'success', + // message: `🔥 ${announceDeleteResponse.SUCCESS} 🔥`, + // clicked: true, + // }); + // } catch (e: any) { + // setSnackbar({ + // toastName: `bad request`, + // severity: 'error', + // message: `🔥 ${announceDeleteResponse[e.response.data.code]} 🔥`, + // clicked: true, + // }); + // } + }; + + return ( +
+
+

추후 토너먼트 페이지 모달 완성시 추가 예정

+ {/* {content ? ( +
+
Notice!
+ +
+ + +
+
+
+ +
+
+
+ ) : ( +
활성화된 공지사항이 없습니다 !
+ )} */} +
+
+ + + + + + + + + + + + + + + + + + + +
+
+ setContent(content)} + /> +
+ + + +
+
+
+ ); +} diff --git a/components/admin/tournament/TournamentList.tsx b/components/admin/tournament/TournamentList.tsx new file mode 100644 index 000000000..2f79fdefd --- /dev/null +++ b/components/admin/tournament/TournamentList.tsx @@ -0,0 +1,136 @@ +import dynamic from 'next/dynamic'; +import { useCallback, useEffect, useState } from 'react'; +import { + Paper, + Table, + TableBody, + TableCell, + TableContainer, + TableRow, +} from '@mui/material'; +import { + ITournament, + ITournamentTable, +} from 'types/admin/adminTournamentTypes'; +import { tableFormat } from 'constants/admin/table'; +import { + AdminEmptyItem, + AdminTableHead, +} from 'components/admin/common/AdminTable'; +import PageNation from 'components/Pagination'; +import styles from 'styles/admin/announcement/AnnounceList.module.scss'; +import 'react-quill/dist/quill.snow.css'; +import 'react-quill/dist/quill.bubble.css'; + +const Quill = dynamic(() => import('react-quill'), { + ssr: false, + loading: () =>

Loading ...

, +}); + +const tableTitle: { [key: string]: string } = { + tournamentName: '토너먼트 이름', + startTime: '시작 시간', + endTime: '종료 시간', + tournamentType: '토너먼트 타입', + edit: '수정하기', +}; + +const smapleTournamentList: ITournament[] = Array.from({ length: 10 }, () => ({ + tournamentName: '샘플토너먼트제목', + content: '샘플내용', + startTime: new Date(), + endTime: new Date(), + tournamentType: 'CUSTOM', +})); + +export default function TournamentList() { + const [tournamentInfo, setTournamentInfo] = useState({ + tournamentList: [], + totalPage: 0, + currentPage: 0, + }); + + const [currentPage, setCurrentPage] = useState(1); + + const getTournaments = useCallback(async () => { + try { + // const res = await instanceInManage.get( + // `/announcement?page=${currentPage}&size=3` + // ); + setTournamentInfo({ + tournamentList: smapleTournamentList, //res.data.tournamentList, + totalPage: 10, //res.data.totalPage, + currentPage: currentPage, + }); + } catch (e) { + console.error('MS01'); + } + }, [currentPage]); + + useEffect(() => { + getTournaments(); + }, [getTournaments]); + + return ( +
+
+ 토너먼트 리스트 +
+ + + + + {tournamentInfo.tournamentList.length > 0 ? ( + tournamentInfo.tournamentList.map( + (tournament: ITournament, index: number) => ( + + {tableFormat['tournament'].columns.map( + (columnName: string, index: number) => { + return ( + + {columnName === 'startTime' || + columnName === 'endTime' + ? tournament[ + columnName as keyof ITournament + ]?.toLocaleString() + : tournament[ + columnName as keyof ITournament + ]?.toString()} + + ); + } + )} + +
+ +
+
+
+ ) + ) + ) : ( + + )} +
+
+
+
+ { + setCurrentPage(pageNumber); + }} + /> +
+
+ ); +} diff --git a/constants/admin/table.ts b/constants/admin/table.ts index 456a0fbb6..9b0330b4f 100644 --- a/constants/admin/table.ts +++ b/constants/admin/table.ts @@ -158,6 +158,7 @@ export const tableFormat: TableFormat = { 'startTime', 'endTime', 'tournamentType', + 'edit', ], }, tournamentCreate: { diff --git a/pages/admin/tournament.tsx b/pages/admin/tournament.tsx new file mode 100644 index 000000000..9bc472b01 --- /dev/null +++ b/pages/admin/tournament.tsx @@ -0,0 +1,12 @@ +import TournamentEdit from 'components/admin/tournament/TournamentEdit'; +import TournamentList from 'components/admin/tournament/TournamentList'; +import styles from 'styles/admin/announcement/Announcement.module.scss'; + +export default function Tournament() { + return ( +
+ + +
+ ); +} diff --git a/types/admin/adminTournamentTypes.ts b/types/admin/adminTournamentTypes.ts new file mode 100644 index 000000000..a7e5620c3 --- /dev/null +++ b/types/admin/adminTournamentTypes.ts @@ -0,0 +1,13 @@ +export interface ITournament { + tournamentName: string; + content: string; + startTime: Date; + endTime: Date; + tournamentType: 'CUSTOM' | 'ROOKIE' | 'MASTER'; +} + +export interface ITournamentTable { + tournamentList: ITournament[]; + totalPage: number; + currentPage: number; +}