Skip to content

Commit 52bee62

Browse files
Merge pull request #180 from SOPT-36-NINEDOT/refactor/#179/entireTodo
Refactor: 전체 목표 뷰 리팩토링
2 parents 1925766 + 472216d commit 52bee62

File tree

27 files changed

+151
-137
lines changed

27 files changed

+151
-137
lines changed

eslint.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export default tseslint.config(
4040
...reactHooks.configs.recommended.rules,
4141
...jsxA11y.configs.recommended.rules,
4242
'react/react-in-jsx-scope': 'off',
43-
'no-console': 'warn',
43+
'no-console': 'off',
4444
'no-unused-vars': 'off',
4545
'@typescript-eslint/no-unused-vars': 'warn',
4646
curly: 'error',
@@ -52,7 +52,7 @@ export default tseslint.config(
5252
},
5353
],
5454
'react/self-closing-comp': 'warn',
55-
'@typescript-eslint/no-explicit-any': 'warn',
55+
'@typescript-eslint/no-explicit-any': 'off',
5656
'react/jsx-pascal-case': 'error',
5757
'react-refresh/only-export-components': ['warn', { allowConstantExport: true }],
5858
'prettier/prettier': [

src/api/axiosInstance.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import axios from 'axios';
2+
23
import { HTTP_STATUS } from '@/api/constant/httpStatus';
34

45
const axiosInstance = axios.create({
@@ -28,11 +29,11 @@ axiosInstance.interceptors.response.use(
2829
const { status } = error.response;
2930

3031
if (status === HTTP_STATUS.UNAUTHORIZED) {
31-
console.warn('인증 실패');
32+
// 인증 실패 처리
3233
}
3334

3435
if (status === HTTP_STATUS.INTERNAL_SERVER_ERROR) {
35-
console.error('서버 오류가 발생');
36+
// 서버 오류 처리
3637
}
3738
}
3839
return Promise.reject(error);

src/api/constant/queryKey.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export const QUERY_KEY = {
2-
OVERALL_TODO: ['overallTodo'],
2+
ENTIRE_TODO: ['entireTodo'],
33
MANDALART_CORE_GOALS: (mandalartId: number) => ['mandalartCoreGoals', mandalartId],
44
MANDALART_SUB_GOALS: (mandalartId: number, coreGoalId?: number, cycle?: string) =>
55
['mandalartSubGoals', mandalartId, coreGoalId, cycle].filter(Boolean),
@@ -22,6 +22,6 @@ export const QUERY_KEY = {
2222
PERSONA: 'persona',
2323
UPDATE_SUB_GOAL: (id: number) => ['updateSubGoal', id],
2424
DELETE_SUB_GOAL: (id: number) => ['deleteSubGoal', id],
25-
OVERALL_GOAL: ['overallGoal'],
25+
ENTIRE_GOAL: ['entireGoal'],
2626
USER_INFO: ['userInfo'],
2727
} as const;

src/api/domain/edit/hook.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export const useUpdateSubGoal = (mandalartId: number) => {
4343

4444
return useMutation({
4545
mutationFn: (data: UpdateSubGoalRequest) => updateSubGoal(mandalartId, data),
46-
onSuccess: (_) => {
46+
onSuccess: () => {
4747
queryClient.invalidateQueries({
4848
queryKey: [...QUERY_KEY.MANDAL_ALL, mandalartId],
4949
exact: true,

src/api/domain/entireTodo/hook.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { useMutation, type UseMutationOptions } from '@tanstack/react-query';
2+
3+
import {
4+
postEntireTodo,
5+
type CreateEntireTodoRequest,
6+
type CreateEntireTodoResponse,
7+
} from '@/api/domain/entireTodo';
8+
import { QUERY_KEY } from '@/api/constant/queryKey';
9+
10+
export const useCreateEntireTodo = (
11+
options?: UseMutationOptions<CreateEntireTodoResponse, unknown, CreateEntireTodoRequest>,
12+
) => {
13+
return useMutation<CreateEntireTodoResponse, unknown, CreateEntireTodoRequest>({
14+
mutationKey: [...QUERY_KEY.ENTIRE_TODO, 'create'],
15+
mutationFn: postEntireTodo,
16+
...options,
17+
});
18+
};

src/api/domain/entireTodo/hook/useCreateMandalart.tsx

Lines changed: 0 additions & 23 deletions
This file was deleted.

src/api/domain/entireTodo/index.ts

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
import axiosInstance from '@/api/axiosInstance';
22
import { END_POINT } from '@/api/constant/endPoint';
3-
import type { BaseResponse } from '@/type/api';
4-
import type {
5-
CreateOverallTodoRequest,
6-
CreateOverallTodoResponse,
7-
} from '@/api/domain/entireTodo/type/entireTodo';
83

9-
export const postOverallTodo = async (
10-
body: CreateOverallTodoRequest,
11-
): Promise<BaseResponse<CreateOverallTodoResponse>> => {
12-
const res = await axiosInstance.post<BaseResponse<CreateOverallTodoResponse>>(
13-
END_POINT.MANDALART,
14-
body,
15-
);
16-
return res.data;
4+
export interface CreateEntireTodoRequest {
5+
title: string;
6+
}
7+
8+
export interface CreateEntireTodoResponse {
9+
id: number;
10+
title: string;
11+
}
12+
13+
export const postEntireTodo = async (
14+
body: CreateEntireTodoRequest,
15+
): Promise<CreateEntireTodoResponse> => {
16+
const res = await axiosInstance.post<{
17+
data: CreateEntireTodoResponse;
18+
}>(END_POINT.MANDALART, body);
19+
return res.data.data;
1720
};

src/api/domain/entireTodo/type/entireTodo.ts

Lines changed: 0 additions & 8 deletions
This file was deleted.

src/api/domain/lowerTodo/hook/useOverallGoal.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { QUERY_KEY } from '@/api/constant/queryKey';
66

77
export const useOverallGoal = (mandalartId: number) => {
88
return useQuery({
9-
queryKey: [QUERY_KEY.OVERALL_GOAL, mandalartId],
9+
queryKey: [QUERY_KEY.ENTIRE_GOAL, mandalartId],
1010
queryFn: () => getOverallGoal(mandalartId),
1111
enabled: !!mandalartId,
1212
});

src/api/domain/myTodo/hook/useMyMandal.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ type MandalCoreGoalsResponse = BaseResponse<{
1717

1818
export const useGetMandalAll = (mandalartId: number) => {
1919
return useQuery({
20-
queryKey: [QUERY_KEY.OVERALL_TODO, mandalartId],
20+
queryKey: [QUERY_KEY.ENTIRE_GOAL, mandalartId],
2121
queryFn: () => getMandalAll(mandalartId),
2222
});
2323
};

0 commit comments

Comments
 (0)