diff --git a/src/mocks/services/taskServiceHandler.ts b/src/mocks/services/taskServiceHandler.ts index 112b828e..95546a63 100644 --- a/src/mocks/services/taskServiceHandler.ts +++ b/src/mocks/services/taskServiceHandler.ts @@ -1,5 +1,5 @@ import { http, HttpResponse } from 'msw'; -import { STATUS_DUMMY, TASK_DUMMY } from '@mocks/mockData'; +import { STATUS_DUMMY, TASK_DUMMY, TASK_USER_DUMMY } from '@mocks/mockData'; import { getStatusHash, getTaskHash } from '@mocks/mockHash'; import type { TaskForm, TaskOrderForm } from '@/types/TaskType'; @@ -28,17 +28,19 @@ const taskServiceHandler = [ // 일정 생성 API http.post(`${BASE_URL}/project/:projectId/task`, async ({ request, params }) => { const accessToken = request.headers.get('Authorization'); - const formData = (await request.json()) as TaskForm; + const { assignees, ...restFormData } = (await request.json()) as TaskForm; const { projectId } = params; if (!accessToken) return new HttpResponse(null, { status: 401 }); const statusList = STATUS_DUMMY.filter((status) => status.projectId === Number(projectId)); - if (!statusList.find((status) => status.statusId === Number(formData.statusId))) { + if (!statusList.find((status) => status.statusId === Number(restFormData.statusId))) { return new HttpResponse(null, { status: 400 }); } - TASK_DUMMY.push({ ...formData, statusId: +formData.statusId, taskId: TASK_DUMMY.length + 1, files: [] }); + const taskId = TASK_DUMMY.length + 1; + assignees.forEach((userId) => TASK_USER_DUMMY.push({ taskId, userId })); + TASK_DUMMY.push({ ...restFormData, statusId: +restFormData.statusId, taskId, files: [] }); return new HttpResponse(null, { status: 201 }); }), // 일정 순서 변경 API