Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/api/constant/queryKey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ export const QUERY_KEY = {
DELETE_ONBOARDING_CORE_GOAL: ['deleteOnboardingCoreGoal'],
POST_AI_RECOMMEND_CORE_GOAL: ['postAiRecommendCoreGoal'],
POST_AI_RECOMMEND_TO_CORE_GOALS: ['postAiRecommendToCoreGoals'],
POST_ONBOARDING_SUB_GOAL: ['postOnboardingSubGoal'],
PATCH_ONBOARDING_SUB_GOAL: ['patchOnboardingSubGoal'],
DELETE_ONBOARDING_SUB_GOAL: ['deleteOnboardingSubGoal'],
POST_AI_RECOMMEND_SUB_GOAL: ['postAiRecommendSubGoal'],
POST_AI_RECOMMEND_NEW_SUB_GOAL: ['postAiRecommendNewSubGoal'],
HISTORY: (mandalartId: number) => ['mandalartHistoryList', mandalartId],
STREAK: (mandalartId: number) => ['streaks', mandalartId],
JOB_LIST: ['jobList'],
Expand Down
2 changes: 1 addition & 1 deletion src/api/domain/edit/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ interface CoreGoalsResponse {

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

interface SubGoal {
export interface SubGoal {
[x: string]: any;
id: number;
title: string;
Expand Down
89 changes: 89 additions & 0 deletions src/api/domain/lowerTodo/hook.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
import { useQuery, useMutation } from '@tanstack/react-query';

import {
getMandalAll,
getCoreGoals,
getSubGoalIds,
postOnboardingSubGoal,
patchOnboardingSubGoal,
deleteOnboardingSubGoal,
postAiRecommendNewSubGoal,
type SubGoalIdPosition,
} from './index';

import { QUERY_KEY } from '@/api/constant/queryKey';

export const useGetMandalAll = (mandalartId: number) => {
return useQuery({
queryKey: [QUERY_KEY.ENTIRE_GOAL, mandalartId],
queryFn: () => getMandalAll(mandalartId),
enabled: !!mandalartId,
});
};

export const useGetCoreGoals = (mandalartId: number) => {
return useQuery({
queryKey: [QUERY_KEY.CORE_GOALS, mandalartId],
queryFn: () => getCoreGoals(mandalartId),
enabled: !!mandalartId,
});
};

export const useGetSubGoalIds = (coreGoalId: number) => {
return useQuery<{ subGoalIds: SubGoalIdPosition[] }>({
queryKey: QUERY_KEY.SUB_GOAL_IDS(coreGoalId),
queryFn: () => getSubGoalIds(coreGoalId),
enabled: !!coreGoalId && coreGoalId > 0,
retry: false,
});
};

export const usePostOnboardingSubGoal = () => {
return useMutation({
mutationKey: QUERY_KEY.POST_ONBOARDING_SUB_GOAL,
mutationFn: ({
coreGoalId,
title,
position,
cycle,
}: {
coreGoalId: number;
title: string;
position: number;
cycle: string;
}) => postOnboardingSubGoal(coreGoalId, { title, position, cycle }),
});
};

export const usePatchOnboardingSubGoal = () => {
return useMutation({
mutationKey: QUERY_KEY.PATCH_ONBOARDING_SUB_GOAL,
mutationFn: (params: { subGoalId: number; title: string; cycle: string }) =>
patchOnboardingSubGoal(params),
});
};

export const useDeleteOnboardingSubGoal = () => {
return useMutation({
mutationKey: QUERY_KEY.DELETE_ONBOARDING_SUB_GOAL,
mutationFn: (subGoalId: number) => deleteOnboardingSubGoal(subGoalId),
});
};

export const usePostAiRecommendNewSubGoal = () => {
return useMutation({
mutationKey: QUERY_KEY.POST_AI_RECOMMEND_NEW_SUB_GOAL,
mutationFn: async ({
coreGoalId,
coreGoal,
subGoal,
}: {
coreGoalId: number;
coreGoal: string;
subGoal: { title: string }[];
}) => {
const response = await postAiRecommendNewSubGoal(coreGoalId, { coreGoal, subGoal });
return response;
},
});
};
18 changes: 0 additions & 18 deletions src/api/domain/lowerTodo/hook/useAiRecommendSubGoal.ts

This file was deleted.

13 changes: 0 additions & 13 deletions src/api/domain/lowerTodo/hook/useCoreGoals.ts

This file was deleted.

31 changes: 0 additions & 31 deletions src/api/domain/lowerTodo/hook/useCreateSubGoal.ts

This file was deleted.

23 changes: 0 additions & 23 deletions src/api/domain/lowerTodo/hook/useDeleteSubGoal.ts

This file was deleted.

13 changes: 0 additions & 13 deletions src/api/domain/lowerTodo/hook/useOverallGoal.ts

This file was deleted.

13 changes: 0 additions & 13 deletions src/api/domain/lowerTodo/hook/useSubGoalIds.ts

This file was deleted.

14 changes: 0 additions & 14 deletions src/api/domain/lowerTodo/hook/useSubGoals.ts

This file was deleted.

24 changes: 0 additions & 24 deletions src/api/domain/lowerTodo/hook/useUpdateSubGoal.ts

This file was deleted.

Loading
Loading