forked from prography/10th-Motimo-FE
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhooks.ts
More file actions
173 lines (153 loc) · 4.86 KB
/
hooks.ts
File metadata and controls
173 lines (153 loc) · 4.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
import { SWRConfiguration } from "swr";
import { useApiQuery } from "./useApiQuery";
import { GetGroupChatParamsDirectionEnum } from "./generated/motimo/Api";
export const useQuery = {
// Todo API
myTodos: (config?: SWRConfiguration) =>
useApiQuery("투두Api", "getMyTodos", [], undefined, config),
todoResult: (todoId: string | null, config?: SWRConfiguration) =>
useApiQuery(
"투두Api",
"getTodoResult",
todoId ? [todoId] : null,
undefined,
config,
),
// Goal API
goals: (config?: SWRConfiguration) =>
useApiQuery("목표Api", "getGoalList", [], undefined, config),
goalDetail: (goalId: string | null, config?: SWRConfiguration) =>
useApiQuery(
"목표Api",
"getGoalDetail",
goalId ? [goalId] : null,
undefined,
config,
),
goalWithSubGoals: (goalId: string | null, config?: SWRConfiguration) =>
useApiQuery(
"목표Api",
"getGoalWithSubGoalAndTodos",
goalId ? [goalId] : null,
undefined,
config,
),
goalsNotInGroup: (config?: SWRConfiguration) =>
useApiQuery("목표Api", "getGoalNotJoinGroup", [], undefined, config),
// Sub Goal API
subGoalTodos: (
subGoalId: string | null,
offset: number = 0,
size: number = 10,
config?: SWRConfiguration,
) =>
useApiQuery(
"세부목표Api",
"getIncompleteOrTodayTodosWithSlice",
subGoalId ? [subGoalId, { offset, size }] : null,
undefined,
config,
),
// Sub Goal API - All todos (complete and incomplete)
allSubGoalTodos: (
subGoalId: string | null,
offset: number = 0,
size: number = 10,
config?: SWRConfiguration,
) =>
useApiQuery(
"세부목표Api",
"getTodosBySubGoalIdWithSlice",
subGoalId ? [subGoalId, { offset, size }] : null,
undefined,
config,
),
// User API
myProfile: (config?: SWRConfiguration) =>
useApiQuery("사용자Api", "getMyProfile", [], undefined, config),
// Group API
groupMembers: (groupId: string | null, config?: SWRConfiguration) =>
useApiQuery(
"그룹Api",
"getGroupMembers",
groupId ? [groupId] : null,
undefined,
config,
),
groupChat: (
groupId: string | null,
limit?: string,
cursor?: string,
direction?: GetGroupChatParamsDirectionEnum,
config?: SWRConfiguration,
) =>
useApiQuery(
"그룹Api",
"getGroupChat",
groupId ? [groupId, { limit, cursor, direction }] : null,
undefined,
config,
),
groupDetail: (groupId: string | null, config?: SWRConfiguration) =>
useApiQuery(
"그룹Api",
"getGroupDetail",
groupId ? [groupId] : null,
undefined,
config,
),
newGroupMessages: (
groupId: string | null,
latestCursor?: string,
config?: SWRConfiguration,
) =>
useApiQuery(
"그룹Api",
"getNewGroupMessages",
groupId ? [groupId, { latestCursor }] : null,
undefined,
config,
),
joinedGroups: (config?: SWRConfiguration) =>
useApiQuery("그룹Api", "getJoinedGroups", [], undefined, config),
// Point & Cheer API
points: (config?: SWRConfiguration) =>
useApiQuery("포인트Api", "getPoint", [], undefined, config),
cheerPhrase: (config?: SWRConfiguration) =>
useApiQuery("응원Api", "getCheerPhrase", [], undefined, config),
// Completed Goals API
completedGoals: (config?: SWRConfiguration) =>
useApiQuery("목표Api", "getCompletedGoals", [], undefined, config),
// Health API
health: (config?: SWRConfiguration) =>
useApiQuery("healthController", "health", [], undefined, config),
// Notification API
notifications: (page: number = 0, size: number, config?: SWRConfiguration) =>
useApiQuery(
"알림Api",
"getNotificationList",
[{ page, size }],
undefined,
config,
),
};
// Legacy hooks for backward compatibility (이전 방식과 호환성 유지)
export const useTodos = useQuery.myTodos;
export const useTodoResult = useQuery.todoResult;
export const useGoals = useQuery.goals;
export const useGoalDetail = useQuery.goalDetail;
export const useGoalWithSubGoals = useQuery.goalWithSubGoals;
export const useGoalsNotInGroup = useQuery.goalsNotInGroup;
export const useSubGoalTodos = useQuery.subGoalTodos;
export const useMyProfile = useQuery.myProfile;
export const useGroupMembers = useQuery.groupMembers;
export const useGroupChat = useQuery.groupChat;
export const useGroupDetail = useQuery.groupDetail;
export const useNewGroupMessages = useQuery.newGroupMessages;
export const useJoinedGroups = useQuery.joinedGroups;
export const usePoints = useQuery.points;
export const useCheerPhrase = useQuery.cheerPhrase;
export const useNotifications = useQuery.notifications;
export const useCompletedGoals = useQuery.completedGoals;
export const useHealth = useQuery.health;
export const useAllSubGoalTodos = useQuery.allSubGoalTodos;