Skip to content

Commit

Permalink
[Fix] 토너먼트 레지스트리 모달 수정 #1159
Browse files Browse the repository at this point in the history
  • Loading branch information
Junho Jeon committed Dec 14, 2023
1 parent e797f1f commit 18562d3
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions components/modal/tournament/TournamentRegistryModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { instance } from 'utils/axios';
import { dateToKRLocaleTimeString } from 'utils/handleTime';
import { errorState } from 'utils/recoil/error';
import { modalState } from 'utils/recoil/modal';
import { toastState } from 'utils/recoil/toast';
import {
ModalButtonContainer,
ModalButton,
Expand All @@ -31,7 +30,6 @@ export default function TournamentRegistryModal({
player_cnt,
tournamentId,
}: TournamentInfo) {
const setSnackbar = useSetRecoilState(toastState);
const setModal = useSetRecoilState(modalState);
const setError = useSetRecoilState(errorState);
const [registState, setRegistState] = useState<string>('LOADING');
Expand All @@ -45,14 +43,16 @@ export default function TournamentRegistryModal({
.post(`/pingpong/tournaments/${tournamentId}/users`)
.then((res) => {
alert('토너먼트 신청이 완료됐습니다');
setModal({ modalName: null });
setLoading(false);
setRegistState(res.data.status);
if (playerCount < 8) setPlayerCount(playerCount + 1);
return res.data.status;
})
.catch((error) => {
alert('토너먼트 신청 중 에러가 발생했습니다.');
setLoading(false);
});
}, []);
}, [playerCount]);

const unRegistTournament = useCallback(() => {
setLoading(true);
Expand All @@ -62,16 +62,18 @@ export default function TournamentRegistryModal({
if (registState === 'WAIT') {
alert('토너먼트 대기가 취소 되었습니다');
} else {
setPlayerCount(playerCount - 1);
alert('토너먼트 등록이 취소 되었습니다');
}
setModal({ modalName: null });
setRegistState(res.data.status);
setLoading(false);
return res.data.status;
})
.catch((error) => {
alert('토너먼트 등록취소 중 에러가 발생했습니다');
setLoading(false);
});
}, []);
}, [playerCount]);

const getStatus = useCallback(() => {
return instance
Expand All @@ -91,6 +93,7 @@ export default function TournamentRegistryModal({
setOpenDate(dateToKRLocaleTimeString(date));
}, []);

console.log(registState);
const closeModalButtonHandler = () => {
setModal({ modalName: null });
};
Expand Down

0 comments on commit 18562d3

Please sign in to comment.