@spotsdev/sdk 1.4.0 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +2139 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1718 -0
- package/dist/index.d.ts +1717 -36
- package/dist/index.js +1996 -64
- package/dist/index.js.map +1 -0
- package/package.json +21 -5
- package/dist/api/client.d.ts +0 -12
- package/dist/api/client.js +0 -72
- package/dist/api/entities.d.ts +0 -305
- package/dist/api/entities.js +0 -13
- package/dist/api/mutations/clubs.d.ts +0 -47
- package/dist/api/mutations/clubs.js +0 -97
- package/dist/api/mutations/conversations.d.ts +0 -45
- package/dist/api/mutations/conversations.js +0 -114
- package/dist/api/mutations/index.d.ts +0 -14
- package/dist/api/mutations/index.js +0 -40
- package/dist/api/mutations/notifications.d.ts +0 -38
- package/dist/api/mutations/notifications.js +0 -64
- package/dist/api/mutations/orders.d.ts +0 -73
- package/dist/api/mutations/orders.js +0 -114
- package/dist/api/mutations/posts.d.ts +0 -123
- package/dist/api/mutations/posts.js +0 -242
- package/dist/api/mutations/products.d.ts +0 -81
- package/dist/api/mutations/products.js +0 -98
- package/dist/api/mutations/redemptions.d.ts +0 -33
- package/dist/api/mutations/redemptions.js +0 -63
- package/dist/api/mutations/spots.d.ts +0 -93
- package/dist/api/mutations/spots.js +0 -167
- package/dist/api/mutations/users.d.ts +0 -73
- package/dist/api/mutations/users.js +0 -175
- package/dist/api/queries/auth.d.ts +0 -37
- package/dist/api/queries/auth.js +0 -61
- package/dist/api/queries/clubs.d.ts +0 -52
- package/dist/api/queries/clubs.js +0 -116
- package/dist/api/queries/conversations.d.ts +0 -52
- package/dist/api/queries/conversations.js +0 -83
- package/dist/api/queries/index.d.ts +0 -28
- package/dist/api/queries/index.js +0 -69
- package/dist/api/queries/misc.d.ts +0 -30
- package/dist/api/queries/misc.js +0 -91
- package/dist/api/queries/notifications.d.ts +0 -34
- package/dist/api/queries/notifications.js +0 -62
- package/dist/api/queries/orders.d.ts +0 -45
- package/dist/api/queries/orders.js +0 -93
- package/dist/api/queries/posts.d.ts +0 -92
- package/dist/api/queries/posts.js +0 -233
- package/dist/api/queries/products.d.ts +0 -48
- package/dist/api/queries/products.js +0 -87
- package/dist/api/queries/spots.d.ts +0 -93
- package/dist/api/queries/spots.js +0 -250
- package/dist/api/queries/templates.d.ts +0 -39
- package/dist/api/queries/templates.js +0 -81
- package/dist/api/queries/users.d.ts +0 -104
- package/dist/api/queries/users.js +0 -235
- package/dist/api/queries/wallet.d.ts +0 -109
- package/dist/api/queries/wallet.js +0 -136
- package/dist/api/services/index.d.ts +0 -2
- package/dist/api/services/index.js +0 -8
- package/dist/api/services/marketplace.d.ts +0 -129
- package/dist/api/services/marketplace.js +0 -168
- package/dist/api/types.d.ts +0 -57
- package/dist/api/types.js +0 -33
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,2139 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var axios = require('axios');
|
|
4
|
+
var types_star = require('@spotsdev/types');
|
|
5
|
+
var reactQuery = require('@tanstack/react-query');
|
|
6
|
+
|
|
7
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
8
|
+
|
|
9
|
+
function _interopNamespace(e) {
|
|
10
|
+
if (e && e.__esModule) return e;
|
|
11
|
+
var n = Object.create(null);
|
|
12
|
+
if (e) {
|
|
13
|
+
Object.keys(e).forEach(function (k) {
|
|
14
|
+
if (k !== 'default') {
|
|
15
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
16
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
get: function () { return e[k]; }
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
n.default = e;
|
|
24
|
+
return Object.freeze(n);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
var axios__default = /*#__PURE__*/_interopDefault(axios);
|
|
28
|
+
var types_star__namespace = /*#__PURE__*/_interopNamespace(types_star);
|
|
29
|
+
|
|
30
|
+
var __defProp = Object.defineProperty;
|
|
31
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
32
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
33
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
34
|
+
var __export = (target, all) => {
|
|
35
|
+
for (var name in all)
|
|
36
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
37
|
+
};
|
|
38
|
+
var __copyProps = (to, from, except, desc) => {
|
|
39
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
40
|
+
for (let key of __getOwnPropNames(from))
|
|
41
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
42
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
43
|
+
}
|
|
44
|
+
return to;
|
|
45
|
+
};
|
|
46
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget);
|
|
47
|
+
|
|
48
|
+
// src/index.ts
|
|
49
|
+
var index_exports = {};
|
|
50
|
+
__export(index_exports, {
|
|
51
|
+
clubKeys: () => clubKeys,
|
|
52
|
+
configureSDK: () => configureSDK,
|
|
53
|
+
conversationKeys: () => conversationKeys,
|
|
54
|
+
getApiClient: () => getApiClient,
|
|
55
|
+
getConfig: () => getConfig,
|
|
56
|
+
miscKeys: () => miscKeys,
|
|
57
|
+
notificationKeys: () => notificationKeys,
|
|
58
|
+
orderKeys: () => orderKeys,
|
|
59
|
+
postKeys: () => postKeys,
|
|
60
|
+
productKeys: () => productKeys,
|
|
61
|
+
spotKeys: () => spotKeys,
|
|
62
|
+
templateKeys: () => templateKeys,
|
|
63
|
+
useAdjustStock: () => useAdjustStock,
|
|
64
|
+
useBlockUser: () => useBlockUser,
|
|
65
|
+
useBlockedUsers: () => useBlockedUsers,
|
|
66
|
+
useCancelOrder: () => useCancelOrder,
|
|
67
|
+
useCities: () => useCities,
|
|
68
|
+
useClaimSpot: () => useClaimSpot,
|
|
69
|
+
useClub: () => useClub,
|
|
70
|
+
useClubBySlug: () => useClubBySlug,
|
|
71
|
+
useClubMembership: () => useClubMembership,
|
|
72
|
+
useClubsBySpot: () => useClubsBySpot,
|
|
73
|
+
useClubsByUser: () => useClubsByUser,
|
|
74
|
+
useCompleteOnboardingStep: () => useCompleteOnboardingStep,
|
|
75
|
+
useConversation: () => useConversation,
|
|
76
|
+
useConversationMessages: () => useConversationMessages,
|
|
77
|
+
useConversations: () => useConversations,
|
|
78
|
+
useCreateClub: () => useCreateClub,
|
|
79
|
+
useCreateCoinbaseCharge: () => useCreateCoinbaseCharge,
|
|
80
|
+
useCreateConversation: () => useCreateConversation,
|
|
81
|
+
useCreateDirectConversation: () => useCreateDirectConversation,
|
|
82
|
+
useCreateOrder: () => useCreateOrder,
|
|
83
|
+
useCreatePost: () => useCreatePost,
|
|
84
|
+
useCreateProduct: () => useCreateProduct,
|
|
85
|
+
useCreateReply: () => useCreateReply,
|
|
86
|
+
useCreateSpot: () => useCreateSpot,
|
|
87
|
+
useCreateStripeIntent: () => useCreateStripeIntent,
|
|
88
|
+
useCurrentUser: () => useCurrentUser,
|
|
89
|
+
useDeleteAccount: () => useDeleteAccount,
|
|
90
|
+
useDeletePost: () => useDeletePost,
|
|
91
|
+
useDeleteProduct: () => useDeleteProduct,
|
|
92
|
+
useDeleteReply: () => useDeleteReply,
|
|
93
|
+
useFavoriteSpot: () => useFavoriteSpot,
|
|
94
|
+
useFulfillPost: () => useFulfillPost,
|
|
95
|
+
useInfiniteSpots: () => useInfiniteSpots,
|
|
96
|
+
useJoinClub: () => useJoinClub,
|
|
97
|
+
useLeaveClub: () => useLeaveClub,
|
|
98
|
+
useLifeSituations: () => useLifeSituations,
|
|
99
|
+
useMarkConversationAsRead: () => useMarkConversationAsRead,
|
|
100
|
+
useMarkNotificationsRead: () => useMarkNotificationsRead,
|
|
101
|
+
useMyOrders: () => useMyOrders,
|
|
102
|
+
useNotifications: () => useNotifications,
|
|
103
|
+
useOrder: () => useOrder,
|
|
104
|
+
useOwnedSpots: () => useOwnedSpots,
|
|
105
|
+
usePost: () => usePost,
|
|
106
|
+
usePostResponses: () => usePostResponses,
|
|
107
|
+
usePostStatus: () => usePostStatus,
|
|
108
|
+
usePostUpvotes: () => usePostUpvotes,
|
|
109
|
+
usePosts: () => usePosts,
|
|
110
|
+
usePostsFeed: () => usePostsFeed,
|
|
111
|
+
useProduct: () => useProduct,
|
|
112
|
+
useProductBySlug: () => useProductBySlug,
|
|
113
|
+
useRateSpot: () => useRateSpot,
|
|
114
|
+
useRedeem: () => useRedeem,
|
|
115
|
+
useRedemptionLookup: () => useRedemptionLookup,
|
|
116
|
+
useRefreshToken: () => useRefreshToken,
|
|
117
|
+
useRegisterDeviceToken: () => useRegisterDeviceToken,
|
|
118
|
+
useRemoveDeviceToken: () => useRemoveDeviceToken,
|
|
119
|
+
useReportPost: () => useReportPost,
|
|
120
|
+
useReportSpot: () => useReportSpot,
|
|
121
|
+
useRespondToPost: () => useRespondToPost,
|
|
122
|
+
useSendMessage: () => useSendMessage,
|
|
123
|
+
useSendOtp: () => useSendOtp,
|
|
124
|
+
useSendTypingIndicator: () => useSendTypingIndicator,
|
|
125
|
+
useSpot: () => useSpot,
|
|
126
|
+
useSpotByQR: () => useSpotByQR,
|
|
127
|
+
useSpotBySlug: () => useSpotBySlug,
|
|
128
|
+
useSpotFavoriteStatus: () => useSpotFavoriteStatus,
|
|
129
|
+
useSpotImages: () => useSpotImages,
|
|
130
|
+
useSpotOrders: () => useSpotOrders,
|
|
131
|
+
useSpotPosts: () => useSpotPosts,
|
|
132
|
+
useSpotProducts: () => useSpotProducts,
|
|
133
|
+
useSpotRedemptions: () => useSpotRedemptions,
|
|
134
|
+
useSpots: () => useSpots,
|
|
135
|
+
useSubscribeToSpot: () => useSubscribeToSpot,
|
|
136
|
+
useTemplate: () => useTemplate,
|
|
137
|
+
useTemplateBySlug: () => useTemplateBySlug,
|
|
138
|
+
useTemplates: () => useTemplates,
|
|
139
|
+
useUnblockUser: () => useUnblockUser,
|
|
140
|
+
useUnreadNotificationCount: () => useUnreadNotificationCount,
|
|
141
|
+
useUnsubscribeFromSpot: () => useUnsubscribeFromSpot,
|
|
142
|
+
useUpdateClub: () => useUpdateClub,
|
|
143
|
+
useUpdateInterests: () => useUpdateInterests,
|
|
144
|
+
useUpdateOrderStatus: () => useUpdateOrderStatus,
|
|
145
|
+
useUpdatePost: () => useUpdatePost,
|
|
146
|
+
useUpdatePostStatus: () => useUpdatePostStatus,
|
|
147
|
+
useUpdateProduct: () => useUpdateProduct,
|
|
148
|
+
useUpdateProfile: () => useUpdateProfile,
|
|
149
|
+
useUpdateResponse: () => useUpdateResponse,
|
|
150
|
+
useUpdateSpot: () => useUpdateSpot,
|
|
151
|
+
useUpdateVibes: () => useUpdateVibes,
|
|
152
|
+
useUploadAvatar: () => useUploadAvatar,
|
|
153
|
+
useUpvotePost: () => useUpvotePost,
|
|
154
|
+
useUserActivity: () => useUserActivity,
|
|
155
|
+
useUserClubs: () => useUserClubs,
|
|
156
|
+
useUserFavorites: () => useUserFavorites,
|
|
157
|
+
useUserPosts: () => useUserPosts,
|
|
158
|
+
useUserSpotsSummary: () => useUserSpotsSummary,
|
|
159
|
+
useUserStats: () => useUserStats,
|
|
160
|
+
useUserSubscriptions: () => useUserSubscriptions,
|
|
161
|
+
useVerifyOtp: () => useVerifyOtp,
|
|
162
|
+
useVibes: () => useVibes,
|
|
163
|
+
useVoidRedemption: () => useVoidRedemption,
|
|
164
|
+
useWallet: () => useWallet,
|
|
165
|
+
useWalletHistory: () => useWalletHistory,
|
|
166
|
+
userKeys: () => userKeys,
|
|
167
|
+
walletKeys: () => walletKeys
|
|
168
|
+
});
|
|
169
|
+
var config = null;
|
|
170
|
+
var apiClient = null;
|
|
171
|
+
function configureSDK(sdkConfig) {
|
|
172
|
+
config = sdkConfig;
|
|
173
|
+
apiClient = createApiClient(sdkConfig);
|
|
174
|
+
}
|
|
175
|
+
function getApiClient() {
|
|
176
|
+
if (!apiClient) {
|
|
177
|
+
throw new Error("SDK not configured. Call configureSDK() first.");
|
|
178
|
+
}
|
|
179
|
+
return apiClient;
|
|
180
|
+
}
|
|
181
|
+
function getConfig() {
|
|
182
|
+
if (!config) {
|
|
183
|
+
throw new Error("SDK not configured. Call configureSDK() first.");
|
|
184
|
+
}
|
|
185
|
+
return config;
|
|
186
|
+
}
|
|
187
|
+
function createApiClient(sdkConfig) {
|
|
188
|
+
const client = axios__default.default.create({
|
|
189
|
+
baseURL: sdkConfig.baseURL,
|
|
190
|
+
headers: {
|
|
191
|
+
"Content-Type": "application/json"
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
client.interceptors.request.use(
|
|
195
|
+
async (requestConfig) => {
|
|
196
|
+
const token = await sdkConfig.getAccessToken();
|
|
197
|
+
if (token) {
|
|
198
|
+
requestConfig.headers.Authorization = `Bearer ${token}`;
|
|
199
|
+
}
|
|
200
|
+
console.log(
|
|
201
|
+
`[SDK] ${requestConfig.method?.toUpperCase()} ${sdkConfig.baseURL}${requestConfig.url}`
|
|
202
|
+
);
|
|
203
|
+
return requestConfig;
|
|
204
|
+
},
|
|
205
|
+
(error) => Promise.reject(error)
|
|
206
|
+
);
|
|
207
|
+
client.interceptors.response.use(
|
|
208
|
+
(response) => response,
|
|
209
|
+
async (error) => {
|
|
210
|
+
console.log(
|
|
211
|
+
`[SDK] Error: ${error.response?.status} ${error.config?.url}`,
|
|
212
|
+
error.message
|
|
213
|
+
);
|
|
214
|
+
if (error.response?.status === 401) {
|
|
215
|
+
if (sdkConfig.refreshAccessToken) {
|
|
216
|
+
try {
|
|
217
|
+
const newToken = await sdkConfig.refreshAccessToken();
|
|
218
|
+
if (newToken && error.config) {
|
|
219
|
+
error.config.headers.Authorization = `Bearer ${newToken}`;
|
|
220
|
+
return client.request(error.config);
|
|
221
|
+
}
|
|
222
|
+
} catch {
|
|
223
|
+
sdkConfig.onUnauthorized?.();
|
|
224
|
+
}
|
|
225
|
+
} else {
|
|
226
|
+
sdkConfig.onUnauthorized?.();
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
return Promise.reject(error);
|
|
230
|
+
}
|
|
231
|
+
);
|
|
232
|
+
return client;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
// src/api/types.ts
|
|
236
|
+
var types_exports = {};
|
|
237
|
+
__reExport(types_exports, types_star__namespace);
|
|
238
|
+
|
|
239
|
+
// src/index.ts
|
|
240
|
+
__reExport(index_exports, types_exports);
|
|
241
|
+
function useSendOtp(options) {
|
|
242
|
+
return reactQuery.useMutation({
|
|
243
|
+
mutationFn: async (data) => {
|
|
244
|
+
const client = getApiClient();
|
|
245
|
+
const response = await client.post(
|
|
246
|
+
"/auth/send-otp",
|
|
247
|
+
data
|
|
248
|
+
);
|
|
249
|
+
return response.data;
|
|
250
|
+
},
|
|
251
|
+
...options
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
function useVerifyOtp(options) {
|
|
255
|
+
return reactQuery.useMutation({
|
|
256
|
+
mutationFn: async (data) => {
|
|
257
|
+
const client = getApiClient();
|
|
258
|
+
const response = await client.post("/auth/verify-otp", data);
|
|
259
|
+
return response.data;
|
|
260
|
+
},
|
|
261
|
+
...options
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
function useRefreshToken(options) {
|
|
265
|
+
return reactQuery.useMutation({
|
|
266
|
+
mutationFn: async (data) => {
|
|
267
|
+
const client = getApiClient();
|
|
268
|
+
const response = await client.post(
|
|
269
|
+
"/auth/refresh",
|
|
270
|
+
data
|
|
271
|
+
);
|
|
272
|
+
return response.data;
|
|
273
|
+
},
|
|
274
|
+
...options
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
function extractArrayData(data) {
|
|
278
|
+
if (Array.isArray(data)) {
|
|
279
|
+
return data;
|
|
280
|
+
}
|
|
281
|
+
if (data && typeof data === "object" && "data" in data) {
|
|
282
|
+
const nested = data.data;
|
|
283
|
+
if (Array.isArray(nested)) {
|
|
284
|
+
return nested;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
return [];
|
|
288
|
+
}
|
|
289
|
+
var userKeys = {
|
|
290
|
+
all: ["users"],
|
|
291
|
+
me: () => [...userKeys.all, "me"],
|
|
292
|
+
stats: () => [...userKeys.me(), "stats"],
|
|
293
|
+
spotsSummary: () => [...userKeys.me(), "spots-summary"],
|
|
294
|
+
activity: (limit) => [...userKeys.me(), "activity", limit],
|
|
295
|
+
posts: (params) => [...userKeys.me(), "posts", params],
|
|
296
|
+
clubs: () => [...userKeys.me(), "clubs"],
|
|
297
|
+
subscriptions: () => [...userKeys.me(), "subscriptions"],
|
|
298
|
+
blocked: () => [...userKeys.me(), "blocked"],
|
|
299
|
+
ownedSpots: () => [...userKeys.me(), "owned-spots"],
|
|
300
|
+
favorites: () => [...userKeys.me(), "favorites"]
|
|
301
|
+
};
|
|
302
|
+
function useCurrentUser(options) {
|
|
303
|
+
return reactQuery.useQuery({
|
|
304
|
+
queryKey: userKeys.me(),
|
|
305
|
+
queryFn: async () => {
|
|
306
|
+
console.log("[SDK-USERS] Fetching /users/me...");
|
|
307
|
+
const client = getApiClient();
|
|
308
|
+
try {
|
|
309
|
+
const response = await client.get("/users/me");
|
|
310
|
+
console.log("[SDK-USERS] Success:", response.status);
|
|
311
|
+
return response.data.data;
|
|
312
|
+
} catch (error) {
|
|
313
|
+
const axiosError = error;
|
|
314
|
+
console.log(
|
|
315
|
+
"[SDK-USERS] Error:",
|
|
316
|
+
axiosError.response?.status,
|
|
317
|
+
"URL:",
|
|
318
|
+
axiosError.config?.baseURL,
|
|
319
|
+
axiosError.config?.url
|
|
320
|
+
);
|
|
321
|
+
throw error;
|
|
322
|
+
}
|
|
323
|
+
},
|
|
324
|
+
...options
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
function useUserStats(options) {
|
|
328
|
+
return reactQuery.useQuery({
|
|
329
|
+
queryKey: userKeys.stats(),
|
|
330
|
+
queryFn: async () => {
|
|
331
|
+
const client = getApiClient();
|
|
332
|
+
const response = await client.get("/users/me/stats");
|
|
333
|
+
return response.data.data;
|
|
334
|
+
},
|
|
335
|
+
...options
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
function useUserSpotsSummary(options) {
|
|
339
|
+
return reactQuery.useQuery({
|
|
340
|
+
queryKey: userKeys.spotsSummary(),
|
|
341
|
+
queryFn: async () => {
|
|
342
|
+
const client = getApiClient();
|
|
343
|
+
const response = await client.get(
|
|
344
|
+
"/users/me/spots-summary"
|
|
345
|
+
);
|
|
346
|
+
return response.data.data;
|
|
347
|
+
},
|
|
348
|
+
...options
|
|
349
|
+
});
|
|
350
|
+
}
|
|
351
|
+
function useUserActivity(limit = 10, options) {
|
|
352
|
+
return reactQuery.useQuery({
|
|
353
|
+
queryKey: userKeys.activity(limit),
|
|
354
|
+
queryFn: async () => {
|
|
355
|
+
const client = getApiClient();
|
|
356
|
+
const response = await client.get(
|
|
357
|
+
`/users/me/activity?limit=${limit}`
|
|
358
|
+
);
|
|
359
|
+
return extractArrayData(response.data.data);
|
|
360
|
+
},
|
|
361
|
+
...options
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
function useUserPosts(params, options) {
|
|
365
|
+
return reactQuery.useQuery({
|
|
366
|
+
queryKey: userKeys.posts(params),
|
|
367
|
+
queryFn: async () => {
|
|
368
|
+
const client = getApiClient();
|
|
369
|
+
const queryParams = new URLSearchParams();
|
|
370
|
+
if (params?.page) queryParams.set("page", String(params.page));
|
|
371
|
+
if (params?.limit) queryParams.set("limit", String(params.limit));
|
|
372
|
+
const response = await client.get(
|
|
373
|
+
`/user/me/posts?${queryParams}`
|
|
374
|
+
);
|
|
375
|
+
return extractArrayData(response.data.data);
|
|
376
|
+
},
|
|
377
|
+
...options
|
|
378
|
+
});
|
|
379
|
+
}
|
|
380
|
+
function useUserClubs(options) {
|
|
381
|
+
return reactQuery.useQuery({
|
|
382
|
+
queryKey: userKeys.clubs(),
|
|
383
|
+
queryFn: async () => {
|
|
384
|
+
const client = getApiClient();
|
|
385
|
+
const response = await client.get("/user/me/clubs");
|
|
386
|
+
return extractArrayData(response.data.data);
|
|
387
|
+
},
|
|
388
|
+
...options
|
|
389
|
+
});
|
|
390
|
+
}
|
|
391
|
+
function useUserSubscriptions(options) {
|
|
392
|
+
return reactQuery.useQuery({
|
|
393
|
+
queryKey: userKeys.subscriptions(),
|
|
394
|
+
queryFn: async () => {
|
|
395
|
+
const client = getApiClient();
|
|
396
|
+
const response = await client.get(
|
|
397
|
+
"/user/me/subscriptions"
|
|
398
|
+
);
|
|
399
|
+
return extractArrayData(response.data.data);
|
|
400
|
+
},
|
|
401
|
+
...options
|
|
402
|
+
});
|
|
403
|
+
}
|
|
404
|
+
function useBlockedUsers(options) {
|
|
405
|
+
return reactQuery.useQuery({
|
|
406
|
+
queryKey: userKeys.blocked(),
|
|
407
|
+
queryFn: async () => {
|
|
408
|
+
const client = getApiClient();
|
|
409
|
+
const response = await client.get("/user/me/blocked");
|
|
410
|
+
return extractArrayData(response.data.data);
|
|
411
|
+
},
|
|
412
|
+
...options
|
|
413
|
+
});
|
|
414
|
+
}
|
|
415
|
+
function useOwnedSpots(options) {
|
|
416
|
+
return reactQuery.useQuery({
|
|
417
|
+
queryKey: userKeys.ownedSpots(),
|
|
418
|
+
queryFn: async () => {
|
|
419
|
+
const client = getApiClient();
|
|
420
|
+
const response = await client.get(
|
|
421
|
+
"/users/me/owned-spots"
|
|
422
|
+
);
|
|
423
|
+
return extractArrayData(response.data.data);
|
|
424
|
+
},
|
|
425
|
+
...options
|
|
426
|
+
});
|
|
427
|
+
}
|
|
428
|
+
function useUserFavorites(options) {
|
|
429
|
+
return reactQuery.useQuery({
|
|
430
|
+
queryKey: userKeys.favorites(),
|
|
431
|
+
queryFn: async () => {
|
|
432
|
+
const client = getApiClient();
|
|
433
|
+
const response = await client.get(
|
|
434
|
+
"/users/me/favorites"
|
|
435
|
+
);
|
|
436
|
+
return extractArrayData(response.data.data);
|
|
437
|
+
},
|
|
438
|
+
...options
|
|
439
|
+
});
|
|
440
|
+
}
|
|
441
|
+
function extractArrayData2(data) {
|
|
442
|
+
if (Array.isArray(data)) {
|
|
443
|
+
return data;
|
|
444
|
+
}
|
|
445
|
+
if (data && typeof data === "object" && "data" in data) {
|
|
446
|
+
const nested = data.data;
|
|
447
|
+
if (Array.isArray(nested)) {
|
|
448
|
+
return nested;
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
return [];
|
|
452
|
+
}
|
|
453
|
+
function extractObjectData(data) {
|
|
454
|
+
if (data && typeof data === "object" && "data" in data && !Array.isArray(data)) {
|
|
455
|
+
const nested = data.data;
|
|
456
|
+
if (nested && typeof nested === "object" && "data" in nested && !Array.isArray(nested)) {
|
|
457
|
+
return nested.data;
|
|
458
|
+
}
|
|
459
|
+
return nested;
|
|
460
|
+
}
|
|
461
|
+
return data;
|
|
462
|
+
}
|
|
463
|
+
var spotKeys = {
|
|
464
|
+
all: ["spots"],
|
|
465
|
+
lists: () => [...spotKeys.all, "list"],
|
|
466
|
+
list: (filters) => [...spotKeys.lists(), filters],
|
|
467
|
+
details: () => [...spotKeys.all, "detail"],
|
|
468
|
+
detail: (id) => [...spotKeys.details(), id],
|
|
469
|
+
bySlug: (slug) => [...spotKeys.all, "slug", slug],
|
|
470
|
+
byQR: (qrCode) => [...spotKeys.all, "qr", qrCode],
|
|
471
|
+
images: (spotId) => [...spotKeys.detail(spotId), "images"]
|
|
472
|
+
};
|
|
473
|
+
function useSpots(params, options) {
|
|
474
|
+
return reactQuery.useQuery({
|
|
475
|
+
queryKey: spotKeys.list(params),
|
|
476
|
+
queryFn: async () => {
|
|
477
|
+
const client = getApiClient();
|
|
478
|
+
const queryParams = new URLSearchParams();
|
|
479
|
+
if (params?.limit) queryParams.set("limit", String(params.limit));
|
|
480
|
+
if (params?.city) queryParams.set("city", params.city);
|
|
481
|
+
if (params?.type) queryParams.set("type", params.type);
|
|
482
|
+
if (params?.lat) queryParams.set("lat", String(params.lat));
|
|
483
|
+
if (params?.lng) queryParams.set("lng", String(params.lng));
|
|
484
|
+
if (params?.radius) queryParams.set("radius", String(params.radius));
|
|
485
|
+
if (params?.search) queryParams.set("search", params.search);
|
|
486
|
+
if (params?.vibes) queryParams.set("vibeIds", params.vibes);
|
|
487
|
+
if (params?.cityId) queryParams.set("cityId", params.cityId);
|
|
488
|
+
if (params?.page) queryParams.set("page", String(params.page));
|
|
489
|
+
const response = await client.get(
|
|
490
|
+
`/spots?${queryParams}`
|
|
491
|
+
);
|
|
492
|
+
return extractArrayData2(response.data.data);
|
|
493
|
+
},
|
|
494
|
+
...options
|
|
495
|
+
});
|
|
496
|
+
}
|
|
497
|
+
function useSpot(spotId, options) {
|
|
498
|
+
return reactQuery.useQuery({
|
|
499
|
+
queryKey: spotKeys.detail(spotId),
|
|
500
|
+
queryFn: async () => {
|
|
501
|
+
const client = getApiClient();
|
|
502
|
+
const response = await client.get(
|
|
503
|
+
`/spots/${spotId}`
|
|
504
|
+
);
|
|
505
|
+
return extractObjectData(response.data.data);
|
|
506
|
+
},
|
|
507
|
+
enabled: !!spotId,
|
|
508
|
+
...options
|
|
509
|
+
});
|
|
510
|
+
}
|
|
511
|
+
function useSpotBySlug(slug, options) {
|
|
512
|
+
return reactQuery.useQuery({
|
|
513
|
+
queryKey: spotKeys.bySlug(slug),
|
|
514
|
+
queryFn: async () => {
|
|
515
|
+
const client = getApiClient();
|
|
516
|
+
const response = await client.get(
|
|
517
|
+
`/spots/slug/${slug}`
|
|
518
|
+
);
|
|
519
|
+
return extractObjectData(response.data.data);
|
|
520
|
+
},
|
|
521
|
+
enabled: !!slug,
|
|
522
|
+
...options
|
|
523
|
+
});
|
|
524
|
+
}
|
|
525
|
+
function useSpotByQR(qrCode, options) {
|
|
526
|
+
return reactQuery.useQuery({
|
|
527
|
+
queryKey: spotKeys.byQR(qrCode),
|
|
528
|
+
queryFn: async () => {
|
|
529
|
+
const client = getApiClient();
|
|
530
|
+
const response = await client.get(
|
|
531
|
+
`/spots/qr/${qrCode}`
|
|
532
|
+
);
|
|
533
|
+
return extractObjectData(response.data.data);
|
|
534
|
+
},
|
|
535
|
+
enabled: !!qrCode,
|
|
536
|
+
...options
|
|
537
|
+
});
|
|
538
|
+
}
|
|
539
|
+
function useSpotImages(spotId, options) {
|
|
540
|
+
return reactQuery.useQuery({
|
|
541
|
+
queryKey: spotKeys.images(spotId),
|
|
542
|
+
queryFn: async () => {
|
|
543
|
+
const client = getApiClient();
|
|
544
|
+
const response = await client.get(
|
|
545
|
+
`/spots/${spotId}/images`
|
|
546
|
+
);
|
|
547
|
+
return extractArrayData2(response.data.data);
|
|
548
|
+
},
|
|
549
|
+
enabled: !!spotId,
|
|
550
|
+
...options
|
|
551
|
+
});
|
|
552
|
+
}
|
|
553
|
+
function useSpotFavoriteStatus(spotId, options) {
|
|
554
|
+
return reactQuery.useQuery({
|
|
555
|
+
queryKey: [...spotKeys.detail(spotId), "favorite"],
|
|
556
|
+
queryFn: async () => {
|
|
557
|
+
const client = getApiClient();
|
|
558
|
+
const response = await client.get(
|
|
559
|
+
`/spots/${spotId}/favorite`
|
|
560
|
+
);
|
|
561
|
+
return extractObjectData(response.data.data);
|
|
562
|
+
},
|
|
563
|
+
enabled: !!spotId,
|
|
564
|
+
...options
|
|
565
|
+
});
|
|
566
|
+
}
|
|
567
|
+
function useInfiniteSpots(params, options) {
|
|
568
|
+
return reactQuery.useInfiniteQuery({
|
|
569
|
+
queryKey: [...spotKeys.lists(), "infinite", params],
|
|
570
|
+
queryFn: async ({ pageParam = 1 }) => {
|
|
571
|
+
const client = getApiClient();
|
|
572
|
+
const queryParams = new URLSearchParams();
|
|
573
|
+
queryParams.set("page", String(pageParam));
|
|
574
|
+
if (params?.limit) queryParams.set("limit", String(params.limit));
|
|
575
|
+
if (params?.city) queryParams.set("city", params.city);
|
|
576
|
+
if (params?.cityId) queryParams.set("cityId", params.cityId);
|
|
577
|
+
if (params?.type && params.type !== "All")
|
|
578
|
+
queryParams.set("type", params.type);
|
|
579
|
+
if (params?.search?.trim())
|
|
580
|
+
queryParams.set("search", params.search.trim());
|
|
581
|
+
if (params?.templateSlugs) {
|
|
582
|
+
params.templateSlugs.forEach(
|
|
583
|
+
(slug) => queryParams.append("templateSlugs", slug)
|
|
584
|
+
);
|
|
585
|
+
}
|
|
586
|
+
if (params?.vibeIds) {
|
|
587
|
+
params.vibeIds.forEach((id) => queryParams.append("vibeIds", id));
|
|
588
|
+
}
|
|
589
|
+
const response = await client.get(
|
|
590
|
+
`/spots?${queryParams}`
|
|
591
|
+
);
|
|
592
|
+
const data = response.data.data;
|
|
593
|
+
if (data && typeof data === "object" && "data" in data) {
|
|
594
|
+
return data;
|
|
595
|
+
}
|
|
596
|
+
const page = pageParam;
|
|
597
|
+
return {
|
|
598
|
+
data: extractArrayData2(data),
|
|
599
|
+
meta: {
|
|
600
|
+
total: 0,
|
|
601
|
+
page,
|
|
602
|
+
limit: params?.limit || 20,
|
|
603
|
+
totalPages: 1,
|
|
604
|
+
hasNextPage: false,
|
|
605
|
+
hasPreviousPage: page > 1
|
|
606
|
+
}
|
|
607
|
+
};
|
|
608
|
+
},
|
|
609
|
+
initialPageParam: 1,
|
|
610
|
+
getNextPageParam: (lastPage) => {
|
|
611
|
+
return lastPage.meta.hasNextPage ? lastPage.meta.page + 1 : void 0;
|
|
612
|
+
},
|
|
613
|
+
...options
|
|
614
|
+
});
|
|
615
|
+
}
|
|
616
|
+
function extractArrayData3(data) {
|
|
617
|
+
if (Array.isArray(data)) {
|
|
618
|
+
return data;
|
|
619
|
+
}
|
|
620
|
+
if (data && typeof data === "object" && "data" in data) {
|
|
621
|
+
const nested = data.data;
|
|
622
|
+
if (Array.isArray(nested)) {
|
|
623
|
+
return nested;
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
return [];
|
|
627
|
+
}
|
|
628
|
+
function extractObjectData2(data) {
|
|
629
|
+
if (data && typeof data === "object" && "data" in data && !Array.isArray(data)) {
|
|
630
|
+
const nested = data.data;
|
|
631
|
+
if (nested && typeof nested === "object" && "data" in nested && !Array.isArray(nested)) {
|
|
632
|
+
return nested.data;
|
|
633
|
+
}
|
|
634
|
+
return nested;
|
|
635
|
+
}
|
|
636
|
+
return data;
|
|
637
|
+
}
|
|
638
|
+
var postKeys = {
|
|
639
|
+
all: ["posts"],
|
|
640
|
+
lists: () => [...postKeys.all, "list"],
|
|
641
|
+
list: (filters) => [...postKeys.lists(), filters],
|
|
642
|
+
bySpot: (spotId, filters) => [...postKeys.all, "spot", spotId, filters],
|
|
643
|
+
details: () => [...postKeys.all, "detail"],
|
|
644
|
+
detail: (id) => [...postKeys.details(), id],
|
|
645
|
+
responses: (postId) => [...postKeys.detail(postId), "responses"],
|
|
646
|
+
status: (postId) => [...postKeys.detail(postId), "status"],
|
|
647
|
+
upvotes: (postId, filters) => [...postKeys.detail(postId), "upvotes", filters]
|
|
648
|
+
};
|
|
649
|
+
function useSpotPosts(spotId, params, options) {
|
|
650
|
+
return reactQuery.useQuery({
|
|
651
|
+
queryKey: postKeys.bySpot(spotId, params),
|
|
652
|
+
queryFn: async () => {
|
|
653
|
+
const client = getApiClient();
|
|
654
|
+
const queryParams = new URLSearchParams();
|
|
655
|
+
if (params?.postType) queryParams.set("postType", params.postType);
|
|
656
|
+
if (params?.status) queryParams.set("status", params.status);
|
|
657
|
+
if (params?.page) queryParams.set("page", String(params.page));
|
|
658
|
+
if (params?.limit) queryParams.set("limit", String(params.limit));
|
|
659
|
+
const response = await client.get(
|
|
660
|
+
`/spots/${spotId}/posts?${queryParams}`
|
|
661
|
+
);
|
|
662
|
+
return extractArrayData3(response.data.data);
|
|
663
|
+
},
|
|
664
|
+
enabled: !!spotId,
|
|
665
|
+
...options
|
|
666
|
+
});
|
|
667
|
+
}
|
|
668
|
+
function usePost(postId, options) {
|
|
669
|
+
return reactQuery.useQuery({
|
|
670
|
+
queryKey: postKeys.detail(postId),
|
|
671
|
+
queryFn: async () => {
|
|
672
|
+
const client = getApiClient();
|
|
673
|
+
const response = await client.get(
|
|
674
|
+
`/posts/${postId}`
|
|
675
|
+
);
|
|
676
|
+
return extractObjectData2(response.data.data);
|
|
677
|
+
},
|
|
678
|
+
enabled: !!postId,
|
|
679
|
+
...options
|
|
680
|
+
});
|
|
681
|
+
}
|
|
682
|
+
function usePostResponses(postId, options) {
|
|
683
|
+
return reactQuery.useQuery({
|
|
684
|
+
queryKey: postKeys.responses(postId),
|
|
685
|
+
queryFn: async () => {
|
|
686
|
+
const client = getApiClient();
|
|
687
|
+
const response = await client.get(
|
|
688
|
+
`/posts/${postId}/responses`
|
|
689
|
+
);
|
|
690
|
+
return extractArrayData3(response.data.data);
|
|
691
|
+
},
|
|
692
|
+
enabled: !!postId,
|
|
693
|
+
...options
|
|
694
|
+
});
|
|
695
|
+
}
|
|
696
|
+
function usePosts(params, options) {
|
|
697
|
+
return reactQuery.useQuery({
|
|
698
|
+
queryKey: postKeys.list(params),
|
|
699
|
+
queryFn: async () => {
|
|
700
|
+
const client = getApiClient();
|
|
701
|
+
const queryParams = new URLSearchParams();
|
|
702
|
+
if (params?.postType) queryParams.set("postType", params.postType);
|
|
703
|
+
if (params?.limit) queryParams.set("limit", String(params.limit));
|
|
704
|
+
const response = await client.get(
|
|
705
|
+
`/posts?${queryParams}`
|
|
706
|
+
);
|
|
707
|
+
return extractArrayData3(response.data.data);
|
|
708
|
+
},
|
|
709
|
+
...options
|
|
710
|
+
});
|
|
711
|
+
}
|
|
712
|
+
function usePostStatus(postId, options) {
|
|
713
|
+
return reactQuery.useQuery({
|
|
714
|
+
queryKey: postKeys.status(postId),
|
|
715
|
+
queryFn: async () => {
|
|
716
|
+
const client = getApiClient();
|
|
717
|
+
const response = await client.get(
|
|
718
|
+
`/posts/${postId}/status`
|
|
719
|
+
);
|
|
720
|
+
return extractObjectData2(response.data.data);
|
|
721
|
+
},
|
|
722
|
+
enabled: !!postId,
|
|
723
|
+
...options
|
|
724
|
+
});
|
|
725
|
+
}
|
|
726
|
+
function usePostUpvotes(postId, params, options) {
|
|
727
|
+
return reactQuery.useQuery({
|
|
728
|
+
queryKey: postKeys.upvotes(postId, params),
|
|
729
|
+
queryFn: async () => {
|
|
730
|
+
const client = getApiClient();
|
|
731
|
+
const queryParams = new URLSearchParams();
|
|
732
|
+
if (params?.limit) queryParams.set("limit", String(params.limit));
|
|
733
|
+
if (params?.offset) queryParams.set("offset", String(params.offset));
|
|
734
|
+
const queryString = queryParams.toString();
|
|
735
|
+
const response = await client.get(
|
|
736
|
+
`/posts/${postId}/upvotes${queryString ? `?${queryString}` : ""}`
|
|
737
|
+
);
|
|
738
|
+
return response.data.data;
|
|
739
|
+
},
|
|
740
|
+
enabled: !!postId,
|
|
741
|
+
...options
|
|
742
|
+
});
|
|
743
|
+
}
|
|
744
|
+
function usePostsFeed(params, options) {
|
|
745
|
+
return reactQuery.useQuery({
|
|
746
|
+
queryKey: [...postKeys.lists(), "feed", params],
|
|
747
|
+
queryFn: async () => {
|
|
748
|
+
const client = getApiClient();
|
|
749
|
+
const queryParams = new URLSearchParams();
|
|
750
|
+
queryParams.set("lat", String(params.lat));
|
|
751
|
+
queryParams.set("lng", String(params.lng));
|
|
752
|
+
if (params.radius) queryParams.set("radius", String(params.radius));
|
|
753
|
+
if (params.postType) queryParams.set("postType", params.postType);
|
|
754
|
+
if (params.cursor) queryParams.set("cursor", params.cursor);
|
|
755
|
+
if (params.limit) queryParams.set("limit", String(params.limit));
|
|
756
|
+
const response = await client.get(`/posts/feed?${queryParams}`);
|
|
757
|
+
const data = response.data.data;
|
|
758
|
+
return {
|
|
759
|
+
posts: data.posts ?? extractArrayData3(data),
|
|
760
|
+
hasMore: data.hasMore ?? false,
|
|
761
|
+
nextCursor: data.nextCursor
|
|
762
|
+
};
|
|
763
|
+
},
|
|
764
|
+
enabled: params.lat !== 0 && params.lng !== 0,
|
|
765
|
+
...options
|
|
766
|
+
});
|
|
767
|
+
}
|
|
768
|
+
var conversationKeys = {
|
|
769
|
+
all: ["conversations"],
|
|
770
|
+
lists: () => [...conversationKeys.all, "list"],
|
|
771
|
+
list: () => [...conversationKeys.lists()],
|
|
772
|
+
details: () => [...conversationKeys.all, "detail"],
|
|
773
|
+
detail: (id) => [...conversationKeys.details(), id],
|
|
774
|
+
messages: (conversationId, params) => [...conversationKeys.detail(conversationId), "messages", params]
|
|
775
|
+
};
|
|
776
|
+
function useConversations(options) {
|
|
777
|
+
return reactQuery.useQuery({
|
|
778
|
+
queryKey: conversationKeys.list(),
|
|
779
|
+
queryFn: async () => {
|
|
780
|
+
const client = getApiClient();
|
|
781
|
+
const response = await client.get("/conversations");
|
|
782
|
+
return response.data.data;
|
|
783
|
+
},
|
|
784
|
+
...options
|
|
785
|
+
});
|
|
786
|
+
}
|
|
787
|
+
function useConversation(conversationId, options) {
|
|
788
|
+
return reactQuery.useQuery({
|
|
789
|
+
queryKey: conversationKeys.detail(conversationId),
|
|
790
|
+
queryFn: async () => {
|
|
791
|
+
const client = getApiClient();
|
|
792
|
+
const response = await client.get(
|
|
793
|
+
`/conversations/${conversationId}`
|
|
794
|
+
);
|
|
795
|
+
return response.data.data;
|
|
796
|
+
},
|
|
797
|
+
enabled: !!conversationId,
|
|
798
|
+
...options
|
|
799
|
+
});
|
|
800
|
+
}
|
|
801
|
+
function useConversationMessages(conversationId, params, options) {
|
|
802
|
+
return reactQuery.useQuery({
|
|
803
|
+
queryKey: conversationKeys.messages(conversationId, params),
|
|
804
|
+
queryFn: async () => {
|
|
805
|
+
const client = getApiClient();
|
|
806
|
+
const queryParams = new URLSearchParams();
|
|
807
|
+
if (params?.limit) queryParams.set("limit", String(params.limit));
|
|
808
|
+
if (params?.before) queryParams.set("before", params.before);
|
|
809
|
+
const response = await client.get(`/conversations/${conversationId}/messages?${queryParams}`);
|
|
810
|
+
return response.data;
|
|
811
|
+
},
|
|
812
|
+
enabled: !!conversationId,
|
|
813
|
+
...options
|
|
814
|
+
});
|
|
815
|
+
}
|
|
816
|
+
var clubKeys = {
|
|
817
|
+
all: ["clubs"],
|
|
818
|
+
bySpot: (spotId) => [...clubKeys.all, "spot", spotId],
|
|
819
|
+
details: () => [...clubKeys.all, "detail"],
|
|
820
|
+
detail: (id) => [...clubKeys.details(), id],
|
|
821
|
+
bySlug: (slug) => [...clubKeys.all, "slug", slug],
|
|
822
|
+
byUser: (userId) => [...clubKeys.all, "user", userId],
|
|
823
|
+
membership: (clubId, userId) => [...clubKeys.detail(clubId), "membership", userId]
|
|
824
|
+
};
|
|
825
|
+
function useClubsBySpot(spotId, options) {
|
|
826
|
+
return reactQuery.useQuery({
|
|
827
|
+
queryKey: clubKeys.bySpot(spotId),
|
|
828
|
+
queryFn: async () => {
|
|
829
|
+
const client = getApiClient();
|
|
830
|
+
const response = await client.get(
|
|
831
|
+
`/clubs/spot/${spotId}`
|
|
832
|
+
);
|
|
833
|
+
return response.data.data;
|
|
834
|
+
},
|
|
835
|
+
enabled: !!spotId,
|
|
836
|
+
...options
|
|
837
|
+
});
|
|
838
|
+
}
|
|
839
|
+
function useClub(clubId, options) {
|
|
840
|
+
return reactQuery.useQuery({
|
|
841
|
+
queryKey: clubKeys.detail(clubId),
|
|
842
|
+
queryFn: async () => {
|
|
843
|
+
const client = getApiClient();
|
|
844
|
+
const response = await client.get(`/clubs/${clubId}`);
|
|
845
|
+
return response.data.data;
|
|
846
|
+
},
|
|
847
|
+
enabled: !!clubId,
|
|
848
|
+
...options
|
|
849
|
+
});
|
|
850
|
+
}
|
|
851
|
+
function useClubBySlug(slug, options) {
|
|
852
|
+
return reactQuery.useQuery({
|
|
853
|
+
queryKey: clubKeys.bySlug(slug),
|
|
854
|
+
queryFn: async () => {
|
|
855
|
+
const client = getApiClient();
|
|
856
|
+
const response = await client.get(
|
|
857
|
+
`/clubs/slug/${slug}`
|
|
858
|
+
);
|
|
859
|
+
return response.data.data;
|
|
860
|
+
},
|
|
861
|
+
enabled: !!slug,
|
|
862
|
+
...options
|
|
863
|
+
});
|
|
864
|
+
}
|
|
865
|
+
function useClubsByUser(userId, options) {
|
|
866
|
+
return reactQuery.useQuery({
|
|
867
|
+
queryKey: clubKeys.byUser(userId),
|
|
868
|
+
queryFn: async () => {
|
|
869
|
+
const client = getApiClient();
|
|
870
|
+
const response = await client.get(
|
|
871
|
+
`/clubs/user/${userId}`
|
|
872
|
+
);
|
|
873
|
+
return response.data.data;
|
|
874
|
+
},
|
|
875
|
+
enabled: !!userId,
|
|
876
|
+
...options
|
|
877
|
+
});
|
|
878
|
+
}
|
|
879
|
+
function useClubMembership(clubId, userId, options) {
|
|
880
|
+
return reactQuery.useQuery({
|
|
881
|
+
queryKey: clubKeys.membership(clubId, userId),
|
|
882
|
+
queryFn: async () => {
|
|
883
|
+
const client = getApiClient();
|
|
884
|
+
const response = await client.get(`/clubs/${clubId}/membership/${userId}`);
|
|
885
|
+
return response.data.data;
|
|
886
|
+
},
|
|
887
|
+
enabled: !!clubId && !!userId,
|
|
888
|
+
...options
|
|
889
|
+
});
|
|
890
|
+
}
|
|
891
|
+
var templateKeys = {
|
|
892
|
+
all: ["templates"],
|
|
893
|
+
lists: () => [...templateKeys.all, "list"],
|
|
894
|
+
list: (filters) => [...templateKeys.lists(), filters],
|
|
895
|
+
details: () => [...templateKeys.all, "detail"],
|
|
896
|
+
detail: (id) => [...templateKeys.details(), id],
|
|
897
|
+
bySlug: (slug) => [...templateKeys.all, "slug", slug]
|
|
898
|
+
};
|
|
899
|
+
function useTemplates(params, options) {
|
|
900
|
+
return reactQuery.useQuery({
|
|
901
|
+
queryKey: templateKeys.list(params),
|
|
902
|
+
queryFn: async () => {
|
|
903
|
+
const client = getApiClient();
|
|
904
|
+
const queryParams = new URLSearchParams();
|
|
905
|
+
if (params?.spotType) queryParams.set("spotType", params.spotType);
|
|
906
|
+
const response = await client.get(
|
|
907
|
+
`/templates?${queryParams}`
|
|
908
|
+
);
|
|
909
|
+
return response.data.data;
|
|
910
|
+
},
|
|
911
|
+
...options
|
|
912
|
+
});
|
|
913
|
+
}
|
|
914
|
+
function useTemplate(templateId, options) {
|
|
915
|
+
return reactQuery.useQuery({
|
|
916
|
+
queryKey: templateKeys.detail(templateId),
|
|
917
|
+
queryFn: async () => {
|
|
918
|
+
const client = getApiClient();
|
|
919
|
+
const response = await client.get(
|
|
920
|
+
`/templates/${templateId}`
|
|
921
|
+
);
|
|
922
|
+
return response.data.data;
|
|
923
|
+
},
|
|
924
|
+
enabled: !!templateId,
|
|
925
|
+
...options
|
|
926
|
+
});
|
|
927
|
+
}
|
|
928
|
+
function useTemplateBySlug(slug, options) {
|
|
929
|
+
return reactQuery.useQuery({
|
|
930
|
+
queryKey: templateKeys.bySlug(slug),
|
|
931
|
+
queryFn: async () => {
|
|
932
|
+
const client = getApiClient();
|
|
933
|
+
const response = await client.get(
|
|
934
|
+
`/templates/slug/${slug}`
|
|
935
|
+
);
|
|
936
|
+
return response.data.data;
|
|
937
|
+
},
|
|
938
|
+
enabled: !!slug,
|
|
939
|
+
...options
|
|
940
|
+
});
|
|
941
|
+
}
|
|
942
|
+
var notificationKeys = {
|
|
943
|
+
all: ["notifications"],
|
|
944
|
+
lists: () => [...notificationKeys.all, "list"],
|
|
945
|
+
list: (params) => [...notificationKeys.lists(), params],
|
|
946
|
+
unreadCount: () => [...notificationKeys.all, "unreadCount"]
|
|
947
|
+
};
|
|
948
|
+
function useNotifications(params, options) {
|
|
949
|
+
return reactQuery.useQuery({
|
|
950
|
+
queryKey: notificationKeys.list(params),
|
|
951
|
+
queryFn: async () => {
|
|
952
|
+
const client = getApiClient();
|
|
953
|
+
const queryParams = new URLSearchParams();
|
|
954
|
+
if (params?.limit) queryParams.set("limit", String(params.limit));
|
|
955
|
+
if (params?.unreadOnly)
|
|
956
|
+
queryParams.set("unreadOnly", String(params.unreadOnly));
|
|
957
|
+
const response = await client.get(
|
|
958
|
+
`/notifications?${queryParams}`
|
|
959
|
+
);
|
|
960
|
+
return response.data.data;
|
|
961
|
+
},
|
|
962
|
+
...options
|
|
963
|
+
});
|
|
964
|
+
}
|
|
965
|
+
function useUnreadNotificationCount(options) {
|
|
966
|
+
return reactQuery.useQuery({
|
|
967
|
+
queryKey: notificationKeys.unreadCount(),
|
|
968
|
+
queryFn: async () => {
|
|
969
|
+
const client = getApiClient();
|
|
970
|
+
const response = await client.get(
|
|
971
|
+
"/notifications/unread-count"
|
|
972
|
+
);
|
|
973
|
+
return response.data.data.count;
|
|
974
|
+
},
|
|
975
|
+
...options
|
|
976
|
+
});
|
|
977
|
+
}
|
|
978
|
+
function extractArrayData4(data) {
|
|
979
|
+
if (Array.isArray(data)) {
|
|
980
|
+
return data;
|
|
981
|
+
}
|
|
982
|
+
if (data && typeof data === "object" && "data" in data) {
|
|
983
|
+
const nested = data.data;
|
|
984
|
+
if (Array.isArray(nested)) {
|
|
985
|
+
return nested;
|
|
986
|
+
}
|
|
987
|
+
}
|
|
988
|
+
return [];
|
|
989
|
+
}
|
|
990
|
+
var miscKeys = {
|
|
991
|
+
cities: () => ["cities"],
|
|
992
|
+
vibes: () => ["vibes"],
|
|
993
|
+
lifeSituations: () => ["life-situations"]
|
|
994
|
+
};
|
|
995
|
+
function useCities(options) {
|
|
996
|
+
return reactQuery.useQuery({
|
|
997
|
+
queryKey: miscKeys.cities(),
|
|
998
|
+
queryFn: async () => {
|
|
999
|
+
const client = getApiClient();
|
|
1000
|
+
const response = await client.get("/cities");
|
|
1001
|
+
return extractArrayData4(response.data.data);
|
|
1002
|
+
},
|
|
1003
|
+
staleTime: 1e3 * 60 * 60,
|
|
1004
|
+
...options
|
|
1005
|
+
});
|
|
1006
|
+
}
|
|
1007
|
+
function useVibes(options) {
|
|
1008
|
+
return reactQuery.useQuery({
|
|
1009
|
+
queryKey: miscKeys.vibes(),
|
|
1010
|
+
queryFn: async () => {
|
|
1011
|
+
const client = getApiClient();
|
|
1012
|
+
const response = await client.get("/vibes");
|
|
1013
|
+
return extractArrayData4(response.data.data);
|
|
1014
|
+
},
|
|
1015
|
+
staleTime: 1e3 * 60 * 60,
|
|
1016
|
+
...options
|
|
1017
|
+
});
|
|
1018
|
+
}
|
|
1019
|
+
function useLifeSituations(options) {
|
|
1020
|
+
return reactQuery.useQuery({
|
|
1021
|
+
queryKey: miscKeys.lifeSituations(),
|
|
1022
|
+
queryFn: async () => {
|
|
1023
|
+
const client = getApiClient();
|
|
1024
|
+
const response = await client.get("/life-situations");
|
|
1025
|
+
return extractArrayData4(response.data.data);
|
|
1026
|
+
},
|
|
1027
|
+
staleTime: 1e3 * 60 * 60,
|
|
1028
|
+
...options
|
|
1029
|
+
});
|
|
1030
|
+
}
|
|
1031
|
+
var productKeys = {
|
|
1032
|
+
all: ["products"],
|
|
1033
|
+
lists: () => [...productKeys.all, "list"],
|
|
1034
|
+
list: (filters) => [...productKeys.lists(), filters],
|
|
1035
|
+
details: () => [...productKeys.all, "detail"],
|
|
1036
|
+
detail: (id) => [...productKeys.details(), id],
|
|
1037
|
+
bySlug: (spotId, slug) => [...productKeys.all, "slug", spotId, slug],
|
|
1038
|
+
bySpot: (spotId) => [...productKeys.all, "spot", spotId]
|
|
1039
|
+
};
|
|
1040
|
+
function useSpotProducts(spotId, params, options) {
|
|
1041
|
+
return reactQuery.useQuery({
|
|
1042
|
+
queryKey: productKeys.bySpot(spotId),
|
|
1043
|
+
queryFn: async () => {
|
|
1044
|
+
const client = getApiClient();
|
|
1045
|
+
const queryParams = new URLSearchParams();
|
|
1046
|
+
if (params?.limit) queryParams.set("limit", String(params.limit));
|
|
1047
|
+
if (params?.page) queryParams.set("page", String(params.page));
|
|
1048
|
+
if (params?.type) queryParams.set("type", params.type);
|
|
1049
|
+
const response = await client.get(
|
|
1050
|
+
`/spots/${spotId}/products?${queryParams}`
|
|
1051
|
+
);
|
|
1052
|
+
return response.data.data;
|
|
1053
|
+
},
|
|
1054
|
+
enabled: !!spotId,
|
|
1055
|
+
...options
|
|
1056
|
+
});
|
|
1057
|
+
}
|
|
1058
|
+
function useProduct(productId, options) {
|
|
1059
|
+
return reactQuery.useQuery({
|
|
1060
|
+
queryKey: productKeys.detail(productId),
|
|
1061
|
+
queryFn: async () => {
|
|
1062
|
+
const client = getApiClient();
|
|
1063
|
+
const response = await client.get(
|
|
1064
|
+
`/products/${productId}`
|
|
1065
|
+
);
|
|
1066
|
+
return response.data.data;
|
|
1067
|
+
},
|
|
1068
|
+
enabled: !!productId,
|
|
1069
|
+
...options
|
|
1070
|
+
});
|
|
1071
|
+
}
|
|
1072
|
+
function useProductBySlug(spotId, slug, options) {
|
|
1073
|
+
return reactQuery.useQuery({
|
|
1074
|
+
queryKey: productKeys.bySlug(spotId, slug),
|
|
1075
|
+
queryFn: async () => {
|
|
1076
|
+
const client = getApiClient();
|
|
1077
|
+
const response = await client.get(
|
|
1078
|
+
`/spots/${spotId}/products/slug/${slug}`
|
|
1079
|
+
);
|
|
1080
|
+
return response.data.data;
|
|
1081
|
+
},
|
|
1082
|
+
enabled: !!spotId && !!slug,
|
|
1083
|
+
...options
|
|
1084
|
+
});
|
|
1085
|
+
}
|
|
1086
|
+
var orderKeys = {
|
|
1087
|
+
all: ["orders"],
|
|
1088
|
+
lists: () => [...orderKeys.all, "list"],
|
|
1089
|
+
list: (filters) => [...orderKeys.lists(), filters],
|
|
1090
|
+
details: () => [...orderKeys.all, "detail"],
|
|
1091
|
+
detail: (id) => [...orderKeys.details(), id],
|
|
1092
|
+
myOrders: () => [...orderKeys.all, "my"],
|
|
1093
|
+
spotOrders: (spotId) => [...orderKeys.all, "spot", spotId]
|
|
1094
|
+
};
|
|
1095
|
+
function useMyOrders(params, options) {
|
|
1096
|
+
return reactQuery.useQuery({
|
|
1097
|
+
queryKey: orderKeys.list({ ...params, my: true }),
|
|
1098
|
+
queryFn: async () => {
|
|
1099
|
+
const client = getApiClient();
|
|
1100
|
+
const queryParams = new URLSearchParams();
|
|
1101
|
+
if (params?.status) queryParams.set("status", params.status);
|
|
1102
|
+
if (params?.limit) queryParams.set("limit", String(params.limit));
|
|
1103
|
+
if (params?.page) queryParams.set("page", String(params.page));
|
|
1104
|
+
const response = await client.get(`/users/me/orders?${queryParams}`);
|
|
1105
|
+
return response.data.data;
|
|
1106
|
+
},
|
|
1107
|
+
...options
|
|
1108
|
+
});
|
|
1109
|
+
}
|
|
1110
|
+
function useOrder(orderId, options) {
|
|
1111
|
+
return reactQuery.useQuery({
|
|
1112
|
+
queryKey: orderKeys.detail(orderId),
|
|
1113
|
+
queryFn: async () => {
|
|
1114
|
+
const client = getApiClient();
|
|
1115
|
+
const response = await client.get(
|
|
1116
|
+
`/orders/${orderId}`
|
|
1117
|
+
);
|
|
1118
|
+
return response.data.data;
|
|
1119
|
+
},
|
|
1120
|
+
enabled: !!orderId,
|
|
1121
|
+
...options
|
|
1122
|
+
});
|
|
1123
|
+
}
|
|
1124
|
+
function useSpotOrders(spotId, params, options) {
|
|
1125
|
+
return reactQuery.useQuery({
|
|
1126
|
+
queryKey: orderKeys.spotOrders(spotId),
|
|
1127
|
+
queryFn: async () => {
|
|
1128
|
+
const client = getApiClient();
|
|
1129
|
+
const queryParams = new URLSearchParams();
|
|
1130
|
+
if (params?.status) queryParams.set("status", params.status);
|
|
1131
|
+
if (params?.limit) queryParams.set("limit", String(params.limit));
|
|
1132
|
+
if (params?.page) queryParams.set("page", String(params.page));
|
|
1133
|
+
const response = await client.get(`/seller/spots/${spotId}/orders?${queryParams}`);
|
|
1134
|
+
return response.data.data;
|
|
1135
|
+
},
|
|
1136
|
+
enabled: !!spotId,
|
|
1137
|
+
...options
|
|
1138
|
+
});
|
|
1139
|
+
}
|
|
1140
|
+
function extractArrayData5(data) {
|
|
1141
|
+
if (Array.isArray(data)) {
|
|
1142
|
+
return data;
|
|
1143
|
+
}
|
|
1144
|
+
if (data && typeof data === "object" && "data" in data) {
|
|
1145
|
+
const nested = data.data;
|
|
1146
|
+
if (Array.isArray(nested)) {
|
|
1147
|
+
return nested;
|
|
1148
|
+
}
|
|
1149
|
+
}
|
|
1150
|
+
return [];
|
|
1151
|
+
}
|
|
1152
|
+
function extractObjectData3(data) {
|
|
1153
|
+
if (data && typeof data === "object" && "data" in data && !Array.isArray(data)) {
|
|
1154
|
+
const nested = data.data;
|
|
1155
|
+
if (nested && typeof nested === "object" && "data" in nested && !Array.isArray(nested)) {
|
|
1156
|
+
return nested.data;
|
|
1157
|
+
}
|
|
1158
|
+
return nested;
|
|
1159
|
+
}
|
|
1160
|
+
return data;
|
|
1161
|
+
}
|
|
1162
|
+
var walletKeys = {
|
|
1163
|
+
all: ["wallet"],
|
|
1164
|
+
active: () => [...walletKeys.all, "active"],
|
|
1165
|
+
history: (page) => [...walletKeys.all, "history", page],
|
|
1166
|
+
redemptions: () => ["redemptions"],
|
|
1167
|
+
lookup: (qrCode) => [...walletKeys.redemptions(), "lookup", qrCode],
|
|
1168
|
+
spotRedemptions: (spotId, page) => [...walletKeys.redemptions(), "spot", spotId, page]
|
|
1169
|
+
};
|
|
1170
|
+
function useWallet(options) {
|
|
1171
|
+
return reactQuery.useQuery({
|
|
1172
|
+
queryKey: walletKeys.active(),
|
|
1173
|
+
queryFn: async () => {
|
|
1174
|
+
const client = getApiClient();
|
|
1175
|
+
const response = await client.get("/wallet");
|
|
1176
|
+
return extractArrayData5(response.data.data);
|
|
1177
|
+
},
|
|
1178
|
+
...options
|
|
1179
|
+
});
|
|
1180
|
+
}
|
|
1181
|
+
function useWalletHistory(params, options) {
|
|
1182
|
+
return reactQuery.useQuery({
|
|
1183
|
+
queryKey: walletKeys.history(params?.page),
|
|
1184
|
+
queryFn: async () => {
|
|
1185
|
+
const client = getApiClient();
|
|
1186
|
+
const queryParams = new URLSearchParams();
|
|
1187
|
+
if (params?.page) queryParams.set("page", String(params.page));
|
|
1188
|
+
if (params?.limit) queryParams.set("limit", String(params.limit));
|
|
1189
|
+
const response = await client.get(
|
|
1190
|
+
`/wallet/history?${queryParams}`
|
|
1191
|
+
);
|
|
1192
|
+
return extractObjectData3(response.data.data);
|
|
1193
|
+
},
|
|
1194
|
+
...options
|
|
1195
|
+
});
|
|
1196
|
+
}
|
|
1197
|
+
function useRedemptionLookup(qrCode, options) {
|
|
1198
|
+
return reactQuery.useQuery({
|
|
1199
|
+
queryKey: walletKeys.lookup(qrCode),
|
|
1200
|
+
queryFn: async () => {
|
|
1201
|
+
const client = getApiClient();
|
|
1202
|
+
const response = await client.get(
|
|
1203
|
+
`/redemptions/lookup/${qrCode}`
|
|
1204
|
+
);
|
|
1205
|
+
return extractObjectData3(response.data.data);
|
|
1206
|
+
},
|
|
1207
|
+
enabled: !!qrCode && qrCode.length > 0,
|
|
1208
|
+
...options
|
|
1209
|
+
});
|
|
1210
|
+
}
|
|
1211
|
+
function useSpotRedemptions(spotId, params, options) {
|
|
1212
|
+
return reactQuery.useQuery({
|
|
1213
|
+
queryKey: walletKeys.spotRedemptions(spotId, params?.page),
|
|
1214
|
+
queryFn: async () => {
|
|
1215
|
+
const client = getApiClient();
|
|
1216
|
+
const queryParams = new URLSearchParams();
|
|
1217
|
+
if (params?.page) queryParams.set("page", String(params.page));
|
|
1218
|
+
if (params?.limit) queryParams.set("limit", String(params.limit));
|
|
1219
|
+
const response = await client.get(
|
|
1220
|
+
`/spots/${spotId}/redemptions?${queryParams}`
|
|
1221
|
+
);
|
|
1222
|
+
return extractObjectData3(response.data.data);
|
|
1223
|
+
},
|
|
1224
|
+
enabled: !!spotId,
|
|
1225
|
+
...options
|
|
1226
|
+
});
|
|
1227
|
+
}
|
|
1228
|
+
function useUpdateProfile(options) {
|
|
1229
|
+
const queryClient = reactQuery.useQueryClient();
|
|
1230
|
+
return reactQuery.useMutation({
|
|
1231
|
+
mutationFn: async (data) => {
|
|
1232
|
+
const client = getApiClient();
|
|
1233
|
+
const response = await client.put("/users/me", data);
|
|
1234
|
+
return response.data.data;
|
|
1235
|
+
},
|
|
1236
|
+
onSuccess: (data) => {
|
|
1237
|
+
queryClient.setQueryData(userKeys.me(), data);
|
|
1238
|
+
},
|
|
1239
|
+
...options
|
|
1240
|
+
});
|
|
1241
|
+
}
|
|
1242
|
+
function useUploadAvatar(options) {
|
|
1243
|
+
const queryClient = reactQuery.useQueryClient();
|
|
1244
|
+
return reactQuery.useMutation({
|
|
1245
|
+
mutationFn: async (formData) => {
|
|
1246
|
+
const client = getApiClient();
|
|
1247
|
+
const response = await client.post(
|
|
1248
|
+
"/users/me/avatar",
|
|
1249
|
+
formData,
|
|
1250
|
+
{
|
|
1251
|
+
headers: { "Content-Type": "multipart/form-data" }
|
|
1252
|
+
}
|
|
1253
|
+
);
|
|
1254
|
+
return response.data.data;
|
|
1255
|
+
},
|
|
1256
|
+
onSuccess: () => {
|
|
1257
|
+
queryClient.invalidateQueries({ queryKey: userKeys.me() });
|
|
1258
|
+
},
|
|
1259
|
+
...options
|
|
1260
|
+
});
|
|
1261
|
+
}
|
|
1262
|
+
function useDeleteAccount(options) {
|
|
1263
|
+
const queryClient = reactQuery.useQueryClient();
|
|
1264
|
+
return reactQuery.useMutation({
|
|
1265
|
+
mutationFn: async () => {
|
|
1266
|
+
const client = getApiClient();
|
|
1267
|
+
await client.delete("/users/me");
|
|
1268
|
+
},
|
|
1269
|
+
onSuccess: () => {
|
|
1270
|
+
queryClient.clear();
|
|
1271
|
+
},
|
|
1272
|
+
...options
|
|
1273
|
+
});
|
|
1274
|
+
}
|
|
1275
|
+
function useUpdateVibes(options) {
|
|
1276
|
+
const queryClient = reactQuery.useQueryClient();
|
|
1277
|
+
return reactQuery.useMutation({
|
|
1278
|
+
mutationFn: async (data) => {
|
|
1279
|
+
const client = getApiClient();
|
|
1280
|
+
const response = await client.put(
|
|
1281
|
+
"/users/me/vibes",
|
|
1282
|
+
data
|
|
1283
|
+
);
|
|
1284
|
+
return response.data.data;
|
|
1285
|
+
},
|
|
1286
|
+
onSuccess: () => {
|
|
1287
|
+
queryClient.invalidateQueries({ queryKey: userKeys.me() });
|
|
1288
|
+
},
|
|
1289
|
+
...options
|
|
1290
|
+
});
|
|
1291
|
+
}
|
|
1292
|
+
function useUpdateInterests(options) {
|
|
1293
|
+
const queryClient = reactQuery.useQueryClient();
|
|
1294
|
+
return reactQuery.useMutation({
|
|
1295
|
+
mutationFn: async (data) => {
|
|
1296
|
+
const client = getApiClient();
|
|
1297
|
+
const response = await client.put(
|
|
1298
|
+
"/user/me/interests",
|
|
1299
|
+
data
|
|
1300
|
+
);
|
|
1301
|
+
return response.data.data;
|
|
1302
|
+
},
|
|
1303
|
+
onSuccess: () => {
|
|
1304
|
+
queryClient.invalidateQueries({ queryKey: userKeys.me() });
|
|
1305
|
+
},
|
|
1306
|
+
...options
|
|
1307
|
+
});
|
|
1308
|
+
}
|
|
1309
|
+
function useCompleteOnboardingStep(options) {
|
|
1310
|
+
const queryClient = reactQuery.useQueryClient();
|
|
1311
|
+
return reactQuery.useMutation({
|
|
1312
|
+
mutationFn: async (data) => {
|
|
1313
|
+
const client = getApiClient();
|
|
1314
|
+
const response = await client.post(
|
|
1315
|
+
"/user/me/onboarding-step",
|
|
1316
|
+
data
|
|
1317
|
+
);
|
|
1318
|
+
return response.data.data;
|
|
1319
|
+
},
|
|
1320
|
+
onSuccess: () => {
|
|
1321
|
+
queryClient.invalidateQueries({ queryKey: userKeys.me() });
|
|
1322
|
+
},
|
|
1323
|
+
...options
|
|
1324
|
+
});
|
|
1325
|
+
}
|
|
1326
|
+
function useBlockUser(options) {
|
|
1327
|
+
const queryClient = reactQuery.useQueryClient();
|
|
1328
|
+
return reactQuery.useMutation({
|
|
1329
|
+
mutationFn: async (userId) => {
|
|
1330
|
+
const client = getApiClient();
|
|
1331
|
+
await client.post(`/users/${userId}/block`);
|
|
1332
|
+
},
|
|
1333
|
+
onSuccess: () => {
|
|
1334
|
+
queryClient.invalidateQueries({ queryKey: userKeys.blocked() });
|
|
1335
|
+
},
|
|
1336
|
+
...options
|
|
1337
|
+
});
|
|
1338
|
+
}
|
|
1339
|
+
function useUnblockUser(options) {
|
|
1340
|
+
const queryClient = reactQuery.useQueryClient();
|
|
1341
|
+
return reactQuery.useMutation({
|
|
1342
|
+
mutationFn: async (userId) => {
|
|
1343
|
+
const client = getApiClient();
|
|
1344
|
+
await client.delete(`/users/${userId}/block`);
|
|
1345
|
+
},
|
|
1346
|
+
onSuccess: () => {
|
|
1347
|
+
queryClient.invalidateQueries({ queryKey: userKeys.blocked() });
|
|
1348
|
+
},
|
|
1349
|
+
...options
|
|
1350
|
+
});
|
|
1351
|
+
}
|
|
1352
|
+
function useCreatePost(options) {
|
|
1353
|
+
const queryClient = reactQuery.useQueryClient();
|
|
1354
|
+
return reactQuery.useMutation({
|
|
1355
|
+
mutationFn: async ({ spotId, ...data }) => {
|
|
1356
|
+
const client = getApiClient();
|
|
1357
|
+
const response = await client.post(
|
|
1358
|
+
`/spots/${spotId}/posts`,
|
|
1359
|
+
data
|
|
1360
|
+
);
|
|
1361
|
+
return response.data.data;
|
|
1362
|
+
},
|
|
1363
|
+
onSuccess: (_, variables) => {
|
|
1364
|
+
queryClient.invalidateQueries({
|
|
1365
|
+
queryKey: postKeys.bySpot(variables.spotId)
|
|
1366
|
+
});
|
|
1367
|
+
},
|
|
1368
|
+
...options
|
|
1369
|
+
});
|
|
1370
|
+
}
|
|
1371
|
+
function useUpdatePost(options) {
|
|
1372
|
+
const queryClient = reactQuery.useQueryClient();
|
|
1373
|
+
return reactQuery.useMutation({
|
|
1374
|
+
mutationFn: async ({ postId, title, content }) => {
|
|
1375
|
+
const client = getApiClient();
|
|
1376
|
+
const response = await client.put(
|
|
1377
|
+
`/posts/${postId}`,
|
|
1378
|
+
{ title, description: content }
|
|
1379
|
+
);
|
|
1380
|
+
return response.data.data;
|
|
1381
|
+
},
|
|
1382
|
+
onSuccess: (data, variables) => {
|
|
1383
|
+
queryClient.setQueryData(postKeys.detail(variables.postId), data);
|
|
1384
|
+
},
|
|
1385
|
+
...options
|
|
1386
|
+
});
|
|
1387
|
+
}
|
|
1388
|
+
function useDeletePost(options) {
|
|
1389
|
+
const queryClient = reactQuery.useQueryClient();
|
|
1390
|
+
return reactQuery.useMutation({
|
|
1391
|
+
mutationFn: async (postId) => {
|
|
1392
|
+
const client = getApiClient();
|
|
1393
|
+
await client.delete(`/posts/${postId}`);
|
|
1394
|
+
},
|
|
1395
|
+
onSuccess: (_, postId) => {
|
|
1396
|
+
queryClient.invalidateQueries({ queryKey: postKeys.detail(postId) });
|
|
1397
|
+
queryClient.invalidateQueries({ queryKey: postKeys.lists() });
|
|
1398
|
+
},
|
|
1399
|
+
...options
|
|
1400
|
+
});
|
|
1401
|
+
}
|
|
1402
|
+
function useFulfillPost(options) {
|
|
1403
|
+
const queryClient = reactQuery.useQueryClient();
|
|
1404
|
+
return reactQuery.useMutation({
|
|
1405
|
+
mutationFn: async (postId) => {
|
|
1406
|
+
const client = getApiClient();
|
|
1407
|
+
const response = await client.put(
|
|
1408
|
+
`/posts/${postId}/fulfill`
|
|
1409
|
+
);
|
|
1410
|
+
return response.data.data;
|
|
1411
|
+
},
|
|
1412
|
+
onSuccess: (data, postId) => {
|
|
1413
|
+
queryClient.setQueryData(postKeys.detail(postId), data);
|
|
1414
|
+
},
|
|
1415
|
+
...options
|
|
1416
|
+
});
|
|
1417
|
+
}
|
|
1418
|
+
function useUpvotePost(options) {
|
|
1419
|
+
const queryClient = reactQuery.useQueryClient();
|
|
1420
|
+
return reactQuery.useMutation({
|
|
1421
|
+
mutationFn: async (postId) => {
|
|
1422
|
+
const client = getApiClient();
|
|
1423
|
+
const response = await client.post(
|
|
1424
|
+
`/posts/${postId}/upvote`
|
|
1425
|
+
);
|
|
1426
|
+
return response.data.data;
|
|
1427
|
+
},
|
|
1428
|
+
onSuccess: (_, postId) => {
|
|
1429
|
+
queryClient.invalidateQueries({ queryKey: postKeys.detail(postId) });
|
|
1430
|
+
},
|
|
1431
|
+
...options
|
|
1432
|
+
});
|
|
1433
|
+
}
|
|
1434
|
+
function useCreateReply(options) {
|
|
1435
|
+
const queryClient = reactQuery.useQueryClient();
|
|
1436
|
+
return reactQuery.useMutation({
|
|
1437
|
+
mutationFn: async ({ postId, ...data }) => {
|
|
1438
|
+
const client = getApiClient();
|
|
1439
|
+
const response = await client.post(
|
|
1440
|
+
`/posts/${postId}/reply`,
|
|
1441
|
+
data
|
|
1442
|
+
);
|
|
1443
|
+
return response.data.data;
|
|
1444
|
+
},
|
|
1445
|
+
onSuccess: (_, variables) => {
|
|
1446
|
+
queryClient.invalidateQueries({
|
|
1447
|
+
queryKey: postKeys.detail(variables.postId)
|
|
1448
|
+
});
|
|
1449
|
+
},
|
|
1450
|
+
...options
|
|
1451
|
+
});
|
|
1452
|
+
}
|
|
1453
|
+
function useDeleteReply(options) {
|
|
1454
|
+
const queryClient = reactQuery.useQueryClient();
|
|
1455
|
+
return reactQuery.useMutation({
|
|
1456
|
+
mutationFn: async ({ replyId }) => {
|
|
1457
|
+
const client = getApiClient();
|
|
1458
|
+
await client.delete(`/replies/${replyId}`);
|
|
1459
|
+
},
|
|
1460
|
+
onSuccess: (_, variables) => {
|
|
1461
|
+
queryClient.invalidateQueries({
|
|
1462
|
+
queryKey: postKeys.detail(variables.postId)
|
|
1463
|
+
});
|
|
1464
|
+
},
|
|
1465
|
+
...options
|
|
1466
|
+
});
|
|
1467
|
+
}
|
|
1468
|
+
function useRespondToPost(options) {
|
|
1469
|
+
const queryClient = reactQuery.useQueryClient();
|
|
1470
|
+
return reactQuery.useMutation({
|
|
1471
|
+
mutationFn: async ({ postId, ...data }) => {
|
|
1472
|
+
const client = getApiClient();
|
|
1473
|
+
const response = await client.post(
|
|
1474
|
+
`/posts/${postId}/respond`,
|
|
1475
|
+
data
|
|
1476
|
+
);
|
|
1477
|
+
return response.data.data;
|
|
1478
|
+
},
|
|
1479
|
+
onSuccess: (_, variables) => {
|
|
1480
|
+
queryClient.invalidateQueries({
|
|
1481
|
+
queryKey: postKeys.detail(variables.postId)
|
|
1482
|
+
});
|
|
1483
|
+
queryClient.invalidateQueries({
|
|
1484
|
+
queryKey: postKeys.responses(variables.postId)
|
|
1485
|
+
});
|
|
1486
|
+
},
|
|
1487
|
+
...options
|
|
1488
|
+
});
|
|
1489
|
+
}
|
|
1490
|
+
function useUpdateResponse(options) {
|
|
1491
|
+
const queryClient = reactQuery.useQueryClient();
|
|
1492
|
+
return reactQuery.useMutation({
|
|
1493
|
+
mutationFn: async ({
|
|
1494
|
+
responseId,
|
|
1495
|
+
postId: _,
|
|
1496
|
+
...data
|
|
1497
|
+
}) => {
|
|
1498
|
+
const client = getApiClient();
|
|
1499
|
+
const response = await client.put(
|
|
1500
|
+
`/responses/${responseId}`,
|
|
1501
|
+
data
|
|
1502
|
+
);
|
|
1503
|
+
return response.data.data;
|
|
1504
|
+
},
|
|
1505
|
+
onSuccess: (_, variables) => {
|
|
1506
|
+
queryClient.invalidateQueries({
|
|
1507
|
+
queryKey: postKeys.responses(variables.postId)
|
|
1508
|
+
});
|
|
1509
|
+
},
|
|
1510
|
+
...options
|
|
1511
|
+
});
|
|
1512
|
+
}
|
|
1513
|
+
function useReportPost(options) {
|
|
1514
|
+
return reactQuery.useMutation({
|
|
1515
|
+
mutationFn: async ({ postId, ...data }) => {
|
|
1516
|
+
const client = getApiClient();
|
|
1517
|
+
await client.post(`/posts/${postId}/report`, data);
|
|
1518
|
+
},
|
|
1519
|
+
...options
|
|
1520
|
+
});
|
|
1521
|
+
}
|
|
1522
|
+
function useUpdatePostStatus(options) {
|
|
1523
|
+
const queryClient = reactQuery.useQueryClient();
|
|
1524
|
+
return reactQuery.useMutation({
|
|
1525
|
+
mutationFn: async ({ postId, ...data }) => {
|
|
1526
|
+
const client = getApiClient();
|
|
1527
|
+
const response = await client.put(
|
|
1528
|
+
`/posts/${postId}/status`,
|
|
1529
|
+
data
|
|
1530
|
+
);
|
|
1531
|
+
return response.data.data;
|
|
1532
|
+
},
|
|
1533
|
+
onSuccess: (data, variables) => {
|
|
1534
|
+
queryClient.setQueryData(postKeys.status(variables.postId), data);
|
|
1535
|
+
},
|
|
1536
|
+
...options
|
|
1537
|
+
});
|
|
1538
|
+
}
|
|
1539
|
+
function useCreateSpot(options) {
|
|
1540
|
+
const queryClient = reactQuery.useQueryClient();
|
|
1541
|
+
return reactQuery.useMutation({
|
|
1542
|
+
mutationFn: async (data) => {
|
|
1543
|
+
const client = getApiClient();
|
|
1544
|
+
const response = await client.post("/spots", data);
|
|
1545
|
+
return response.data.data;
|
|
1546
|
+
},
|
|
1547
|
+
onSuccess: () => {
|
|
1548
|
+
queryClient.invalidateQueries({ queryKey: spotKeys.lists() });
|
|
1549
|
+
},
|
|
1550
|
+
...options
|
|
1551
|
+
});
|
|
1552
|
+
}
|
|
1553
|
+
function useUpdateSpot(options) {
|
|
1554
|
+
const queryClient = reactQuery.useQueryClient();
|
|
1555
|
+
return reactQuery.useMutation({
|
|
1556
|
+
mutationFn: async ({ spotId, ...data }) => {
|
|
1557
|
+
const client = getApiClient();
|
|
1558
|
+
const response = await client.put(
|
|
1559
|
+
`/spots/${spotId}`,
|
|
1560
|
+
data
|
|
1561
|
+
);
|
|
1562
|
+
return response.data.data;
|
|
1563
|
+
},
|
|
1564
|
+
onSuccess: (data, variables) => {
|
|
1565
|
+
queryClient.setQueryData(spotKeys.detail(variables.spotId), data);
|
|
1566
|
+
},
|
|
1567
|
+
...options
|
|
1568
|
+
});
|
|
1569
|
+
}
|
|
1570
|
+
function useClaimSpot(options) {
|
|
1571
|
+
return reactQuery.useMutation({
|
|
1572
|
+
mutationFn: async ({ spotId, ...data }) => {
|
|
1573
|
+
const client = getApiClient();
|
|
1574
|
+
const response = await client.post(
|
|
1575
|
+
`/spots/${spotId}/claim`,
|
|
1576
|
+
data
|
|
1577
|
+
);
|
|
1578
|
+
return response.data.data;
|
|
1579
|
+
},
|
|
1580
|
+
...options
|
|
1581
|
+
});
|
|
1582
|
+
}
|
|
1583
|
+
function useSubscribeToSpot(options) {
|
|
1584
|
+
const queryClient = reactQuery.useQueryClient();
|
|
1585
|
+
return reactQuery.useMutation({
|
|
1586
|
+
mutationFn: async (spotId) => {
|
|
1587
|
+
const client = getApiClient();
|
|
1588
|
+
await client.post(`/spots/${spotId}/subscribe`);
|
|
1589
|
+
},
|
|
1590
|
+
onSuccess: () => {
|
|
1591
|
+
queryClient.invalidateQueries({ queryKey: userKeys.subscriptions() });
|
|
1592
|
+
},
|
|
1593
|
+
...options
|
|
1594
|
+
});
|
|
1595
|
+
}
|
|
1596
|
+
function useUnsubscribeFromSpot(options) {
|
|
1597
|
+
const queryClient = reactQuery.useQueryClient();
|
|
1598
|
+
return reactQuery.useMutation({
|
|
1599
|
+
mutationFn: async (spotId) => {
|
|
1600
|
+
const client = getApiClient();
|
|
1601
|
+
await client.delete(`/spots/${spotId}/subscribe`);
|
|
1602
|
+
},
|
|
1603
|
+
onSuccess: () => {
|
|
1604
|
+
queryClient.invalidateQueries({ queryKey: userKeys.subscriptions() });
|
|
1605
|
+
},
|
|
1606
|
+
...options
|
|
1607
|
+
});
|
|
1608
|
+
}
|
|
1609
|
+
function useFavoriteSpot(options) {
|
|
1610
|
+
const queryClient = reactQuery.useQueryClient();
|
|
1611
|
+
return reactQuery.useMutation({
|
|
1612
|
+
mutationFn: async (spotId) => {
|
|
1613
|
+
const client = getApiClient();
|
|
1614
|
+
const response = await client.post(
|
|
1615
|
+
`/spots/${spotId}/favorite`
|
|
1616
|
+
);
|
|
1617
|
+
return response.data.data;
|
|
1618
|
+
},
|
|
1619
|
+
onSuccess: () => {
|
|
1620
|
+
queryClient.invalidateQueries({ queryKey: userKeys.favorites() });
|
|
1621
|
+
},
|
|
1622
|
+
...options
|
|
1623
|
+
});
|
|
1624
|
+
}
|
|
1625
|
+
function useRateSpot(options) {
|
|
1626
|
+
const queryClient = reactQuery.useQueryClient();
|
|
1627
|
+
return reactQuery.useMutation({
|
|
1628
|
+
mutationFn: async ({
|
|
1629
|
+
spotId,
|
|
1630
|
+
rating
|
|
1631
|
+
}) => {
|
|
1632
|
+
const client = getApiClient();
|
|
1633
|
+
const response = await client.post(
|
|
1634
|
+
`/spots/${spotId}/rate`,
|
|
1635
|
+
{ rating }
|
|
1636
|
+
);
|
|
1637
|
+
return response.data.data;
|
|
1638
|
+
},
|
|
1639
|
+
onSuccess: (_, variables) => {
|
|
1640
|
+
queryClient.invalidateQueries({
|
|
1641
|
+
queryKey: spotKeys.detail(variables.spotId)
|
|
1642
|
+
});
|
|
1643
|
+
},
|
|
1644
|
+
...options
|
|
1645
|
+
});
|
|
1646
|
+
}
|
|
1647
|
+
function useReportSpot(options) {
|
|
1648
|
+
return reactQuery.useMutation({
|
|
1649
|
+
mutationFn: async ({
|
|
1650
|
+
spotId,
|
|
1651
|
+
reason,
|
|
1652
|
+
details
|
|
1653
|
+
}) => {
|
|
1654
|
+
const client = getApiClient();
|
|
1655
|
+
const response = await client.post(
|
|
1656
|
+
`/spots/${spotId}/report`,
|
|
1657
|
+
{ reason, details }
|
|
1658
|
+
);
|
|
1659
|
+
return response.data.data;
|
|
1660
|
+
},
|
|
1661
|
+
...options
|
|
1662
|
+
});
|
|
1663
|
+
}
|
|
1664
|
+
function useCreateConversation(options) {
|
|
1665
|
+
const queryClient = reactQuery.useQueryClient();
|
|
1666
|
+
return reactQuery.useMutation({
|
|
1667
|
+
mutationFn: async (data) => {
|
|
1668
|
+
const client = getApiClient();
|
|
1669
|
+
const response = await client.post(
|
|
1670
|
+
"/conversations",
|
|
1671
|
+
data
|
|
1672
|
+
);
|
|
1673
|
+
return response.data.data;
|
|
1674
|
+
},
|
|
1675
|
+
onSuccess: () => {
|
|
1676
|
+
queryClient.invalidateQueries({ queryKey: conversationKeys.lists() });
|
|
1677
|
+
},
|
|
1678
|
+
...options
|
|
1679
|
+
});
|
|
1680
|
+
}
|
|
1681
|
+
function useCreateDirectConversation(options) {
|
|
1682
|
+
const queryClient = reactQuery.useQueryClient();
|
|
1683
|
+
return reactQuery.useMutation({
|
|
1684
|
+
mutationFn: async (data) => {
|
|
1685
|
+
const client = getApiClient();
|
|
1686
|
+
const response = await client.post(
|
|
1687
|
+
"/conversations/direct",
|
|
1688
|
+
data
|
|
1689
|
+
);
|
|
1690
|
+
return response.data.data;
|
|
1691
|
+
},
|
|
1692
|
+
onSuccess: () => {
|
|
1693
|
+
queryClient.invalidateQueries({ queryKey: conversationKeys.lists() });
|
|
1694
|
+
},
|
|
1695
|
+
...options
|
|
1696
|
+
});
|
|
1697
|
+
}
|
|
1698
|
+
function useSendMessage(options) {
|
|
1699
|
+
const queryClient = reactQuery.useQueryClient();
|
|
1700
|
+
return reactQuery.useMutation({
|
|
1701
|
+
mutationFn: async ({ conversationId, ...data }) => {
|
|
1702
|
+
const client = getApiClient();
|
|
1703
|
+
const response = await client.post(
|
|
1704
|
+
`/conversations/${conversationId}/messages`,
|
|
1705
|
+
data
|
|
1706
|
+
);
|
|
1707
|
+
return response.data.data;
|
|
1708
|
+
},
|
|
1709
|
+
onSuccess: (_, variables) => {
|
|
1710
|
+
queryClient.invalidateQueries({
|
|
1711
|
+
queryKey: conversationKeys.messages(variables.conversationId)
|
|
1712
|
+
});
|
|
1713
|
+
queryClient.invalidateQueries({ queryKey: conversationKeys.lists() });
|
|
1714
|
+
},
|
|
1715
|
+
...options
|
|
1716
|
+
});
|
|
1717
|
+
}
|
|
1718
|
+
function useMarkConversationAsRead(options) {
|
|
1719
|
+
const queryClient = reactQuery.useQueryClient();
|
|
1720
|
+
return reactQuery.useMutation({
|
|
1721
|
+
mutationFn: async (conversationId) => {
|
|
1722
|
+
const client = getApiClient();
|
|
1723
|
+
await client.put(`/conversations/${conversationId}/read`);
|
|
1724
|
+
},
|
|
1725
|
+
onSuccess: (_, conversationId) => {
|
|
1726
|
+
queryClient.invalidateQueries({
|
|
1727
|
+
queryKey: conversationKeys.detail(conversationId)
|
|
1728
|
+
});
|
|
1729
|
+
queryClient.invalidateQueries({ queryKey: conversationKeys.lists() });
|
|
1730
|
+
},
|
|
1731
|
+
...options
|
|
1732
|
+
});
|
|
1733
|
+
}
|
|
1734
|
+
function useSendTypingIndicator(options) {
|
|
1735
|
+
return reactQuery.useMutation({
|
|
1736
|
+
mutationFn: async (conversationId) => {
|
|
1737
|
+
const client = getApiClient();
|
|
1738
|
+
await client.post(`/conversations/${conversationId}/typing`);
|
|
1739
|
+
},
|
|
1740
|
+
...options
|
|
1741
|
+
});
|
|
1742
|
+
}
|
|
1743
|
+
function useCreateClub(options) {
|
|
1744
|
+
const queryClient = reactQuery.useQueryClient();
|
|
1745
|
+
return reactQuery.useMutation({
|
|
1746
|
+
mutationFn: async (data) => {
|
|
1747
|
+
const client = getApiClient();
|
|
1748
|
+
const response = await client.post("/clubs", data);
|
|
1749
|
+
return response.data.data;
|
|
1750
|
+
},
|
|
1751
|
+
onSuccess: (_, variables) => {
|
|
1752
|
+
queryClient.invalidateQueries({
|
|
1753
|
+
queryKey: clubKeys.bySpot(variables.spotId)
|
|
1754
|
+
});
|
|
1755
|
+
},
|
|
1756
|
+
...options
|
|
1757
|
+
});
|
|
1758
|
+
}
|
|
1759
|
+
function useUpdateClub(options) {
|
|
1760
|
+
const queryClient = reactQuery.useQueryClient();
|
|
1761
|
+
return reactQuery.useMutation({
|
|
1762
|
+
mutationFn: async ({ clubId, ...data }) => {
|
|
1763
|
+
const client = getApiClient();
|
|
1764
|
+
const response = await client.put(
|
|
1765
|
+
`/clubs/${clubId}`,
|
|
1766
|
+
data
|
|
1767
|
+
);
|
|
1768
|
+
return response.data.data;
|
|
1769
|
+
},
|
|
1770
|
+
onSuccess: (data, variables) => {
|
|
1771
|
+
queryClient.setQueryData(clubKeys.detail(variables.clubId), data);
|
|
1772
|
+
},
|
|
1773
|
+
...options
|
|
1774
|
+
});
|
|
1775
|
+
}
|
|
1776
|
+
function useJoinClub(options) {
|
|
1777
|
+
const queryClient = reactQuery.useQueryClient();
|
|
1778
|
+
return reactQuery.useMutation({
|
|
1779
|
+
mutationFn: async (clubId) => {
|
|
1780
|
+
const client = getApiClient();
|
|
1781
|
+
await client.post(`/clubs/${clubId}/join`);
|
|
1782
|
+
},
|
|
1783
|
+
onSuccess: (_, clubId) => {
|
|
1784
|
+
queryClient.invalidateQueries({ queryKey: clubKeys.detail(clubId) });
|
|
1785
|
+
queryClient.invalidateQueries({ queryKey: userKeys.clubs() });
|
|
1786
|
+
},
|
|
1787
|
+
...options
|
|
1788
|
+
});
|
|
1789
|
+
}
|
|
1790
|
+
function useLeaveClub(options) {
|
|
1791
|
+
const queryClient = reactQuery.useQueryClient();
|
|
1792
|
+
return reactQuery.useMutation({
|
|
1793
|
+
mutationFn: async (clubId) => {
|
|
1794
|
+
const client = getApiClient();
|
|
1795
|
+
await client.post(`/clubs/${clubId}/leave`);
|
|
1796
|
+
},
|
|
1797
|
+
onSuccess: (_, clubId) => {
|
|
1798
|
+
queryClient.invalidateQueries({ queryKey: clubKeys.detail(clubId) });
|
|
1799
|
+
queryClient.invalidateQueries({ queryKey: userKeys.clubs() });
|
|
1800
|
+
},
|
|
1801
|
+
...options
|
|
1802
|
+
});
|
|
1803
|
+
}
|
|
1804
|
+
function useMarkNotificationsRead(options) {
|
|
1805
|
+
const queryClient = reactQuery.useQueryClient();
|
|
1806
|
+
return reactQuery.useMutation({
|
|
1807
|
+
mutationFn: async (data) => {
|
|
1808
|
+
const client = getApiClient();
|
|
1809
|
+
await client.put("/notifications/read", data);
|
|
1810
|
+
},
|
|
1811
|
+
onSuccess: () => {
|
|
1812
|
+
queryClient.invalidateQueries({ queryKey: notificationKeys.lists() });
|
|
1813
|
+
queryClient.invalidateQueries({ queryKey: notificationKeys.unreadCount() });
|
|
1814
|
+
},
|
|
1815
|
+
...options
|
|
1816
|
+
});
|
|
1817
|
+
}
|
|
1818
|
+
function useRegisterDeviceToken(options) {
|
|
1819
|
+
return reactQuery.useMutation({
|
|
1820
|
+
mutationFn: async (data) => {
|
|
1821
|
+
const client = getApiClient();
|
|
1822
|
+
await client.post("/device-tokens", data);
|
|
1823
|
+
},
|
|
1824
|
+
...options
|
|
1825
|
+
});
|
|
1826
|
+
}
|
|
1827
|
+
function useRemoveDeviceToken(options) {
|
|
1828
|
+
return reactQuery.useMutation({
|
|
1829
|
+
mutationFn: async (data) => {
|
|
1830
|
+
const client = getApiClient();
|
|
1831
|
+
await client.delete("/device-tokens", { data });
|
|
1832
|
+
},
|
|
1833
|
+
...options
|
|
1834
|
+
});
|
|
1835
|
+
}
|
|
1836
|
+
function useCreateProduct(options) {
|
|
1837
|
+
const queryClient = reactQuery.useQueryClient();
|
|
1838
|
+
return reactQuery.useMutation({
|
|
1839
|
+
mutationFn: async (data) => {
|
|
1840
|
+
const client = getApiClient();
|
|
1841
|
+
const { spotId, ...productData } = data;
|
|
1842
|
+
const response = await client.post(
|
|
1843
|
+
`/spots/${spotId}/products`,
|
|
1844
|
+
productData
|
|
1845
|
+
);
|
|
1846
|
+
return response.data.data;
|
|
1847
|
+
},
|
|
1848
|
+
onSuccess: (_, variables) => {
|
|
1849
|
+
queryClient.invalidateQueries({ queryKey: productKeys.bySpot(variables.spotId) });
|
|
1850
|
+
queryClient.invalidateQueries({ queryKey: productKeys.list({ my: true }) });
|
|
1851
|
+
},
|
|
1852
|
+
...options
|
|
1853
|
+
});
|
|
1854
|
+
}
|
|
1855
|
+
function useUpdateProduct(options) {
|
|
1856
|
+
const queryClient = reactQuery.useQueryClient();
|
|
1857
|
+
return reactQuery.useMutation({
|
|
1858
|
+
mutationFn: async ({ productId, data }) => {
|
|
1859
|
+
const client = getApiClient();
|
|
1860
|
+
const response = await client.put(
|
|
1861
|
+
`/products/${productId}`,
|
|
1862
|
+
data
|
|
1863
|
+
);
|
|
1864
|
+
return response.data.data;
|
|
1865
|
+
},
|
|
1866
|
+
onSuccess: (data) => {
|
|
1867
|
+
queryClient.setQueryData(productKeys.detail(data.id), data);
|
|
1868
|
+
queryClient.invalidateQueries({ queryKey: productKeys.bySpot(data.spotId) });
|
|
1869
|
+
queryClient.invalidateQueries({ queryKey: productKeys.list({ my: true }) });
|
|
1870
|
+
},
|
|
1871
|
+
...options
|
|
1872
|
+
});
|
|
1873
|
+
}
|
|
1874
|
+
function useDeleteProduct(options) {
|
|
1875
|
+
const queryClient = reactQuery.useQueryClient();
|
|
1876
|
+
return reactQuery.useMutation({
|
|
1877
|
+
mutationFn: async (productId) => {
|
|
1878
|
+
const client = getApiClient();
|
|
1879
|
+
await client.delete(`/products/${productId}`);
|
|
1880
|
+
},
|
|
1881
|
+
onSuccess: () => {
|
|
1882
|
+
queryClient.invalidateQueries({ queryKey: productKeys.all });
|
|
1883
|
+
},
|
|
1884
|
+
...options
|
|
1885
|
+
});
|
|
1886
|
+
}
|
|
1887
|
+
function useAdjustStock(options) {
|
|
1888
|
+
const queryClient = reactQuery.useQueryClient();
|
|
1889
|
+
return reactQuery.useMutation({
|
|
1890
|
+
mutationFn: async ({ productId, quantity, reason, notes }) => {
|
|
1891
|
+
const client = getApiClient();
|
|
1892
|
+
const response = await client.post(
|
|
1893
|
+
`/products/${productId}/stock`,
|
|
1894
|
+
{ quantity, reason, notes }
|
|
1895
|
+
);
|
|
1896
|
+
return response.data.data;
|
|
1897
|
+
},
|
|
1898
|
+
onSuccess: (data) => {
|
|
1899
|
+
queryClient.setQueryData(productKeys.detail(data.id), data);
|
|
1900
|
+
queryClient.invalidateQueries({ queryKey: productKeys.bySpot(data.spotId) });
|
|
1901
|
+
},
|
|
1902
|
+
...options
|
|
1903
|
+
});
|
|
1904
|
+
}
|
|
1905
|
+
function useCreateOrder(options) {
|
|
1906
|
+
const queryClient = reactQuery.useQueryClient();
|
|
1907
|
+
return reactQuery.useMutation({
|
|
1908
|
+
mutationFn: async (data) => {
|
|
1909
|
+
const client = getApiClient();
|
|
1910
|
+
const response = await client.post(
|
|
1911
|
+
"/orders",
|
|
1912
|
+
data
|
|
1913
|
+
);
|
|
1914
|
+
return response.data.data;
|
|
1915
|
+
},
|
|
1916
|
+
onSuccess: (_, variables) => {
|
|
1917
|
+
queryClient.invalidateQueries({ queryKey: productKeys.bySpot(variables.spotId) });
|
|
1918
|
+
queryClient.invalidateQueries({ queryKey: orderKeys.list({ my: true }) });
|
|
1919
|
+
},
|
|
1920
|
+
...options
|
|
1921
|
+
});
|
|
1922
|
+
}
|
|
1923
|
+
function useCreateStripeIntent(options) {
|
|
1924
|
+
return reactQuery.useMutation({
|
|
1925
|
+
mutationFn: async (orderId) => {
|
|
1926
|
+
const client = getApiClient();
|
|
1927
|
+
const response = await client.post(
|
|
1928
|
+
`/payments/stripe/intent/${orderId}`
|
|
1929
|
+
);
|
|
1930
|
+
return response.data.data;
|
|
1931
|
+
},
|
|
1932
|
+
...options
|
|
1933
|
+
});
|
|
1934
|
+
}
|
|
1935
|
+
function useCreateCoinbaseCharge(options) {
|
|
1936
|
+
return reactQuery.useMutation({
|
|
1937
|
+
mutationFn: async (orderId) => {
|
|
1938
|
+
const client = getApiClient();
|
|
1939
|
+
const response = await client.post(
|
|
1940
|
+
`/payments/coinbase/charge/${orderId}`
|
|
1941
|
+
);
|
|
1942
|
+
return response.data.data;
|
|
1943
|
+
},
|
|
1944
|
+
...options
|
|
1945
|
+
});
|
|
1946
|
+
}
|
|
1947
|
+
function useUpdateOrderStatus(options) {
|
|
1948
|
+
const queryClient = reactQuery.useQueryClient();
|
|
1949
|
+
return reactQuery.useMutation({
|
|
1950
|
+
mutationFn: async ({ orderId, status }) => {
|
|
1951
|
+
const client = getApiClient();
|
|
1952
|
+
const response = await client.put(
|
|
1953
|
+
`/orders/${orderId}/status`,
|
|
1954
|
+
{ status }
|
|
1955
|
+
);
|
|
1956
|
+
return response.data.data;
|
|
1957
|
+
},
|
|
1958
|
+
onSuccess: (data) => {
|
|
1959
|
+
queryClient.setQueryData(orderKeys.detail(data.id), data);
|
|
1960
|
+
queryClient.invalidateQueries({ queryKey: orderKeys.spotOrders(data.spotId) });
|
|
1961
|
+
},
|
|
1962
|
+
...options
|
|
1963
|
+
});
|
|
1964
|
+
}
|
|
1965
|
+
function useCancelOrder(options) {
|
|
1966
|
+
const queryClient = reactQuery.useQueryClient();
|
|
1967
|
+
return reactQuery.useMutation({
|
|
1968
|
+
mutationFn: async (orderId) => {
|
|
1969
|
+
const client = getApiClient();
|
|
1970
|
+
const response = await client.post(
|
|
1971
|
+
`/orders/${orderId}/cancel`
|
|
1972
|
+
);
|
|
1973
|
+
return response.data.data;
|
|
1974
|
+
},
|
|
1975
|
+
onSuccess: (data) => {
|
|
1976
|
+
queryClient.setQueryData(orderKeys.detail(data.id), data);
|
|
1977
|
+
queryClient.invalidateQueries({ queryKey: orderKeys.list({ my: true }) });
|
|
1978
|
+
queryClient.invalidateQueries({ queryKey: productKeys.bySpot(data.spotId) });
|
|
1979
|
+
},
|
|
1980
|
+
...options
|
|
1981
|
+
});
|
|
1982
|
+
}
|
|
1983
|
+
function useRedeem() {
|
|
1984
|
+
const queryClient = reactQuery.useQueryClient();
|
|
1985
|
+
return reactQuery.useMutation({
|
|
1986
|
+
mutationFn: async (request) => {
|
|
1987
|
+
const client = getApiClient();
|
|
1988
|
+
const response = await client.post("/redemptions/redeem", request);
|
|
1989
|
+
return response.data.data;
|
|
1990
|
+
},
|
|
1991
|
+
onSuccess: (_data, variables) => {
|
|
1992
|
+
queryClient.invalidateQueries({
|
|
1993
|
+
queryKey: walletKeys.lookup(variables.qrCode)
|
|
1994
|
+
});
|
|
1995
|
+
if (variables.spotId) {
|
|
1996
|
+
queryClient.invalidateQueries({
|
|
1997
|
+
queryKey: walletKeys.spotRedemptions(variables.spotId)
|
|
1998
|
+
});
|
|
1999
|
+
}
|
|
2000
|
+
}
|
|
2001
|
+
});
|
|
2002
|
+
}
|
|
2003
|
+
function useVoidRedemption() {
|
|
2004
|
+
const queryClient = reactQuery.useQueryClient();
|
|
2005
|
+
return reactQuery.useMutation({
|
|
2006
|
+
mutationFn: async ({
|
|
2007
|
+
redemptionId,
|
|
2008
|
+
reason
|
|
2009
|
+
}) => {
|
|
2010
|
+
const client = getApiClient();
|
|
2011
|
+
const response = await client.put(`/redemptions/${redemptionId}/void`, { reason });
|
|
2012
|
+
return response.data.data;
|
|
2013
|
+
},
|
|
2014
|
+
onSuccess: () => {
|
|
2015
|
+
queryClient.invalidateQueries({ queryKey: walletKeys.all });
|
|
2016
|
+
queryClient.invalidateQueries({ queryKey: walletKeys.redemptions() });
|
|
2017
|
+
}
|
|
2018
|
+
});
|
|
2019
|
+
}
|
|
2020
|
+
|
|
2021
|
+
exports.clubKeys = clubKeys;
|
|
2022
|
+
exports.configureSDK = configureSDK;
|
|
2023
|
+
exports.conversationKeys = conversationKeys;
|
|
2024
|
+
exports.getApiClient = getApiClient;
|
|
2025
|
+
exports.getConfig = getConfig;
|
|
2026
|
+
exports.miscKeys = miscKeys;
|
|
2027
|
+
exports.notificationKeys = notificationKeys;
|
|
2028
|
+
exports.orderKeys = orderKeys;
|
|
2029
|
+
exports.postKeys = postKeys;
|
|
2030
|
+
exports.productKeys = productKeys;
|
|
2031
|
+
exports.spotKeys = spotKeys;
|
|
2032
|
+
exports.templateKeys = templateKeys;
|
|
2033
|
+
exports.useAdjustStock = useAdjustStock;
|
|
2034
|
+
exports.useBlockUser = useBlockUser;
|
|
2035
|
+
exports.useBlockedUsers = useBlockedUsers;
|
|
2036
|
+
exports.useCancelOrder = useCancelOrder;
|
|
2037
|
+
exports.useCities = useCities;
|
|
2038
|
+
exports.useClaimSpot = useClaimSpot;
|
|
2039
|
+
exports.useClub = useClub;
|
|
2040
|
+
exports.useClubBySlug = useClubBySlug;
|
|
2041
|
+
exports.useClubMembership = useClubMembership;
|
|
2042
|
+
exports.useClubsBySpot = useClubsBySpot;
|
|
2043
|
+
exports.useClubsByUser = useClubsByUser;
|
|
2044
|
+
exports.useCompleteOnboardingStep = useCompleteOnboardingStep;
|
|
2045
|
+
exports.useConversation = useConversation;
|
|
2046
|
+
exports.useConversationMessages = useConversationMessages;
|
|
2047
|
+
exports.useConversations = useConversations;
|
|
2048
|
+
exports.useCreateClub = useCreateClub;
|
|
2049
|
+
exports.useCreateCoinbaseCharge = useCreateCoinbaseCharge;
|
|
2050
|
+
exports.useCreateConversation = useCreateConversation;
|
|
2051
|
+
exports.useCreateDirectConversation = useCreateDirectConversation;
|
|
2052
|
+
exports.useCreateOrder = useCreateOrder;
|
|
2053
|
+
exports.useCreatePost = useCreatePost;
|
|
2054
|
+
exports.useCreateProduct = useCreateProduct;
|
|
2055
|
+
exports.useCreateReply = useCreateReply;
|
|
2056
|
+
exports.useCreateSpot = useCreateSpot;
|
|
2057
|
+
exports.useCreateStripeIntent = useCreateStripeIntent;
|
|
2058
|
+
exports.useCurrentUser = useCurrentUser;
|
|
2059
|
+
exports.useDeleteAccount = useDeleteAccount;
|
|
2060
|
+
exports.useDeletePost = useDeletePost;
|
|
2061
|
+
exports.useDeleteProduct = useDeleteProduct;
|
|
2062
|
+
exports.useDeleteReply = useDeleteReply;
|
|
2063
|
+
exports.useFavoriteSpot = useFavoriteSpot;
|
|
2064
|
+
exports.useFulfillPost = useFulfillPost;
|
|
2065
|
+
exports.useInfiniteSpots = useInfiniteSpots;
|
|
2066
|
+
exports.useJoinClub = useJoinClub;
|
|
2067
|
+
exports.useLeaveClub = useLeaveClub;
|
|
2068
|
+
exports.useLifeSituations = useLifeSituations;
|
|
2069
|
+
exports.useMarkConversationAsRead = useMarkConversationAsRead;
|
|
2070
|
+
exports.useMarkNotificationsRead = useMarkNotificationsRead;
|
|
2071
|
+
exports.useMyOrders = useMyOrders;
|
|
2072
|
+
exports.useNotifications = useNotifications;
|
|
2073
|
+
exports.useOrder = useOrder;
|
|
2074
|
+
exports.useOwnedSpots = useOwnedSpots;
|
|
2075
|
+
exports.usePost = usePost;
|
|
2076
|
+
exports.usePostResponses = usePostResponses;
|
|
2077
|
+
exports.usePostStatus = usePostStatus;
|
|
2078
|
+
exports.usePostUpvotes = usePostUpvotes;
|
|
2079
|
+
exports.usePosts = usePosts;
|
|
2080
|
+
exports.usePostsFeed = usePostsFeed;
|
|
2081
|
+
exports.useProduct = useProduct;
|
|
2082
|
+
exports.useProductBySlug = useProductBySlug;
|
|
2083
|
+
exports.useRateSpot = useRateSpot;
|
|
2084
|
+
exports.useRedeem = useRedeem;
|
|
2085
|
+
exports.useRedemptionLookup = useRedemptionLookup;
|
|
2086
|
+
exports.useRefreshToken = useRefreshToken;
|
|
2087
|
+
exports.useRegisterDeviceToken = useRegisterDeviceToken;
|
|
2088
|
+
exports.useRemoveDeviceToken = useRemoveDeviceToken;
|
|
2089
|
+
exports.useReportPost = useReportPost;
|
|
2090
|
+
exports.useReportSpot = useReportSpot;
|
|
2091
|
+
exports.useRespondToPost = useRespondToPost;
|
|
2092
|
+
exports.useSendMessage = useSendMessage;
|
|
2093
|
+
exports.useSendOtp = useSendOtp;
|
|
2094
|
+
exports.useSendTypingIndicator = useSendTypingIndicator;
|
|
2095
|
+
exports.useSpot = useSpot;
|
|
2096
|
+
exports.useSpotByQR = useSpotByQR;
|
|
2097
|
+
exports.useSpotBySlug = useSpotBySlug;
|
|
2098
|
+
exports.useSpotFavoriteStatus = useSpotFavoriteStatus;
|
|
2099
|
+
exports.useSpotImages = useSpotImages;
|
|
2100
|
+
exports.useSpotOrders = useSpotOrders;
|
|
2101
|
+
exports.useSpotPosts = useSpotPosts;
|
|
2102
|
+
exports.useSpotProducts = useSpotProducts;
|
|
2103
|
+
exports.useSpotRedemptions = useSpotRedemptions;
|
|
2104
|
+
exports.useSpots = useSpots;
|
|
2105
|
+
exports.useSubscribeToSpot = useSubscribeToSpot;
|
|
2106
|
+
exports.useTemplate = useTemplate;
|
|
2107
|
+
exports.useTemplateBySlug = useTemplateBySlug;
|
|
2108
|
+
exports.useTemplates = useTemplates;
|
|
2109
|
+
exports.useUnblockUser = useUnblockUser;
|
|
2110
|
+
exports.useUnreadNotificationCount = useUnreadNotificationCount;
|
|
2111
|
+
exports.useUnsubscribeFromSpot = useUnsubscribeFromSpot;
|
|
2112
|
+
exports.useUpdateClub = useUpdateClub;
|
|
2113
|
+
exports.useUpdateInterests = useUpdateInterests;
|
|
2114
|
+
exports.useUpdateOrderStatus = useUpdateOrderStatus;
|
|
2115
|
+
exports.useUpdatePost = useUpdatePost;
|
|
2116
|
+
exports.useUpdatePostStatus = useUpdatePostStatus;
|
|
2117
|
+
exports.useUpdateProduct = useUpdateProduct;
|
|
2118
|
+
exports.useUpdateProfile = useUpdateProfile;
|
|
2119
|
+
exports.useUpdateResponse = useUpdateResponse;
|
|
2120
|
+
exports.useUpdateSpot = useUpdateSpot;
|
|
2121
|
+
exports.useUpdateVibes = useUpdateVibes;
|
|
2122
|
+
exports.useUploadAvatar = useUploadAvatar;
|
|
2123
|
+
exports.useUpvotePost = useUpvotePost;
|
|
2124
|
+
exports.useUserActivity = useUserActivity;
|
|
2125
|
+
exports.useUserClubs = useUserClubs;
|
|
2126
|
+
exports.useUserFavorites = useUserFavorites;
|
|
2127
|
+
exports.useUserPosts = useUserPosts;
|
|
2128
|
+
exports.useUserSpotsSummary = useUserSpotsSummary;
|
|
2129
|
+
exports.useUserStats = useUserStats;
|
|
2130
|
+
exports.useUserSubscriptions = useUserSubscriptions;
|
|
2131
|
+
exports.useVerifyOtp = useVerifyOtp;
|
|
2132
|
+
exports.useVibes = useVibes;
|
|
2133
|
+
exports.useVoidRedemption = useVoidRedemption;
|
|
2134
|
+
exports.useWallet = useWallet;
|
|
2135
|
+
exports.useWalletHistory = useWalletHistory;
|
|
2136
|
+
exports.userKeys = userKeys;
|
|
2137
|
+
exports.walletKeys = walletKeys;
|
|
2138
|
+
//# sourceMappingURL=index.cjs.map
|
|
2139
|
+
//# sourceMappingURL=index.cjs.map
|