Skip to content

Commit a020c9e

Browse files
Merge branch 'develop' of https://github.com/SOPT-36-NINEDOT/NINEDOT-CLIENT into refactor/#204/aiFailModal
2 parents bffc9ab + cf41fac commit a020c9e

36 files changed

+918
-1127
lines changed

src/api/constant/queryKey.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ export const QUERY_KEY = {
1313
DELETE_ONBOARDING_CORE_GOAL: ['deleteOnboardingCoreGoal'],
1414
POST_AI_RECOMMEND_CORE_GOAL: ['postAiRecommendCoreGoal'],
1515
POST_AI_RECOMMEND_TO_CORE_GOALS: ['postAiRecommendToCoreGoals'],
16+
POST_ONBOARDING_SUB_GOAL: ['postOnboardingSubGoal'],
17+
PATCH_ONBOARDING_SUB_GOAL: ['patchOnboardingSubGoal'],
18+
DELETE_ONBOARDING_SUB_GOAL: ['deleteOnboardingSubGoal'],
19+
POST_AI_RECOMMEND_SUB_GOAL: ['postAiRecommendSubGoal'],
20+
POST_AI_RECOMMEND_NEW_SUB_GOAL: ['postAiRecommendNewSubGoal'],
1621
HISTORY: (mandalartId: number) => ['mandalartHistoryList', mandalartId],
1722
STREAK: (mandalartId: number) => ['streaks', mandalartId],
1823
JOB_LIST: ['jobList'],

src/api/domain/edit/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ interface CoreGoalsResponse {
2424

2525
type CycleType = 'DAILY' | 'WEEKLY' | 'ONCE';
2626

27-
interface SubGoal {
27+
export interface SubGoal {
2828
[x: string]: any;
2929
id: number;
3030
title: string;

src/api/domain/lowerTodo/hook.ts

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
import { useQuery, useMutation } from '@tanstack/react-query';
2+
3+
import {
4+
getMandalAll,
5+
getCoreGoals,
6+
getSubGoalIds,
7+
postOnboardingSubGoal,
8+
patchOnboardingSubGoal,
9+
deleteOnboardingSubGoal,
10+
postAiRecommendNewSubGoal,
11+
type SubGoalIdPosition,
12+
} from './index';
13+
14+
import { QUERY_KEY } from '@/api/constant/queryKey';
15+
16+
export const useGetMandalAll = (mandalartId: number) => {
17+
return useQuery({
18+
queryKey: [QUERY_KEY.ENTIRE_GOAL, mandalartId],
19+
queryFn: () => getMandalAll(mandalartId),
20+
enabled: !!mandalartId,
21+
});
22+
};
23+
24+
export const useGetCoreGoals = (mandalartId: number) => {
25+
return useQuery({
26+
queryKey: [QUERY_KEY.CORE_GOALS, mandalartId],
27+
queryFn: () => getCoreGoals(mandalartId),
28+
enabled: !!mandalartId,
29+
});
30+
};
31+
32+
export const useGetSubGoalIds = (coreGoalId: number) => {
33+
return useQuery<{ subGoalIds: SubGoalIdPosition[] }>({
34+
queryKey: QUERY_KEY.SUB_GOAL_IDS(coreGoalId),
35+
queryFn: () => getSubGoalIds(coreGoalId),
36+
enabled: !!coreGoalId && coreGoalId > 0,
37+
retry: false,
38+
});
39+
};
40+
41+
export const usePostOnboardingSubGoal = () => {
42+
return useMutation({
43+
mutationKey: QUERY_KEY.POST_ONBOARDING_SUB_GOAL,
44+
mutationFn: ({
45+
coreGoalId,
46+
title,
47+
position,
48+
cycle,
49+
}: {
50+
coreGoalId: number;
51+
title: string;
52+
position: number;
53+
cycle: string;
54+
}) => postOnboardingSubGoal(coreGoalId, { title, position, cycle }),
55+
});
56+
};
57+
58+
export const usePatchOnboardingSubGoal = () => {
59+
return useMutation({
60+
mutationKey: QUERY_KEY.PATCH_ONBOARDING_SUB_GOAL,
61+
mutationFn: (params: { subGoalId: number; title: string; cycle: string }) =>
62+
patchOnboardingSubGoal(params),
63+
});
64+
};
65+
66+
export const useDeleteOnboardingSubGoal = () => {
67+
return useMutation({
68+
mutationKey: QUERY_KEY.DELETE_ONBOARDING_SUB_GOAL,
69+
mutationFn: (subGoalId: number) => deleteOnboardingSubGoal(subGoalId),
70+
});
71+
};
72+
73+
export const usePostAiRecommendNewSubGoal = () => {
74+
return useMutation({
75+
mutationKey: QUERY_KEY.POST_AI_RECOMMEND_NEW_SUB_GOAL,
76+
mutationFn: async ({
77+
coreGoalId,
78+
coreGoal,
79+
subGoal,
80+
}: {
81+
coreGoalId: number;
82+
coreGoal: string;
83+
subGoal: { title: string }[];
84+
}) => {
85+
const response = await postAiRecommendNewSubGoal(coreGoalId, { coreGoal, subGoal });
86+
return response;
87+
},
88+
});
89+
};

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

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

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

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

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

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

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

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

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

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

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

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

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

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

0 commit comments

Comments
 (0)