Skip to content
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/api/games/patchGameParticipate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { axiosInstance } from '@api/axiosInstance';
import { PatchGameParticipateApplyRequest } from '@type/api/games';
import { Game, Member } from '@type/models';

export const patchMannerScoreReview = async ({
export const patchGameParticipate = async ({
payload,
gameId,
memberId,
Expand Down
9 changes: 9 additions & 0 deletions src/hooks/mutations/useGameParticipateCreateMutation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { useMutation } from '@tanstack/react-query';

import { postGameParticipate } from '@api/games/postGameParticipate';

export const useGameParticipateCreateMutation = () => {
return useMutation({
mutationFn: postGameParticipate,
});
};
37 changes: 36 additions & 1 deletion src/mocks/handlers/game.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { CommonErrorResponse } from '@type/api/error';
import {
GetGameDetailResponse,
GetGameMembersResponse,
PostGameParticipateRequest,
PostGameRequest,
PostGameResponse,
} from '@type/api/games';
Expand Down Expand Up @@ -65,6 +66,34 @@ const mockGetGames = http.get('/api/games', ({ request }) => {
return HttpResponse.json(games.slice(startIndex, startIndex + size));
});

const mockPostGameParticipate = http.post<
{ gameId: string },
{ data: PostGameParticipateRequest }
>('/api/games/:gameId/members', async ({ params, request }) => {
const gameId = Number(params.gameId);
const {
data: { memberId },
} = await request.json();

const game = games.find((game) => game.id === gameId);
if (!game) {
return;
}

game.members.push({
id: memberId,
email: 'james123@pickple.kr',
nickname: 'james123',
introduction: '안녕하십니까. 제임스입니다. 아이고~ 사장님~~',
profileImageUrl: 'https://s3.amazonaws.com/pickple/james123.jpg',
mannerScore: 21,
mannerScoreCount: 30,
addressDepth1: '서울시',
addressDepth2: '강남구',
positions: ['C', 'PF'],
});
});

const mockGetGameMembers = http.get<
{ gameId: string },
DefaultBodyType,
Expand Down Expand Up @@ -106,4 +135,10 @@ const mockGetGameDetail = http.get<
return HttpResponse.json(game);
});

export const gameHandlers = [mockPostGame, mockGetGames, mockGetGameDetail, mockGetGameMembers];
export const gameHandlers = [
mockPostGame,
mockGetGames,
mockGetGameDetail,
mockGetGameMembers,
mockPostGameParticipate,
];