From 745532870fb6612539e9090983ac5a6a99d0fe26 Mon Sep 17 00:00:00 2001 From: seungchanwoo Date: Thu, 31 Oct 2024 22:28:47 +0900 Subject: [PATCH] =?UTF-8?q?Fix:=20#253=20mockAPI=20=EC=B6=94=EA=B0=80=20?= =?UTF-8?q?=EB=B0=8F=20=ED=94=84=EB=A1=9C=EC=A0=9D=ED=8A=B8=20=ED=8C=80?= =?UTF-8?q?=EC=9B=90=20=EC=82=AD=EC=A0=9C=20mswhandler=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/mocks/mockAPI.ts | 12 ++++++++++++ src/mocks/services/projectServiceHandler.ts | 11 ++++------- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/mocks/mockAPI.ts b/src/mocks/mockAPI.ts index 222262fe..c2acab82 100644 --- a/src/mocks/mockAPI.ts +++ b/src/mocks/mockAPI.ts @@ -90,6 +90,7 @@ export function updateProjectUserRole( projectUser.roleId = newRoleId; } +// 프로젝트 유저 삭제 export function deleteProjectUser(projectId: Project['projectId'], userId: User['userId']) { const projectUserIndex = PROJECT_USER_DUMMY.findIndex( (projectUser) => projectUser.projectId === projectId && projectUser.userId === userId, @@ -201,6 +202,17 @@ export function deleteAllTaskUser(taskId: Task['taskId']) { } } +// 일정과 특정 유저의 연결만 삭제 +export function deleteTaskUser(taskId: Task['taskId'], userId: number) { + const taskUserIndex = TASK_USER_DUMMY.findIndex( + (taskUser) => taskUser.taskId === taskId && taskUser.userId === userId, + ); + + if (taskUserIndex !== -1) { + TASK_USER_DUMMY.splice(taskUserIndex, 1); // 특정 유저와의 연결 삭제 + } +} + /* ===================== 일정(Task) 관련 처리 ===================== */ // 일정 추가 diff --git a/src/mocks/services/projectServiceHandler.ts b/src/mocks/services/projectServiceHandler.ts index 6e121dd0..01c2f376 100644 --- a/src/mocks/services/projectServiceHandler.ts +++ b/src/mocks/services/projectServiceHandler.ts @@ -10,6 +10,7 @@ import { deleteAllTaskUser, deleteProject, deleteProjectUser, + deleteTaskUser, findAllProject, findAllProjectStatus, findAllProjectUser, @@ -383,17 +384,13 @@ const projectServiceHandler = [ try { const statusIds = findAllProjectStatus(projectId).map((status) => status.statusId); - const taskIds: number[] = []; statusIds.forEach((statusId) => { const tasks = findAllTask(statusId); - tasks.forEach((task) => taskIds.push(task.taskId)); + tasks.forEach((task) => { + deleteTaskUser(task.taskId, projectCoworkerId); + }); }); - taskIds.forEach((taskId) => { - deleteAllTaskFileInMemory(taskId); - deleteAllTaskFile(taskId); - deleteAllTaskUser(taskId); - }); deleteProjectUser(projectId, projectCoworkerId); } catch (error) { console.error((error as Error).message);