Skip to content

Commit

Permalink
Feat: 경기에 정상적으로 참여할 수 있도록 서버 통신 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
pp449 committed Sep 11, 2023
1 parent 453a5e3 commit f300f63
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/components/Modal/JoinLeague/JoinLeague.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import authAPI from '@apis/authAPI';
import Icon from '@components/Icon';
import { SERVER_URL } from '@config/index';
import { css } from '@emotion/react';
Expand Down Expand Up @@ -46,6 +47,21 @@ const JoinLeague = ({ onClose, channelLink }: JoinLeagueProps) => {
return true;
};

const onClickSubmit: MouseEventHandler<HTMLElement> = async () => {
if (!nickname || !checked) return;
const res = await authAPI({
method: 'post',
url: `/api/${channelLink}/participant`,
data: {
gameId,
nickname,
},
});
if (res.status !== 200) return;
alert('정상적으로 리그참여 요청을 전송했어요');
onClose();
};

useEffect(() => {
if (profile) setNickname(profile.nickname);
}, []);
Expand Down Expand Up @@ -124,7 +140,9 @@ const JoinLeague = ({ onClose, channelLink }: JoinLeagueProps) => {
</CheckboxWrapper>
<Wrapper>
<SubmitButton onClick={onClose}>취소</SubmitButton>
<SubmitButton disabled={submitHandler()}>신청</SubmitButton>
<SubmitButton disabled={submitHandler()} onClick={onClickSubmit}>
신청
</SubmitButton>
</Wrapper>
</Container>
);
Expand Down

0 comments on commit f300f63

Please sign in to comment.