Skip to content

Commit

Permalink
Fix: #210 코드리뷰 반영 수정 및 경로 정리
Browse files Browse the repository at this point in the history
  • Loading branch information
ice-bear98 committed Oct 15, 2024
1 parent 12fe960 commit ff327b3
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import ModalButton from '@components/modal/ModalButton';
import ModalProjectStatusForm from '@components/modal/project-status/ModalProjectStatusForm';

import type { SubmitHandler } from 'react-hook-form';
import { useCreateStatus } from '@hooks/query/useStatusQuery';
import type { Project } from '@/types/ProjectType';
import type { ProjectStatusForm } from '@/types/ProjectStatusType';
import { useCreateStatus } from '@/hooks/query/useStatusQuery';

type CreateModalProjectStatusProps = {
project: Project;
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/query/useUserQuery.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useMutation, useQueryClient } from '@tanstack/react-query';
import useToast from '@hooks/useToast';
import { updateUserInfo } from '@services/userService';
import { generateUserInfoQueryKey } from '@/utils/queryKeyGenerator';
import { generateUserInfoQueryKey } from '@utils/queryKeyGenerator';
import type { EditUserInfoRequest } from '@/types/UserType';

export function useUpdateUserInfo() {
Expand Down
6 changes: 3 additions & 3 deletions src/layouts/page/TeamLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ import CreateModalTeam from '@components/modal/team/CreateModalTeam';
import useModal from '@hooks/useModal';
import { useMemo } from 'react';
import { useReadTeams } from '@hooks/query/useTeamQuery';
import Spinner from '@/components/common/Spinner';
import Spinner from '@components/common/Spinner';

export default function TeamLayout() {
const { showModal: showTeamModal, openModal: openTeamModal, closeModal: closeTeamModal } = useModal();
const location = useLocation();
const { teamId } = useParams();
const { joinedTeamList: teamData, isLoading } = useReadTeams();
const { joinedTeamList: teamData, isLoading: isTeamLoading } = useReadTeams();
const selectedTeam = useMemo(() => teamData.find((team) => team.teamId.toString() === teamId), [teamId, teamData]);
const hasProjectRoute = location.pathname.split('/').includes('projects');

if (isLoading) {
if (isTeamLoading) {
return <Spinner />;
}

Expand Down
37 changes: 25 additions & 12 deletions src/mocks/services/projectServiceHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ const projectServiceHandler = [

return HttpResponse.json(userRoleList);
}),

// 프로젝트 삭제 API
http.delete(`${BASE_URL}/project/:projectId`, ({ request, params }) => {
const accessToken = request.headers.get('Authorization');
Expand All @@ -82,36 +83,48 @@ const projectServiceHandler = [
);

const filteredProjects = PROJECT_DUMMY.filter((project) => project.projectId !== projectIdToDelete);
PROJECT_DUMMY.length = 0;
PROJECT_DUMMY.push(...filteredProjects);
if (PROJECT_DUMMY.length !== filteredProjects.length) {
PROJECT_DUMMY.length = 0;
PROJECT_DUMMY.push(...filteredProjects);
}

const filteredProjectUsers = PROJECT_USER_DUMMY.filter(
(projectUser) => projectUser.projectId !== projectIdToDelete,
);
PROJECT_USER_DUMMY.length = 0;
PROJECT_USER_DUMMY.push(...filteredProjectUsers);
if (PROJECT_USER_DUMMY.length !== filteredProjectUsers.length) {
PROJECT_USER_DUMMY.length = 0;
PROJECT_USER_DUMMY.push(...filteredProjectUsers);
}

const filteredStatuses = STATUS_DUMMY.filter((status) => status.projectId !== projectIdToDelete);
STATUS_DUMMY.length = 0;
STATUS_DUMMY.push(...filteredStatuses);
if (STATUS_DUMMY.length !== filteredStatuses.length) {
STATUS_DUMMY.length = 0;
STATUS_DUMMY.push(...filteredStatuses);
}

const filteredTasks = TASK_DUMMY.filter((task) => !statusIdsToDelete.includes(task.statusId));
TASK_DUMMY.length = 0;
TASK_DUMMY.push(...filteredTasks);
if (TASK_DUMMY.length !== filteredTasks.length) {
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;
});
TASK_USER_DUMMY.length = 0;
TASK_USER_DUMMY.push(...filteredTaskUsers);
if (TASK_USER_DUMMY.length !== filteredTaskUsers.length) {
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;
});
TASK_FILE_DUMMY.length = 0;
TASK_FILE_DUMMY.push(...filteredTaskFiles);
if (TASK_FILE_DUMMY.length !== filteredTaskFiles.length) {
TASK_FILE_DUMMY.length = 0;
TASK_FILE_DUMMY.push(...filteredTaskFiles);
}

return new HttpResponse(null, { status: 204 });
}),
Expand Down
4 changes: 2 additions & 2 deletions src/pages/team/TeamPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default function TeamPage() {
const { joinedTeamList, isLoading } = useReadTeams();
const [selectedProjectId, setSelectedProjectId] = useState<Project['projectId'] | null>(null);

const { mutate: deleteProject } = useDeleteProject(Number(teamId));
const { mutate: deleteProjectMutate } = useDeleteProject(Number(teamId));

const team = joinedTeamList.find((team) => team.teamId.toString() === teamId);
const teamName = team ? team.teamName : '';
Expand All @@ -31,7 +31,7 @@ export default function TeamPage() {

const handleDeleteClick = (e: React.MouseEvent, projectId: Project['projectId']) => {
e.preventDefault();
deleteProject(projectId);
deleteProjectMutate(projectId);
};

if (isProjectLoading || isLoading) {
Expand Down
4 changes: 2 additions & 2 deletions src/services/projectService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ export async function getProjectUserRoleList(projectId: Project['projectId'], ax
* @async
* @param {Project['projectId']} projectId - 프로젝트 ID
* @param {AxiosRequestConfig} [axiosConfig={}] - axios 요청 옵션 설정 객체
* @returns {Promise<AxiosResponse<void>>}
* @returns {Promise<void>}
*/
export async function deleteProject(projectId: Project['projectId'], axiosConfig: AxiosRequestConfig = {}) {
return authAxios.delete<AxiosResponse<void>>(`/project/${projectId}`, axiosConfig);
return authAxios.delete<void>(`/project/${projectId}`, axiosConfig);
}

0 comments on commit ff327b3

Please sign in to comment.