Skip to content

Commit

Permalink
Fix: #210 프로젝트 삭제 handler 변경 및 useEffect 의존성 배열 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
ice-bear98 committed Oct 15, 2024
1 parent 2d982d4 commit 2671356
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
13 changes: 7 additions & 6 deletions src/mocks/services/projectServiceHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,14 @@ const projectServiceHandler = [
const accessToken = request.headers.get('Authorization');
const { projectId } = params;

if (!accessToken) return new HttpResponse(null, { status: 403 });
if (!accessToken) return new HttpResponse(null, { status: 401 });

const projectIdToDelete = Number(projectId);

const statusIdsToDelete = STATUS_DUMMY.filter((status) => status.projectId === projectIdToDelete).map(
(status) => status.statusId,
);

const filteredProjects = PROJECT_DUMMY.filter((project) => project.projectId !== projectIdToDelete);
PROJECT_DUMMY.length = 0;
PROJECT_DUMMY.push(...filteredProjects);
Expand All @@ -90,24 +94,21 @@ const projectServiceHandler = [
const filteredStatuses = STATUS_DUMMY.filter((status) => status.projectId !== projectIdToDelete);
STATUS_DUMMY.length = 0;
STATUS_DUMMY.push(...filteredStatuses);
const statusIdsToDelete = STATUS_DUMMY.filter((status) => status.projectId === projectIdToDelete).map(
(status) => status.statusId,
);

const filteredTasks = TASK_DUMMY.filter((task) => !statusIdsToDelete.includes(task.statusId));
TASK_DUMMY.length = 0;
TASK_DUMMY.push(...filteredTasks);

const filteredTaskUsers = TASK_USER_DUMMY.filter((taskUser) => {
const taskExists = TASK_DUMMY.some((task) => task.taskId === taskUser.taskId);
return !taskExists;
return taskExists;
});
TASK_USER_DUMMY.length = 0;
TASK_USER_DUMMY.push(...filteredTaskUsers);

const filteredTaskFiles = TASK_FILE_DUMMY.filter((taskFile) => {
const taskExists = TASK_DUMMY.some((task) => task.taskId === taskFile.taskId);
return !taskExists;
return taskExists;
});
TASK_FILE_DUMMY.length = 0;
TASK_FILE_DUMMY.push(...filteredTaskFiles);
Expand Down
2 changes: 1 addition & 1 deletion src/pages/team/TeamPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default function TeamPage() {
if (team) {
setTeamName(team.teamName);
}
}, [teamId, teamProjects]);
}, [teamId]);

const handleOpenUpdateModal = (projectId: Project['projectId']) => {
setSelectedProjectId(projectId);
Expand Down

0 comments on commit 2671356

Please sign in to comment.