Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/관리자 토너먼트 페이지 전적 수정을 위한 브래킷뷰#1080 #1101

Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
9871ad4
Merge branch 'feat/관리자-토너먼트-페이지-레이아웃#1075' into feat/관리자-토너먼트-페이지-전적-…
greatSweetMango Nov 9, 2023
5506234
feat:토너먼트 모달타입추가
greatSweetMango Nov 9, 2023
4219a6c
Merge branch 'main' into feat/관리자-토너먼트-페이지-전적-수정을-위한-브래킷뷰#1080
greatSweetMango Nov 9, 2023
a54da77
feat:버튼 클릭 모달열기 추가#1080
greatSweetMango Nov 9, 2023
97ac551
fix: ITournament TournamentInfo 필드 이름 변경
greatSweetMango Nov 10, 2023
25e3049
Merge branch 'main' into feat/관리자-토너먼트-페이지-전적-수정을-위한-브래킷뷰#1080
greatSweetMango Nov 10, 2023
43df8a1
[Feat] tournament 스타일 추가
greatSweetMango Nov 21, 2023
c6fd7a1
[Feat] 토너먼트 전적 수정 모달 작성
greatSweetMango Nov 21, 2023
d804e3c
[Feat] 토너먼트 브래킷뷰 구현
greatSweetMango Nov 21, 2023
233a378
[Feat] 토너먼트 전적 수정 버튼 추가
greatSweetMango Nov 21, 2023
15db5da
[Feat] 브래킷뷰 스타일 작성 #1080
greatSweetMango Nov 22, 2023
0b402c2
[Refactor] 스타일 분리 #1080
greatSweetMango Nov 22, 2023
d926803
[Fix] 수정버튼 위치 수정
greatSweetMango Nov 22, 2023
678e7e9
[Fix] AdminEditTournamentBraket props 제거 #1080
greatSweetMango Nov 22, 2023
572308b
[Fix] dynamic import 타입 명시 #1080
greatSweetMango Nov 22, 2023
b8f3b73
[Fix] 구버전 TournamentInfo 삭제 #1080
greatSweetMango Nov 22, 2023
b48303f
[Fix] 구버전 TournamentInfo 삭제
greatSweetMango Nov 22, 2023
99e307e
Merge branch 'main' into feat/관리자-토너먼트-페이지-전적-수정을-위한-브래킷뷰#1080
greatSweetMango Nov 23, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 28 additions & 18 deletions components/admin/tournament/TournamentList.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import dynamic from 'next/dynamic';
import { useCallback, useEffect, useState } from 'react';
import { useSetRecoilState } from 'recoil';
import {
Paper,
Table,
Expand All @@ -12,6 +13,8 @@ import {
ITournament,
ITournamentTable,
} from 'types/admin/adminTournamentTypes';
import { TournamentInfo } from 'types/tournamentTypes';
import { modalState } from 'utils/recoil/modal';
import { tableFormat } from 'constants/admin/table';
import {
AdminEmptyItem,
Expand All @@ -28,7 +31,8 @@ const Quill = dynamic(() => import('react-quill'), {
});

const tableTitle: { [key: string]: string } = {
tournamentName: '토너먼트 이름',
title: '토너먼트 이름',
content: '토너먼트 내용',
startTime: '시작 시간',
endTime: '종료 시간',
tournamentType: '토너먼트 타입',
Expand All @@ -45,6 +49,7 @@ const smapleTournamentList: ITournament[] = Array.from({ length: 10 }, () => ({
}));

export default function TournamentList() {
const setModal = useSetRecoilState(modalState);
const [tournamentInfo, setTournamentInfo] = useState<ITournamentTable>({
tournamentList: [],
totalPage: 0,
Expand Down Expand Up @@ -93,27 +98,32 @@ export default function TournamentList() {
key={index}
>
{columnName === 'startTime' ||
columnName === 'endTime'
? tournament[
columnName as keyof ITournament
]?.toLocaleString()
: tournament[
columnName as keyof ITournament
]?.toString()}
columnName === 'endTime' ? (
tournament[
columnName as keyof ITournament
]?.toLocaleString()
) : columnName === 'edit' ? (
<div>
<button
className={styles.editBtn}
onClick={() => {
setModal({
modalName: 'ADMIN-TOURNAMENT_BRAKET_EDIT',
});
}}
>
수정
</button>
</div>
) : (
tournament[
columnName as keyof ITournament
]?.toString()
)}
</TableCell>
);
}
)}
<TableCell>
<div>
<button
className={styles.editBtn}
// onClick={() => deleteHandler(seasonL.seasonId)}
>
삭제
</button>
</div>
</TableCell>
</TableRow>
)
)
Expand Down
131 changes: 131 additions & 0 deletions components/modal/admin/AdminEditTournamentBraket.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
import { Match } from '@g-loot/react-tournament-brackets/dist/src/types';
import TournamentBraket from 'components/tournament/TournamentBraket';
import styles from 'styles/admin/modal/AdminEditTournamentBraket.module.scss';

export const simpleSmallBracket: Match[] = [
{
id: 19753,
nextMatchId: null,
tournamentRoundText: '3',
startTime: '2021-05-30',
state: 'SCHEDULED',
participants: [],
},
{
id: 19754,
nextMatchId: 19753,
tournamentRoundText: '2',
startTime: '2021-05-30',
state: 'SCHEDULED',
participants: [
{
id: '14754a1a-932c-4992-8dec-f7f94a339960',
resultText: null,
isWinner: false,
status: null,
name: 'CoKe BoYz',
picture: 'https://avatars.githubusercontent.com/u/93255519?v=4',
},
],
},
{
id: 19755,
nextMatchId: 19754,
tournamentRoundText: '1',
startTime: '2021-05-30',
state: 'SCORE_DONE',
participants: [
{
id: '14754a1a-932c-4992-8dec-f7f94a339960',
resultText: 'Won',
isWinner: true,
status: 'PLAYED',
name: 'CoKe BoYz',
picture: 'https://avatars.githubusercontent.com/u/93255519?v=4',
},
{
id: 'd16315d4-7f2d-427b-ae75-63a1ae82c0a8',
resultText: 'Lost',
isWinner: false,
status: 'PLAYED',
name: 'Aids Team',
picture: 'https://avatars.githubusercontent.com/u/93255519?v=4',
},
],
},
{
id: 19756,
nextMatchId: 19754,
tournamentRoundText: '1',
startTime: '2021-05-30',
state: 'RUNNING',
participants: [
{
id: 'd8b9f00a-0ffa-4527-8316-da701894768e',
resultText: null,
isWinner: false,
status: null,
name: 'Art of kill',
picture: 'https://avatars.githubusercontent.com/u/93255519?v=4',
},
],
},
{
id: 19757,
nextMatchId: 19753,
tournamentRoundText: '2',
startTime: '2021-05-30',
state: 'SCHEDULED',
participants: [],
},
{
id: 19758,
nextMatchId: 19757,
tournamentRoundText: '1',
startTime: '2021-05-30',
state: 'SCHEDULED',
participants: [
{
id: '9397971f-4b2f-44eb-a094-722eb286c59b',
resultText: null,
isWinner: false,
status: null,
name: 'Crazy Pepes',
picture: 'https://avatars.githubusercontent.com/u/93255519?v=4',
},
],
},
{
id: 19759,
nextMatchId: 19757,
tournamentRoundText: '1',
startTime: '2021-05-30',
state: 'SCHEDULED',
participants: [
{
id: '42fecd89-dc83-4821-80d3-718acb50a30c',
resultText: null,
isWinner: false,
status: null,
name: 'BLUEJAYS',
picture: 'https://avatars.githubusercontent.com/u/93255519?v=4',
},
{
id: 'df01fe2c-18db-4190-9f9e-aa63364128fe',
resultText: null,
isWinner: false,
status: null,
name: 'Bosphorus',
picture: 'teamlogos/r7zn4gr8eajivapvjyzd',
},
],
},
];

export default function AdminEditTournamentBraket() {
return (
<div className={styles['whole']}>
<TournamentBraket singleEliminationBracketMatchs={simpleSmallBracket} />
</div>
);
}
3 changes: 3 additions & 0 deletions components/modal/modalType/AdminModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import AdminUserCoinModal from 'components/modal/admin/AdminUserCoinModal';
import DeletePenaltyModal from 'components/modal/admin/DeletePenaltyModal';
import DetailModal from 'components/modal/admin/DetailModal';
import AdminSeasonEdit from 'components/modal/admin/SeasonEdit';
import AdminEditTournamentBraket from '../admin/AdminEditTournamentBraket';

export default function AdminModal() {
const {
Expand All @@ -30,6 +31,7 @@ export default function AdminModal() {
profile,
item,
coinPolicy,
tournamentInfo,
} = useRecoilValue(modalState);

const content: { [key: string]: JSX.Element | null } = {
Expand Down Expand Up @@ -76,6 +78,7 @@ export default function AdminModal() {
'ADMIN-COINPOLICY_EDIT': coinPolicy ? (
<AdminEditCoinPolicyModal {...coinPolicy} />
) : null,
'ADMIN-TOURNAMENT_BRAKET_EDIT': <AdminEditTournamentBraket />,
};

if (!modalName) return null;
Expand Down
74 changes: 74 additions & 0 deletions components/tournament/TournamentBraket.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import dynamic from 'next/dynamic';
import {
SVGViewer as StaticSVGViewer,
SingleEliminationBracket as StaticSingleEliminationBracket,
} from '@g-loot/react-tournament-brackets';
import { Match } from '@g-loot/react-tournament-brackets/dist/src/types';
import React from 'react';
import TournamentMatch from 'components/tournament/TournamentMatch';

if (typeof window !== 'undefined' && typeof window.navigator !== 'undefined') {
import('@g-loot/react-tournament-brackets');
}

const SingleEliminationBracket = dynamic<
React.ComponentProps<typeof StaticSingleEliminationBracket>
>(
() => {
return import('@g-loot/react-tournament-brackets').then(
(mod) => mod.SingleEliminationBracket
);
},
{ ssr: false }
);

const SVGViewer = dynamic<React.ComponentProps<typeof StaticSVGViewer>>(
() => {
return import('@g-loot/react-tournament-brackets').then(
(mod) => mod.SVGViewer
);
},
{ ssr: false }
);

interface TournamentBraketProps {
singleEliminationBracketMatchs: Match[];
}

export default function TournamentBraket({
singleEliminationBracketMatchs,
}: TournamentBraketProps) {
// const [width, height] = useWindowSize();
const finalWidth = 500; //Math.max(width - 50, 500);
const finalHeight = 500; //Math.max(height - 100, 500);

return (
<SingleEliminationBracket
matches={singleEliminationBracketMatchs}
matchComponent={TournamentMatch}
options={{
style: {
width: 230,
boxHeight: 120,
roundHeader: {
isShown: false,
fontColor: '#FFFFFF',
},
connectorColor: '#FFFFFF',
connectorColorHighlight: '#da96c6',
},
}}
svgWrapper={({ children, ...props }) => (
<SVGViewer
background={'rgba(0, 0, 0, 0)'}
SVGBackground={'rgba(0, 0, 0, 0)'}
width={finalWidth}
height={finalHeight}
{...props}
>
{children}
</SVGViewer>
)}
/>
);
}
76 changes: 76 additions & 0 deletions components/tournament/TournamentMatch.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import {
MatchComponentProps,
Participant,
} from '@g-loot/react-tournament-brackets/dist/src/types';
import PlayerImage from 'components/PlayerImage';
import styles from 'styles/tournament/TournamentMatch.module.scss';

interface TournamentMatchPartyProps {
party: Participant;
teamNameFallback: string;
resultFallback: (participant: Participant) => string;
onMouseEnter: (partyId: string | number) => void;
}

function TournamentMatchParty({
party,
teamNameFallback,
onMouseEnter,
resultFallback,
}: TournamentMatchPartyProps) {
return (
<div
className={styles.tournamentPartyWrapper}
onMouseEnter={() => onMouseEnter(party.id)}
>
<PlayerImage
src={party.picture ?? '/image/match_qustion.png'}
styleName={`tournament`}
size={1}
/>

<div className={styles.partyName}>{party.name || teamNameFallback}</div>
<div className={styles.score}>
{party.resultText ?? resultFallback(party)}
{/* <input value={topParty.resultText ?? resultFallback(topParty)} /> */}
</div>
</div>
);
}

export default function TournamentMatch({
match,
onMatchClick,
onPartyClick,
onMouseEnter,
onMouseLeave,
topParty,
bottomParty,
topWon,
bottomWon,
topHovered,
bottomHovered,
topText,
bottomText,
connectorColor,
computedStyles,
teamNameFallback,
resultFallback,
}: MatchComponentProps) {
return (
<div className={styles.tournamentMatchContainer}>
<TournamentMatchParty
party={topParty}
teamNameFallback={teamNameFallback}
onMouseEnter={onMouseEnter}
resultFallback={resultFallback}
></TournamentMatchParty>
<TournamentMatchParty
party={bottomParty}
teamNameFallback={teamNameFallback}
onMouseEnter={onMouseEnter}
resultFallback={resultFallback}
></TournamentMatchParty>
</div>
);
}
Loading