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

Fix/#216 라운드 대진 횟수 설정 에러 해결 #218

Merged
merged 4 commits into from
Nov 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion src/@types/channelConfig.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export interface MatchCountList {
roundCountList: number[];
matchSetCountList: number[];
}
24 changes: 19 additions & 5 deletions src/components/ModifyChannel/BracketInfoChannel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const BracketInfoChannel = () => {
const { data, isLoading, isError, isSuccess } = useQuery({
queryKey: ['matchCount', router.query.channelLink as string],
queryFn: () => fetchInitialMatchCount(router.query.channelLink as string),
staleTime: 0,
});

const handleRoundInfo = (e: React.ChangeEvent<HTMLSelectElement>, roundIndex: number) => {
Expand All @@ -32,34 +33,47 @@ const BracketInfoChannel = () => {
};

const updateRoundMatchCount = async () => {
if (!roundInfo) {
return;
}

try {
const res = await authAPI({
method: 'post',
url: `/api/match/${router.query.channelLink as string}/count`,
data: {
roundCountList: roundInfo?.reverse(),
matchSetCountList: [...roundInfo].reverse(),
},
});

console.log(res);

alert('수정이 완료되었습니다!');
} catch (error) {
console.log(error);
alert('이미 시작된 경기는 재 배정할 수 없습니다.');
}
};

useEffect(() => {
if (isSuccess) {
setRoundInfo(data?.roundCountList.reverse());
setRoundInfo([...data?.matchSetCountList].reverse());
}
}, [data]);

if (isLoading) {
return <div>로딩 중</div>;
}

if (isError) {
return <div>에러</div>;
}

return (
<Container>
<Header>라운드 수정</Header>
<Content>
{roundInfo?.map((currentMatchCount, index) => {
{isLoading && <div>로딩 중</div>}
{isError && <div>Error</div>}
{roundInfo?.reverse().map((currentMatchCount, index) => {
return (
<RoundInfo key={index}>
<RoundInfoHeader>Round {index + 1}</RoundInfoHeader>
Expand Down
2 changes: 0 additions & 2 deletions src/components/RoundAlarm/RoundAlarmBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ interface Props {
const RoundAlarmBody = ({ curRound, havingAlarm }: Props) => {
const router = useRouter();

console.log(havingAlarm);

const [roundInfo, setRoundInfo] = useState<BracketContents>();

useEffect(() => {
Expand Down