Skip to content

Commit

Permalink
Merge branch 'main' into feat/유저-토너먼트-전적-페이지-우승자-스와이프-뷰-#1070
Browse files Browse the repository at this point in the history
  • Loading branch information
Clearsu authored Nov 15, 2023
2 parents df23647 + 263ef73 commit ec91552
Show file tree
Hide file tree
Showing 22 changed files with 735 additions and 9 deletions.
10 changes: 9 additions & 1 deletion components/admin/SideNav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -113,6 +113,14 @@ export default function SideNav() {
>
<TbCoin className={styles.logo} />
</SideNavContent>

<SideNavContent
url={'/tournament'}
menuName={'토너먼트 관리'}
currentPath={currentPath}
>
<TbTrophy className={styles.logo} />
</SideNavContent>
</div>
);
}
193 changes: 193 additions & 0 deletions components/admin/tournament/TournamentEdit.tsx
Original file line number Diff line number Diff line change
@@ -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: () => <p>Loading ...</p>,
});

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 (
<div className={styles.container}>
<div className={styles.announceModal}>
<h1>추후 토너먼트 페이지 모달 완성시 추가 예정</h1>
{/* {content ? (
<div className={styles.announceModalContainer}>
<div className={styles.modalTitle}>Notice!</div>
<Quill
className={styles.quillViewer}
readOnly={true}
formats={QUILL_FORMATS}
value={content}
theme='bubble'
/>
<div className={styles.checkBox}>
<input type='checkbox' id='neverSeeAgain' name='neverSeeAgain' />
<label htmlFor='neverSeeAgain'>
<div>하루 동안 열지 않기</div>
</label>
</div>
<div className={styles.buttons}>
<div className={styles.positive}>
<input type='button' value='닫기' />
</div>
</div>
</div>
) : (
<div className={styles.noActive}>활성화된 공지사항이 없습니다 !</div>
)} */}
</div>
<div className={styles.editorContainer}>
<TableContainer className={styles.tableContainer} component={Paper}>
<Table className={styles.table} aria-label='customized table'>
<AdminTableHead tableName={'tournamentCreate'} table={tableTitle} />
<TableBody className={styles.tableBody}>
<TableRow>
<TableCell className={styles.tableBodyItem}>
<input
type='text'
name='tournamentName'
// onChange={inputChangeHandler}
/>
</TableCell>
<TableCell className={styles.tableBodyItem}>
<input
type='datetime-local'
name='startTime'
// onChange={inputChangeHandler}
/>
</TableCell>
<TableCell className={styles.tableBodyItem}>
<input
type='datetime-local'
name='endTime'
// onChange={inputChangeHandler}
/>
</TableCell>
<TableCell className={styles.tableBodyItem}>
<select
name='tournamentType'
// value={selectedValue}
// onChange={handleSelectChange}
>
<option value='CUSTOM'>CUSTOM</option>
<option value='ROOKIE'>ROOKIE</option>
<option value='MASTER'>MASTER</option>
{/* You can add more options here */}
</select>
</TableCell>
</TableRow>
</TableBody>
</Table>
</TableContainer>
<Quill
className={styles.quillEditor}
modules={QUILL_EDIT_MODULES}
formats={QUILL_FORMATS}
theme='snow'
value={content}
onChange={(content) => setContent(content)}
/>
<div className={styles.editorBtnContainer}>
<button onClick={resetHandler}>초기화</button>
<button onClick={postHandler}>생성</button>
<button onClick={deleteHandler}>토너먼트 삭제</button>
</div>
</div>
</div>
);
}
137 changes: 137 additions & 0 deletions components/admin/tournament/TournamentList.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
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: () => <p>Loading ...</p>,
});

const tableTitle: { [key: string]: string } = {
tournamentName: '토너먼트 이름',
startTime: '시작 시간',
endTime: '종료 시간',
tournamentType: '토너먼트 타입',
edit: '수정하기',
};

const smapleTournamentList: ITournament[] = Array.from({ length: 10 }, () => ({
title: '샘플토너먼트제목',
content: '샘플내용',
startTime: new Date(),
endTime: new Date(),
tournamentType: 'CUSTOM',
count: 7,
}));

export default function TournamentList() {
const [tournamentInfo, setTournamentInfo] = useState<ITournamentTable>({
tournamentList: [],
totalPage: 0,
currentPage: 0,
});

const [currentPage, setCurrentPage] = useState<number>(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 (
<div className={styles.container}>
<div className={styles.header}>
<span className={styles.title}>토너먼트 리스트</span>
</div>
<TableContainer className={styles.tableContainer} component={Paper}>
<Table className={styles.table} aria-label='customized table'>
<AdminTableHead tableName={'tournament'} table={tableTitle} />
<TableBody className={styles.tableBody}>
{tournamentInfo.tournamentList.length > 0 ? (
tournamentInfo.tournamentList.map(
(tournament: ITournament, index: number) => (
<TableRow key={index}>
{tableFormat['tournament'].columns.map(
(columnName: string, index: number) => {
return (
<TableCell
className={styles.tableBodyItem}
key={index}
>
{columnName === 'startTime' ||
columnName === 'endTime'
? tournament[
columnName as keyof ITournament
]?.toLocaleString()
: tournament[
columnName as keyof ITournament
]?.toString()}
</TableCell>
);
}
)}
<TableCell>
<div>
<button
className={styles.editBtn}
// onClick={() => deleteHandler(seasonL.seasonId)}
>
삭제
</button>
</div>
</TableCell>
</TableRow>
)
)
) : (
<AdminEmptyItem content={'기존 토너먼트가 없습니다'} />
)}
</TableBody>
</Table>
</TableContainer>
<div className={styles.pageNationContainer}>
<PageNation
curPage={tournamentInfo.currentPage}
totalPages={tournamentInfo.totalPage}
pageChangeHandler={(pageNumber: number) => {
setCurrentPage(pageNumber);
}}
/>
</div>
</div>
);
}
1 change: 1 addition & 0 deletions components/main/Section.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export default function Section({ sectionTitle, path }: SectionProps) {
const pathCheck: pathType = {
game: <GameResult />,
rank: <RankListMain isMain={true} season={0} />,
tournament: <></>,
};

return (
Expand Down
3 changes: 3 additions & 0 deletions components/modal/ModalProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import AdminModal from 'components/modal/modalType/AdminModal';
import NormalModal from 'components/modal/modalType/NormalModal';
import StoreModal from 'components/modal/modalType/StoreModal';
import styles from 'styles/modal/Modal.module.scss';
import TournamentModal from './modalType/TournamentModal';

export default function ModalProvider() {
const [{ modalName }, setModal] = useRecoilState(modalState);
Expand Down Expand Up @@ -43,6 +44,8 @@ export default function ModalProvider() {
<StoreModal />
) : modalType === 'ADMIN' ? (
<AdminModal />
) : modalType === 'TOURNAMENT' ? (
<TournamentModal />
) : null}
</div>
)
Expand Down
16 changes: 16 additions & 0 deletions components/modal/modalType/TournamentModal.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { useRecoilValue } from 'recoil';
import { modalState } from 'utils/recoil/modal';
import TournamentRegistryModal from '../tournament/TournamentRegistryModal';

export default function TournamentModal() {
const { modalName, tournamentInfo } = useRecoilValue(modalState);

const content: { [key: string]: JSX.Element | null } = {
'TOURNAMENT-REGISTRY': tournamentInfo ? (
<TournamentRegistryModal {...tournamentInfo} />
) : null,
};

if (!modalName) return null;
return content[modalName];
}
Loading

0 comments on commit ec91552

Please sign in to comment.