Skip to content

Commit

Permalink
Feat: #134 일정 생성 API 수정 사항 반영
Browse files Browse the repository at this point in the history
  • Loading branch information
Seok93 committed Sep 18, 2024
1 parent c1488fc commit 15390df
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/mocks/services/taskServiceHandler.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 15390df

Please sign in to comment.