Skip to content

Commit

Permalink
Merge pull request #138 from TheUpperPart/Feat/#137
Browse files Browse the repository at this point in the history
Feat/#137: 경기 참가요청할 수 있도록 추가했어요
  • Loading branch information
pp449 authored Sep 12, 2023
2 parents 132206e + f300f63 commit 7981108
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
3 changes: 3 additions & 0 deletions __mocks__/handlers/channelHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ const channelHandlers = [
rest.post(SERVER_URL + '/api/channel/:channelLink', (req, res, ctx) => {
return res(ctx.status(200), ctx.json({}));
}),
rest.post(SERVER_URL + '/api/:channelLink/participant', (req, res, ctx) => {
return res(ctx.status(200), ctx.json({}));
}),
];

export default channelHandlers;
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 7981108

Please sign in to comment.