@diffsome/react 1.2.0 → 1.2.2
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.d.mts +63 -3
- package/dist/index.d.ts +63 -3
- package/dist/index.js +542 -346
- package/dist/index.mjs +538 -345
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -22,6 +22,7 @@ var index_exports = {};
|
|
|
22
22
|
__export(index_exports, {
|
|
23
23
|
DiffsomeContext: () => DiffsomeContext,
|
|
24
24
|
DiffsomeProvider: () => DiffsomeProvider,
|
|
25
|
+
RichContent: () => RichContent,
|
|
25
26
|
useAuth: () => useAuth,
|
|
26
27
|
useAvailableSlots: () => useAvailableSlots,
|
|
27
28
|
useBlog: () => useBlog,
|
|
@@ -46,6 +47,7 @@ __export(index_exports, {
|
|
|
46
47
|
useCreateReservation: () => useCreateReservation,
|
|
47
48
|
useCreateReview: () => useCreateReview,
|
|
48
49
|
useCreateSubscription: () => useCreateSubscription,
|
|
50
|
+
useCurrency: () => useCurrency,
|
|
49
51
|
useDiffsome: () => useDiffsome,
|
|
50
52
|
useDigitalProducts: () => useDigitalProducts,
|
|
51
53
|
useDownloads: () => useDownloads,
|
|
@@ -70,6 +72,7 @@ __export(index_exports, {
|
|
|
70
72
|
useReservationServices: () => useReservationServices,
|
|
71
73
|
useReservationSettings: () => useReservationSettings,
|
|
72
74
|
useReservationStaffs: () => useReservationStaffs,
|
|
75
|
+
useSite: () => useSite,
|
|
73
76
|
useSocialAuth: () => useSocialAuth,
|
|
74
77
|
useStripePayment: () => useStripePayment,
|
|
75
78
|
useSubscription: () => useSubscription,
|
|
@@ -147,19 +150,33 @@ function DiffsomeProvider({ children, config = {} }) {
|
|
|
147
150
|
}
|
|
148
151
|
}, [client]);
|
|
149
152
|
(0, import_react.useEffect)(() => {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
153
|
+
let mounted = true;
|
|
154
|
+
const init = async () => {
|
|
155
|
+
if (!mounted) return;
|
|
156
|
+
setIsReady(true);
|
|
157
|
+
try {
|
|
158
|
+
const cartData = await client.shop.getCart();
|
|
159
|
+
if (mounted) setCart(cartData);
|
|
160
|
+
} catch (err) {
|
|
161
|
+
if (mounted) setCart(null);
|
|
162
|
+
} finally {
|
|
163
|
+
if (mounted) setCartLoading(false);
|
|
164
|
+
}
|
|
165
|
+
if (client.isAuthenticated()) {
|
|
166
|
+
try {
|
|
167
|
+
const response = await client.shop.getWishlist({ per_page: 100 });
|
|
168
|
+
if (mounted) setWishlistItems(response.data);
|
|
169
|
+
} catch (err) {
|
|
170
|
+
if (mounted) setWishlistItems([]);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
if (mounted) setWishlistLoading(false);
|
|
157
174
|
};
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
}
|
|
162
|
-
}, [
|
|
175
|
+
init();
|
|
176
|
+
return () => {
|
|
177
|
+
mounted = false;
|
|
178
|
+
};
|
|
179
|
+
}, [client]);
|
|
163
180
|
const value = (0, import_react.useMemo)(() => ({
|
|
164
181
|
client,
|
|
165
182
|
isReady,
|
|
@@ -186,15 +203,104 @@ function useClient() {
|
|
|
186
203
|
return client;
|
|
187
204
|
}
|
|
188
205
|
|
|
189
|
-
// src/hooks/
|
|
206
|
+
// src/hooks/useSite.ts
|
|
190
207
|
var import_react2 = require("react");
|
|
191
|
-
|
|
208
|
+
var DEFAULT_CURRENCY = {
|
|
209
|
+
code: "KRW",
|
|
210
|
+
symbol: "\u20A9",
|
|
211
|
+
position: "before",
|
|
212
|
+
decimals: 0
|
|
213
|
+
};
|
|
214
|
+
function useSite() {
|
|
192
215
|
const client = useClient();
|
|
193
|
-
const [
|
|
216
|
+
const [site, setSite] = (0, import_react2.useState)(null);
|
|
194
217
|
const [loading, setLoading] = (0, import_react2.useState)(true);
|
|
195
218
|
const [error, setError] = (0, import_react2.useState)(null);
|
|
219
|
+
const fetchSite = (0, import_react2.useCallback)(async () => {
|
|
220
|
+
setLoading(true);
|
|
221
|
+
setError(null);
|
|
222
|
+
try {
|
|
223
|
+
const data = await client.site.getInfo();
|
|
224
|
+
setSite(data);
|
|
225
|
+
} catch (err) {
|
|
226
|
+
setError(err instanceof Error ? err : new Error("Failed to fetch site info"));
|
|
227
|
+
} finally {
|
|
228
|
+
setLoading(false);
|
|
229
|
+
}
|
|
230
|
+
}, [client]);
|
|
231
|
+
(0, import_react2.useEffect)(() => {
|
|
232
|
+
fetchSite();
|
|
233
|
+
}, [fetchSite]);
|
|
234
|
+
const currency = site?.currency ?? null;
|
|
235
|
+
const formatPrice = (0, import_react2.useCallback)((amount) => {
|
|
236
|
+
const curr = currency ?? DEFAULT_CURRENCY;
|
|
237
|
+
const formatted = amount.toLocaleString(void 0, {
|
|
238
|
+
minimumFractionDigits: curr.decimals,
|
|
239
|
+
maximumFractionDigits: curr.decimals
|
|
240
|
+
});
|
|
241
|
+
if (curr.position === "after") {
|
|
242
|
+
return `${formatted}${curr.symbol}`;
|
|
243
|
+
}
|
|
244
|
+
return `${curr.symbol}${formatted}`;
|
|
245
|
+
}, [currency]);
|
|
246
|
+
return {
|
|
247
|
+
site,
|
|
248
|
+
loading,
|
|
249
|
+
error,
|
|
250
|
+
refresh: fetchSite,
|
|
251
|
+
currency,
|
|
252
|
+
formatPrice
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
function useCurrency() {
|
|
256
|
+
const client = useClient();
|
|
257
|
+
const [currency, setCurrency] = (0, import_react2.useState)(null);
|
|
258
|
+
const [loading, setLoading] = (0, import_react2.useState)(true);
|
|
259
|
+
const [error, setError] = (0, import_react2.useState)(null);
|
|
260
|
+
const fetchCurrency = (0, import_react2.useCallback)(async () => {
|
|
261
|
+
setLoading(true);
|
|
262
|
+
setError(null);
|
|
263
|
+
try {
|
|
264
|
+
const data = await client.site.getCurrency();
|
|
265
|
+
setCurrency(data);
|
|
266
|
+
} catch (err) {
|
|
267
|
+
setError(err instanceof Error ? err : new Error("Failed to fetch currency"));
|
|
268
|
+
} finally {
|
|
269
|
+
setLoading(false);
|
|
270
|
+
}
|
|
271
|
+
}, [client]);
|
|
272
|
+
(0, import_react2.useEffect)(() => {
|
|
273
|
+
fetchCurrency();
|
|
274
|
+
}, [fetchCurrency]);
|
|
275
|
+
const formatPrice = (0, import_react2.useCallback)((amount) => {
|
|
276
|
+
const curr = currency ?? DEFAULT_CURRENCY;
|
|
277
|
+
const formatted = amount.toLocaleString(void 0, {
|
|
278
|
+
minimumFractionDigits: curr.decimals,
|
|
279
|
+
maximumFractionDigits: curr.decimals
|
|
280
|
+
});
|
|
281
|
+
if (curr.position === "after") {
|
|
282
|
+
return `${formatted}${curr.symbol}`;
|
|
283
|
+
}
|
|
284
|
+
return `${curr.symbol}${formatted}`;
|
|
285
|
+
}, [currency]);
|
|
286
|
+
return {
|
|
287
|
+
currency,
|
|
288
|
+
loading,
|
|
289
|
+
error,
|
|
290
|
+
formatPrice,
|
|
291
|
+
refresh: fetchCurrency
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
// src/hooks/useAuth.ts
|
|
296
|
+
var import_react3 = require("react");
|
|
297
|
+
function useAuth() {
|
|
298
|
+
const client = useClient();
|
|
299
|
+
const [user, setUser] = (0, import_react3.useState)(null);
|
|
300
|
+
const [loading, setLoading] = (0, import_react3.useState)(true);
|
|
301
|
+
const [error, setError] = (0, import_react3.useState)(null);
|
|
196
302
|
const isAuthenticated = !!user && client.isAuthenticated();
|
|
197
|
-
const fetchProfile = (0,
|
|
303
|
+
const fetchProfile = (0, import_react3.useCallback)(async () => {
|
|
198
304
|
if (!client.isAuthenticated()) {
|
|
199
305
|
setUser(null);
|
|
200
306
|
setLoading(false);
|
|
@@ -211,10 +317,10 @@ function useAuth() {
|
|
|
211
317
|
setLoading(false);
|
|
212
318
|
}
|
|
213
319
|
}, [client]);
|
|
214
|
-
(0,
|
|
320
|
+
(0, import_react3.useEffect)(() => {
|
|
215
321
|
fetchProfile();
|
|
216
322
|
}, [fetchProfile]);
|
|
217
|
-
const login = (0,
|
|
323
|
+
const login = (0, import_react3.useCallback)(async (credentials) => {
|
|
218
324
|
setLoading(true);
|
|
219
325
|
setError(null);
|
|
220
326
|
try {
|
|
@@ -229,7 +335,7 @@ function useAuth() {
|
|
|
229
335
|
setLoading(false);
|
|
230
336
|
}
|
|
231
337
|
}, [client]);
|
|
232
|
-
const register = (0,
|
|
338
|
+
const register = (0, import_react3.useCallback)(async (data) => {
|
|
233
339
|
setLoading(true);
|
|
234
340
|
setError(null);
|
|
235
341
|
try {
|
|
@@ -244,7 +350,7 @@ function useAuth() {
|
|
|
244
350
|
setLoading(false);
|
|
245
351
|
}
|
|
246
352
|
}, [client]);
|
|
247
|
-
const logout = (0,
|
|
353
|
+
const logout = (0, import_react3.useCallback)(async () => {
|
|
248
354
|
setLoading(true);
|
|
249
355
|
try {
|
|
250
356
|
await client.auth.logout();
|
|
@@ -253,23 +359,23 @@ function useAuth() {
|
|
|
253
359
|
setLoading(false);
|
|
254
360
|
}
|
|
255
361
|
}, [client]);
|
|
256
|
-
const getProfile = (0,
|
|
362
|
+
const getProfile = (0, import_react3.useCallback)(async () => {
|
|
257
363
|
const profile = await client.auth.me();
|
|
258
364
|
setUser(profile);
|
|
259
365
|
return profile;
|
|
260
366
|
}, [client]);
|
|
261
|
-
const updateProfile = (0,
|
|
367
|
+
const updateProfile = (0, import_react3.useCallback)(async (data) => {
|
|
262
368
|
const profile = await client.auth.updateProfile(data);
|
|
263
369
|
setUser(profile);
|
|
264
370
|
return profile;
|
|
265
371
|
}, [client]);
|
|
266
|
-
const forgotPassword = (0,
|
|
372
|
+
const forgotPassword = (0, import_react3.useCallback)(async (email) => {
|
|
267
373
|
return await client.auth.forgotPassword({ email });
|
|
268
374
|
}, [client]);
|
|
269
|
-
const resetPassword = (0,
|
|
375
|
+
const resetPassword = (0, import_react3.useCallback)(async (data) => {
|
|
270
376
|
return await client.auth.resetPassword(data);
|
|
271
377
|
}, [client]);
|
|
272
|
-
const refresh = (0,
|
|
378
|
+
const refresh = (0, import_react3.useCallback)(async () => {
|
|
273
379
|
await fetchProfile();
|
|
274
380
|
}, [fetchProfile]);
|
|
275
381
|
return {
|
|
@@ -289,13 +395,13 @@ function useAuth() {
|
|
|
289
395
|
}
|
|
290
396
|
|
|
291
397
|
// src/hooks/useSocialAuth.ts
|
|
292
|
-
var
|
|
398
|
+
var import_react4 = require("react");
|
|
293
399
|
function useSocialAuth() {
|
|
294
400
|
const client = useClient();
|
|
295
|
-
const [providers, setProviders] = (0,
|
|
296
|
-
const [loading, setLoading] = (0,
|
|
297
|
-
const [error, setError] = (0,
|
|
298
|
-
const fetchProviders = (0,
|
|
401
|
+
const [providers, setProviders] = (0, import_react4.useState)([]);
|
|
402
|
+
const [loading, setLoading] = (0, import_react4.useState)(true);
|
|
403
|
+
const [error, setError] = (0, import_react4.useState)(null);
|
|
404
|
+
const fetchProviders = (0, import_react4.useCallback)(async () => {
|
|
299
405
|
setLoading(true);
|
|
300
406
|
setError(null);
|
|
301
407
|
try {
|
|
@@ -307,14 +413,14 @@ function useSocialAuth() {
|
|
|
307
413
|
setLoading(false);
|
|
308
414
|
}
|
|
309
415
|
}, [client]);
|
|
310
|
-
(0,
|
|
416
|
+
(0, import_react4.useEffect)(() => {
|
|
311
417
|
fetchProviders();
|
|
312
418
|
}, [fetchProviders]);
|
|
313
|
-
const getAuthUrl = (0,
|
|
419
|
+
const getAuthUrl = (0, import_react4.useCallback)(async (provider) => {
|
|
314
420
|
const result = await client.auth.getSocialAuthUrl(provider);
|
|
315
421
|
return result.url;
|
|
316
422
|
}, [client]);
|
|
317
|
-
const handleCallback = (0,
|
|
423
|
+
const handleCallback = (0, import_react4.useCallback)(async (provider, code) => {
|
|
318
424
|
return await client.auth.socialCallback(provider, code);
|
|
319
425
|
}, [client]);
|
|
320
426
|
return {
|
|
@@ -328,10 +434,10 @@ function useSocialAuth() {
|
|
|
328
434
|
}
|
|
329
435
|
|
|
330
436
|
// src/hooks/useCart.ts
|
|
331
|
-
var
|
|
437
|
+
var import_react5 = require("react");
|
|
332
438
|
function useCart() {
|
|
333
439
|
const { client, cart, cartLoading, setCart, refreshCart } = useDiffsome();
|
|
334
|
-
const addToCart = (0,
|
|
440
|
+
const addToCart = (0, import_react5.useCallback)(async (productId, quantity = 1, variantId, options) => {
|
|
335
441
|
const data = {
|
|
336
442
|
product_id: productId,
|
|
337
443
|
quantity,
|
|
@@ -342,27 +448,27 @@ function useCart() {
|
|
|
342
448
|
setCart(updatedCart);
|
|
343
449
|
return updatedCart;
|
|
344
450
|
}, [client, setCart]);
|
|
345
|
-
const updateItem = (0,
|
|
451
|
+
const updateItem = (0, import_react5.useCallback)(async (itemId, quantity) => {
|
|
346
452
|
const updatedCart = await client.shop.updateCartItem(itemId, { quantity });
|
|
347
453
|
setCart(updatedCart);
|
|
348
454
|
return updatedCart;
|
|
349
455
|
}, [client, setCart]);
|
|
350
|
-
const removeItem = (0,
|
|
456
|
+
const removeItem = (0, import_react5.useCallback)(async (itemId) => {
|
|
351
457
|
const updatedCart = await client.shop.removeFromCart(itemId);
|
|
352
458
|
setCart(updatedCart);
|
|
353
459
|
return updatedCart;
|
|
354
460
|
}, [client, setCart]);
|
|
355
|
-
const clearCart = (0,
|
|
461
|
+
const clearCart = (0, import_react5.useCallback)(async () => {
|
|
356
462
|
await client.shop.clearCart();
|
|
357
463
|
setCart(null);
|
|
358
464
|
}, [client, setCart]);
|
|
359
|
-
const isInCart = (0,
|
|
465
|
+
const isInCart = (0, import_react5.useCallback)((productId, variantId) => {
|
|
360
466
|
if (!cart?.items) return false;
|
|
361
467
|
return cart.items.some(
|
|
362
468
|
(item) => item.product_id === productId && (variantId === void 0 || item.variant_id === variantId)
|
|
363
469
|
);
|
|
364
470
|
}, [cart]);
|
|
365
|
-
const getItemQuantity = (0,
|
|
471
|
+
const getItemQuantity = (0, import_react5.useCallback)((productId, variantId) => {
|
|
366
472
|
if (!cart?.items) return 0;
|
|
367
473
|
const item = cart.items.find(
|
|
368
474
|
(item2) => item2.product_id === productId && (variantId === void 0 || item2.variant_id === variantId)
|
|
@@ -389,11 +495,11 @@ function useCart() {
|
|
|
389
495
|
}
|
|
390
496
|
|
|
391
497
|
// src/hooks/useWishlist.ts
|
|
392
|
-
var
|
|
498
|
+
var import_react6 = require("react");
|
|
393
499
|
function useWishlist() {
|
|
394
500
|
const { client, wishlistItems, wishlistLoading, setWishlistItems, refreshWishlist, setCart } = useDiffsome();
|
|
395
|
-
const [error, setError] = (0,
|
|
396
|
-
const wishlistMap = (0,
|
|
501
|
+
const [error, setError] = (0, import_react6.useState)(null);
|
|
502
|
+
const wishlistMap = (0, import_react6.useMemo)(() => {
|
|
397
503
|
const map = {};
|
|
398
504
|
wishlistItems.forEach((item) => {
|
|
399
505
|
const key = item.variant_id ? `${item.product_id}_${item.variant_id}` : String(item.product_id);
|
|
@@ -401,11 +507,11 @@ function useWishlist() {
|
|
|
401
507
|
});
|
|
402
508
|
return map;
|
|
403
509
|
}, [wishlistItems]);
|
|
404
|
-
const isInWishlist = (0,
|
|
510
|
+
const isInWishlist = (0, import_react6.useCallback)((productId, variantId) => {
|
|
405
511
|
const key = variantId ? `${productId}_${variantId}` : String(productId);
|
|
406
512
|
return wishlistMap[key] || false;
|
|
407
513
|
}, [wishlistMap]);
|
|
408
|
-
const toggleWishlist = (0,
|
|
514
|
+
const toggleWishlist = (0, import_react6.useCallback)(async (productId, variantId) => {
|
|
409
515
|
const result = await client.shop.toggleWishlist(productId, variantId);
|
|
410
516
|
if (result.action === "added") {
|
|
411
517
|
await refreshWishlist();
|
|
@@ -416,7 +522,7 @@ function useWishlist() {
|
|
|
416
522
|
}
|
|
417
523
|
return result;
|
|
418
524
|
}, [client, refreshWishlist, setWishlistItems, wishlistItems]);
|
|
419
|
-
const addToWishlist = (0,
|
|
525
|
+
const addToWishlist = (0, import_react6.useCallback)(async (productId, variantId, note) => {
|
|
420
526
|
const item = await client.shop.addToWishlist({
|
|
421
527
|
product_id: productId,
|
|
422
528
|
variant_id: variantId,
|
|
@@ -425,23 +531,23 @@ function useWishlist() {
|
|
|
425
531
|
await refreshWishlist();
|
|
426
532
|
return item;
|
|
427
533
|
}, [client, refreshWishlist]);
|
|
428
|
-
const removeFromWishlist = (0,
|
|
534
|
+
const removeFromWishlist = (0, import_react6.useCallback)(async (wishlistId) => {
|
|
429
535
|
await client.shop.removeFromWishlist(wishlistId);
|
|
430
536
|
setWishlistItems(wishlistItems.filter((i) => i.id !== wishlistId));
|
|
431
537
|
}, [client, setWishlistItems, wishlistItems]);
|
|
432
|
-
const moveToCart = (0,
|
|
538
|
+
const moveToCart = (0, import_react6.useCallback)(async (wishlistIds) => {
|
|
433
539
|
const result = await client.shop.moveWishlistToCart(wishlistIds);
|
|
434
540
|
await refreshWishlist();
|
|
435
541
|
const cartData = await client.shop.getCart();
|
|
436
542
|
setCart(cartData);
|
|
437
543
|
return result;
|
|
438
544
|
}, [client, refreshWishlist, setCart]);
|
|
439
|
-
const updateNote = (0,
|
|
545
|
+
const updateNote = (0, import_react6.useCallback)(async (wishlistId, note) => {
|
|
440
546
|
const item = await client.shop.updateWishlistNote(wishlistId, note);
|
|
441
547
|
setWishlistItems(wishlistItems.map((i) => i.id === wishlistId ? item : i));
|
|
442
548
|
return item;
|
|
443
549
|
}, [client, setWishlistItems, wishlistItems]);
|
|
444
|
-
const getProductWishlistCount = (0,
|
|
550
|
+
const getProductWishlistCount = (0, import_react6.useCallback)(async (productSlug) => {
|
|
445
551
|
return await client.shop.getProductWishlistCount(productSlug);
|
|
446
552
|
}, [client]);
|
|
447
553
|
return {
|
|
@@ -461,16 +567,16 @@ function useWishlist() {
|
|
|
461
567
|
}
|
|
462
568
|
|
|
463
569
|
// src/hooks/useProducts.ts
|
|
464
|
-
var
|
|
570
|
+
var import_react7 = require("react");
|
|
465
571
|
function useProducts(options = {}) {
|
|
466
572
|
const { autoFetch = true, ...params } = options;
|
|
467
573
|
const client = useClient();
|
|
468
|
-
const [products, setProducts] = (0,
|
|
469
|
-
const [meta, setMeta] = (0,
|
|
470
|
-
const [loading, setLoading] = (0,
|
|
471
|
-
const [error, setError] = (0,
|
|
472
|
-
const [currentParams, setCurrentParams] = (0,
|
|
473
|
-
const fetchProducts = (0,
|
|
574
|
+
const [products, setProducts] = (0, import_react7.useState)([]);
|
|
575
|
+
const [meta, setMeta] = (0, import_react7.useState)(null);
|
|
576
|
+
const [loading, setLoading] = (0, import_react7.useState)(autoFetch);
|
|
577
|
+
const [error, setError] = (0, import_react7.useState)(null);
|
|
578
|
+
const [currentParams, setCurrentParams] = (0, import_react7.useState)(params);
|
|
579
|
+
const fetchProducts = (0, import_react7.useCallback)(async (fetchParams, append = false) => {
|
|
474
580
|
setLoading(true);
|
|
475
581
|
setError(null);
|
|
476
582
|
try {
|
|
@@ -487,22 +593,22 @@ function useProducts(options = {}) {
|
|
|
487
593
|
setLoading(false);
|
|
488
594
|
}
|
|
489
595
|
}, [client]);
|
|
490
|
-
(0,
|
|
596
|
+
(0, import_react7.useEffect)(() => {
|
|
491
597
|
if (autoFetch) {
|
|
492
598
|
fetchProducts(params);
|
|
493
599
|
}
|
|
494
600
|
}, []);
|
|
495
601
|
const hasMore = meta ? meta.current_page < meta.last_page : false;
|
|
496
|
-
const loadMore = (0,
|
|
602
|
+
const loadMore = (0, import_react7.useCallback)(async () => {
|
|
497
603
|
if (!hasMore || loading) return;
|
|
498
604
|
const nextPage = (meta?.current_page ?? 0) + 1;
|
|
499
605
|
await fetchProducts({ ...currentParams, page: nextPage }, true);
|
|
500
606
|
}, [hasMore, loading, meta, currentParams, fetchProducts]);
|
|
501
|
-
const refresh = (0,
|
|
607
|
+
const refresh = (0, import_react7.useCallback)(async () => {
|
|
502
608
|
setCurrentParams(params);
|
|
503
609
|
await fetchProducts(params);
|
|
504
610
|
}, [params, fetchProducts]);
|
|
505
|
-
const search = (0,
|
|
611
|
+
const search = (0, import_react7.useCallback)(async (query) => {
|
|
506
612
|
const searchParams = { ...params, search: query, page: 1 };
|
|
507
613
|
setCurrentParams(searchParams);
|
|
508
614
|
await fetchProducts(searchParams);
|
|
@@ -520,10 +626,10 @@ function useProducts(options = {}) {
|
|
|
520
626
|
}
|
|
521
627
|
function useProduct(idOrSlug) {
|
|
522
628
|
const client = useClient();
|
|
523
|
-
const [product, setProduct] = (0,
|
|
524
|
-
const [loading, setLoading] = (0,
|
|
525
|
-
const [error, setError] = (0,
|
|
526
|
-
const fetchProduct = (0,
|
|
629
|
+
const [product, setProduct] = (0, import_react7.useState)(null);
|
|
630
|
+
const [loading, setLoading] = (0, import_react7.useState)(true);
|
|
631
|
+
const [error, setError] = (0, import_react7.useState)(null);
|
|
632
|
+
const fetchProduct = (0, import_react7.useCallback)(async () => {
|
|
527
633
|
setLoading(true);
|
|
528
634
|
setError(null);
|
|
529
635
|
try {
|
|
@@ -535,7 +641,7 @@ function useProduct(idOrSlug) {
|
|
|
535
641
|
setLoading(false);
|
|
536
642
|
}
|
|
537
643
|
}, [client, idOrSlug]);
|
|
538
|
-
(0,
|
|
644
|
+
(0, import_react7.useEffect)(() => {
|
|
539
645
|
fetchProduct();
|
|
540
646
|
}, [fetchProduct]);
|
|
541
647
|
return {
|
|
@@ -547,10 +653,10 @@ function useProduct(idOrSlug) {
|
|
|
547
653
|
}
|
|
548
654
|
function useCategories() {
|
|
549
655
|
const client = useClient();
|
|
550
|
-
const [categories, setCategories] = (0,
|
|
551
|
-
const [loading, setLoading] = (0,
|
|
552
|
-
const [error, setError] = (0,
|
|
553
|
-
const fetchCategories = (0,
|
|
656
|
+
const [categories, setCategories] = (0, import_react7.useState)([]);
|
|
657
|
+
const [loading, setLoading] = (0, import_react7.useState)(true);
|
|
658
|
+
const [error, setError] = (0, import_react7.useState)(null);
|
|
659
|
+
const fetchCategories = (0, import_react7.useCallback)(async () => {
|
|
554
660
|
setLoading(true);
|
|
555
661
|
setError(null);
|
|
556
662
|
try {
|
|
@@ -562,7 +668,7 @@ function useCategories() {
|
|
|
562
668
|
setLoading(false);
|
|
563
669
|
}
|
|
564
670
|
}, [client]);
|
|
565
|
-
(0,
|
|
671
|
+
(0, import_react7.useEffect)(() => {
|
|
566
672
|
fetchCategories();
|
|
567
673
|
}, [fetchCategories]);
|
|
568
674
|
return {
|
|
@@ -574,10 +680,10 @@ function useCategories() {
|
|
|
574
680
|
}
|
|
575
681
|
function useFeaturedProducts(limit = 8) {
|
|
576
682
|
const client = useClient();
|
|
577
|
-
const [products, setProducts] = (0,
|
|
578
|
-
const [loading, setLoading] = (0,
|
|
579
|
-
const [error, setError] = (0,
|
|
580
|
-
const fetchProducts = (0,
|
|
683
|
+
const [products, setProducts] = (0, import_react7.useState)([]);
|
|
684
|
+
const [loading, setLoading] = (0, import_react7.useState)(true);
|
|
685
|
+
const [error, setError] = (0, import_react7.useState)(null);
|
|
686
|
+
const fetchProducts = (0, import_react7.useCallback)(async () => {
|
|
581
687
|
setLoading(true);
|
|
582
688
|
setError(null);
|
|
583
689
|
try {
|
|
@@ -589,7 +695,7 @@ function useFeaturedProducts(limit = 8) {
|
|
|
589
695
|
setLoading(false);
|
|
590
696
|
}
|
|
591
697
|
}, [client, limit]);
|
|
592
|
-
(0,
|
|
698
|
+
(0, import_react7.useEffect)(() => {
|
|
593
699
|
fetchProducts();
|
|
594
700
|
}, [fetchProducts]);
|
|
595
701
|
return {
|
|
@@ -601,11 +707,11 @@ function useFeaturedProducts(limit = 8) {
|
|
|
601
707
|
}
|
|
602
708
|
function useProductsByType(type, params) {
|
|
603
709
|
const client = useClient();
|
|
604
|
-
const [products, setProducts] = (0,
|
|
605
|
-
const [meta, setMeta] = (0,
|
|
606
|
-
const [loading, setLoading] = (0,
|
|
607
|
-
const [error, setError] = (0,
|
|
608
|
-
const fetchProducts = (0,
|
|
710
|
+
const [products, setProducts] = (0, import_react7.useState)([]);
|
|
711
|
+
const [meta, setMeta] = (0, import_react7.useState)(null);
|
|
712
|
+
const [loading, setLoading] = (0, import_react7.useState)(true);
|
|
713
|
+
const [error, setError] = (0, import_react7.useState)(null);
|
|
714
|
+
const fetchProducts = (0, import_react7.useCallback)(async () => {
|
|
609
715
|
setLoading(true);
|
|
610
716
|
setError(null);
|
|
611
717
|
try {
|
|
@@ -618,7 +724,7 @@ function useProductsByType(type, params) {
|
|
|
618
724
|
setLoading(false);
|
|
619
725
|
}
|
|
620
726
|
}, [client, type, params]);
|
|
621
|
-
(0,
|
|
727
|
+
(0, import_react7.useEffect)(() => {
|
|
622
728
|
fetchProducts();
|
|
623
729
|
}, [fetchProducts]);
|
|
624
730
|
return {
|
|
@@ -640,10 +746,10 @@ function useBundleProducts(params) {
|
|
|
640
746
|
}
|
|
641
747
|
function useBundleItems(productSlug) {
|
|
642
748
|
const client = useClient();
|
|
643
|
-
const [bundle, setBundle] = (0,
|
|
644
|
-
const [loading, setLoading] = (0,
|
|
645
|
-
const [error, setError] = (0,
|
|
646
|
-
const fetchBundle = (0,
|
|
749
|
+
const [bundle, setBundle] = (0, import_react7.useState)(null);
|
|
750
|
+
const [loading, setLoading] = (0, import_react7.useState)(true);
|
|
751
|
+
const [error, setError] = (0, import_react7.useState)(null);
|
|
752
|
+
const fetchBundle = (0, import_react7.useCallback)(async () => {
|
|
647
753
|
setLoading(true);
|
|
648
754
|
setError(null);
|
|
649
755
|
try {
|
|
@@ -655,7 +761,7 @@ function useBundleItems(productSlug) {
|
|
|
655
761
|
setLoading(false);
|
|
656
762
|
}
|
|
657
763
|
}, [client, productSlug]);
|
|
658
|
-
(0,
|
|
764
|
+
(0, import_react7.useEffect)(() => {
|
|
659
765
|
fetchBundle();
|
|
660
766
|
}, [fetchBundle]);
|
|
661
767
|
return {
|
|
@@ -667,14 +773,14 @@ function useBundleItems(productSlug) {
|
|
|
667
773
|
}
|
|
668
774
|
|
|
669
775
|
// src/hooks/useOrders.ts
|
|
670
|
-
var
|
|
776
|
+
var import_react8 = require("react");
|
|
671
777
|
function useOrders(params) {
|
|
672
778
|
const client = useClient();
|
|
673
|
-
const [orders, setOrders] = (0,
|
|
674
|
-
const [meta, setMeta] = (0,
|
|
675
|
-
const [loading, setLoading] = (0,
|
|
676
|
-
const [error, setError] = (0,
|
|
677
|
-
const fetchOrders = (0,
|
|
779
|
+
const [orders, setOrders] = (0, import_react8.useState)([]);
|
|
780
|
+
const [meta, setMeta] = (0, import_react8.useState)(null);
|
|
781
|
+
const [loading, setLoading] = (0, import_react8.useState)(true);
|
|
782
|
+
const [error, setError] = (0, import_react8.useState)(null);
|
|
783
|
+
const fetchOrders = (0, import_react8.useCallback)(async (fetchParams, append = false) => {
|
|
678
784
|
if (!client.isAuthenticated()) {
|
|
679
785
|
setOrders([]);
|
|
680
786
|
setLoading(false);
|
|
@@ -696,16 +802,16 @@ function useOrders(params) {
|
|
|
696
802
|
setLoading(false);
|
|
697
803
|
}
|
|
698
804
|
}, [client]);
|
|
699
|
-
(0,
|
|
805
|
+
(0, import_react8.useEffect)(() => {
|
|
700
806
|
fetchOrders(params);
|
|
701
807
|
}, []);
|
|
702
808
|
const hasMore = meta ? meta.current_page < meta.last_page : false;
|
|
703
|
-
const loadMore = (0,
|
|
809
|
+
const loadMore = (0, import_react8.useCallback)(async () => {
|
|
704
810
|
if (!hasMore || loading) return;
|
|
705
811
|
const nextPage = (meta?.current_page ?? 0) + 1;
|
|
706
812
|
await fetchOrders({ ...params, page: nextPage }, true);
|
|
707
813
|
}, [hasMore, loading, meta, params, fetchOrders]);
|
|
708
|
-
const refresh = (0,
|
|
814
|
+
const refresh = (0, import_react8.useCallback)(async () => {
|
|
709
815
|
await fetchOrders(params);
|
|
710
816
|
}, [params, fetchOrders]);
|
|
711
817
|
return {
|
|
@@ -720,10 +826,10 @@ function useOrders(params) {
|
|
|
720
826
|
}
|
|
721
827
|
function useOrder(idOrNumber) {
|
|
722
828
|
const client = useClient();
|
|
723
|
-
const [order, setOrder] = (0,
|
|
724
|
-
const [loading, setLoading] = (0,
|
|
725
|
-
const [error, setError] = (0,
|
|
726
|
-
const fetchOrder = (0,
|
|
829
|
+
const [order, setOrder] = (0, import_react8.useState)(null);
|
|
830
|
+
const [loading, setLoading] = (0, import_react8.useState)(true);
|
|
831
|
+
const [error, setError] = (0, import_react8.useState)(null);
|
|
832
|
+
const fetchOrder = (0, import_react8.useCallback)(async () => {
|
|
727
833
|
setLoading(true);
|
|
728
834
|
setError(null);
|
|
729
835
|
try {
|
|
@@ -735,10 +841,10 @@ function useOrder(idOrNumber) {
|
|
|
735
841
|
setLoading(false);
|
|
736
842
|
}
|
|
737
843
|
}, [client, idOrNumber]);
|
|
738
|
-
(0,
|
|
844
|
+
(0, import_react8.useEffect)(() => {
|
|
739
845
|
fetchOrder();
|
|
740
846
|
}, [fetchOrder]);
|
|
741
|
-
const cancel = (0,
|
|
847
|
+
const cancel = (0, import_react8.useCallback)(async () => {
|
|
742
848
|
if (!order) throw new Error("Order not loaded");
|
|
743
849
|
const cancelled = await client.shop.cancelOrder(order.id);
|
|
744
850
|
setOrder(cancelled);
|
|
@@ -754,9 +860,9 @@ function useOrder(idOrNumber) {
|
|
|
754
860
|
}
|
|
755
861
|
function useCreateOrder() {
|
|
756
862
|
const client = useClient();
|
|
757
|
-
const [loading, setLoading] = (0,
|
|
758
|
-
const [error, setError] = (0,
|
|
759
|
-
const createOrder = (0,
|
|
863
|
+
const [loading, setLoading] = (0, import_react8.useState)(false);
|
|
864
|
+
const [error, setError] = (0, import_react8.useState)(null);
|
|
865
|
+
const createOrder = (0, import_react8.useCallback)(async (data) => {
|
|
760
866
|
setLoading(true);
|
|
761
867
|
setError(null);
|
|
762
868
|
try {
|
|
@@ -777,13 +883,19 @@ function useCreateOrder() {
|
|
|
777
883
|
}
|
|
778
884
|
|
|
779
885
|
// src/hooks/usePayment.ts
|
|
780
|
-
var
|
|
886
|
+
var import_react9 = require("react");
|
|
887
|
+
var DEFAULT_CURRENCY2 = {
|
|
888
|
+
code: "KRW",
|
|
889
|
+
symbol: "\u20A9",
|
|
890
|
+
position: "before",
|
|
891
|
+
decimals: 0
|
|
892
|
+
};
|
|
781
893
|
function usePaymentStatus() {
|
|
782
894
|
const client = useClient();
|
|
783
|
-
const [status, setStatus] = (0,
|
|
784
|
-
const [loading, setLoading] = (0,
|
|
785
|
-
const [error, setError] = (0,
|
|
786
|
-
const fetchStatus = (0,
|
|
895
|
+
const [status, setStatus] = (0, import_react9.useState)(null);
|
|
896
|
+
const [loading, setLoading] = (0, import_react9.useState)(true);
|
|
897
|
+
const [error, setError] = (0, import_react9.useState)(null);
|
|
898
|
+
const fetchStatus = (0, import_react9.useCallback)(async () => {
|
|
787
899
|
setLoading(true);
|
|
788
900
|
setError(null);
|
|
789
901
|
try {
|
|
@@ -795,11 +907,25 @@ function usePaymentStatus() {
|
|
|
795
907
|
setLoading(false);
|
|
796
908
|
}
|
|
797
909
|
}, [client]);
|
|
910
|
+
const currency = status?.currency ?? null;
|
|
911
|
+
const formatPrice = (0, import_react9.useCallback)((amount) => {
|
|
912
|
+
const curr = currency ?? DEFAULT_CURRENCY2;
|
|
913
|
+
const formatted = amount.toLocaleString(void 0, {
|
|
914
|
+
minimumFractionDigits: curr.decimals,
|
|
915
|
+
maximumFractionDigits: curr.decimals
|
|
916
|
+
});
|
|
917
|
+
if (curr.position === "after") {
|
|
918
|
+
return `${formatted}${curr.symbol}`;
|
|
919
|
+
}
|
|
920
|
+
return `${curr.symbol}${formatted}`;
|
|
921
|
+
}, [currency]);
|
|
798
922
|
return {
|
|
799
923
|
status,
|
|
800
924
|
loading,
|
|
801
925
|
error,
|
|
802
926
|
refresh: fetchStatus,
|
|
927
|
+
currency,
|
|
928
|
+
formatPrice,
|
|
803
929
|
isTossAvailable: status?.toss?.available ?? false,
|
|
804
930
|
isStripeAvailable: status?.stripe?.available ?? false,
|
|
805
931
|
stripePublishableKey: status?.stripe?.publishable_key ?? null
|
|
@@ -807,9 +933,9 @@ function usePaymentStatus() {
|
|
|
807
933
|
}
|
|
808
934
|
function useTossPayment() {
|
|
809
935
|
const client = useClient();
|
|
810
|
-
const [loading, setLoading] = (0,
|
|
811
|
-
const [error, setError] = (0,
|
|
812
|
-
const preparePayment = (0,
|
|
936
|
+
const [loading, setLoading] = (0, import_react9.useState)(false);
|
|
937
|
+
const [error, setError] = (0, import_react9.useState)(null);
|
|
938
|
+
const preparePayment = (0, import_react9.useCallback)(async (orderNumber, successUrl, failUrl) => {
|
|
813
939
|
setLoading(true);
|
|
814
940
|
setError(null);
|
|
815
941
|
try {
|
|
@@ -826,7 +952,7 @@ function useTossPayment() {
|
|
|
826
952
|
setLoading(false);
|
|
827
953
|
}
|
|
828
954
|
}, [client]);
|
|
829
|
-
const confirmPayment = (0,
|
|
955
|
+
const confirmPayment = (0, import_react9.useCallback)(async (paymentKey, orderId, amount) => {
|
|
830
956
|
setLoading(true);
|
|
831
957
|
setError(null);
|
|
832
958
|
try {
|
|
@@ -843,7 +969,7 @@ function useTossPayment() {
|
|
|
843
969
|
setLoading(false);
|
|
844
970
|
}
|
|
845
971
|
}, [client]);
|
|
846
|
-
const cancelPayment = (0,
|
|
972
|
+
const cancelPayment = (0, import_react9.useCallback)(async (orderNumber, reason, amount) => {
|
|
847
973
|
setLoading(true);
|
|
848
974
|
setError(null);
|
|
849
975
|
try {
|
|
@@ -866,9 +992,9 @@ function useTossPayment() {
|
|
|
866
992
|
}
|
|
867
993
|
function useStripePayment() {
|
|
868
994
|
const client = useClient();
|
|
869
|
-
const [loading, setLoading] = (0,
|
|
870
|
-
const [error, setError] = (0,
|
|
871
|
-
const createCheckout = (0,
|
|
995
|
+
const [loading, setLoading] = (0, import_react9.useState)(false);
|
|
996
|
+
const [error, setError] = (0, import_react9.useState)(null);
|
|
997
|
+
const createCheckout = (0, import_react9.useCallback)(async (orderNumber, successUrl, cancelUrl) => {
|
|
872
998
|
setLoading(true);
|
|
873
999
|
setError(null);
|
|
874
1000
|
try {
|
|
@@ -885,7 +1011,7 @@ function useStripePayment() {
|
|
|
885
1011
|
setLoading(false);
|
|
886
1012
|
}
|
|
887
1013
|
}, [client]);
|
|
888
|
-
const verifyPayment = (0,
|
|
1014
|
+
const verifyPayment = (0, import_react9.useCallback)(async (sessionId) => {
|
|
889
1015
|
setLoading(true);
|
|
890
1016
|
setError(null);
|
|
891
1017
|
try {
|
|
@@ -898,7 +1024,7 @@ function useStripePayment() {
|
|
|
898
1024
|
setLoading(false);
|
|
899
1025
|
}
|
|
900
1026
|
}, [client]);
|
|
901
|
-
const refund = (0,
|
|
1027
|
+
const refund = (0, import_react9.useCallback)(async (orderNumber, reason, amount) => {
|
|
902
1028
|
setLoading(true);
|
|
903
1029
|
setError(null);
|
|
904
1030
|
try {
|
|
@@ -921,13 +1047,13 @@ function useStripePayment() {
|
|
|
921
1047
|
}
|
|
922
1048
|
|
|
923
1049
|
// src/hooks/useCoupons.ts
|
|
924
|
-
var
|
|
1050
|
+
var import_react10 = require("react");
|
|
925
1051
|
function useCoupons() {
|
|
926
1052
|
const client = useClient();
|
|
927
|
-
const [coupons, setCoupons] = (0,
|
|
928
|
-
const [loading, setLoading] = (0,
|
|
929
|
-
const [error, setError] = (0,
|
|
930
|
-
const fetchCoupons = (0,
|
|
1053
|
+
const [coupons, setCoupons] = (0, import_react10.useState)([]);
|
|
1054
|
+
const [loading, setLoading] = (0, import_react10.useState)(true);
|
|
1055
|
+
const [error, setError] = (0, import_react10.useState)(null);
|
|
1056
|
+
const fetchCoupons = (0, import_react10.useCallback)(async () => {
|
|
931
1057
|
if (!client.isAuthenticated()) {
|
|
932
1058
|
setCoupons([]);
|
|
933
1059
|
setLoading(false);
|
|
@@ -944,7 +1070,7 @@ function useCoupons() {
|
|
|
944
1070
|
setLoading(false);
|
|
945
1071
|
}
|
|
946
1072
|
}, [client]);
|
|
947
|
-
(0,
|
|
1073
|
+
(0, import_react10.useEffect)(() => {
|
|
948
1074
|
fetchCoupons();
|
|
949
1075
|
}, [fetchCoupons]);
|
|
950
1076
|
return {
|
|
@@ -956,10 +1082,10 @@ function useCoupons() {
|
|
|
956
1082
|
}
|
|
957
1083
|
function useValidateCoupon() {
|
|
958
1084
|
const client = useClient();
|
|
959
|
-
const [validation, setValidation] = (0,
|
|
960
|
-
const [loading, setLoading] = (0,
|
|
961
|
-
const [error, setError] = (0,
|
|
962
|
-
const validate = (0,
|
|
1085
|
+
const [validation, setValidation] = (0, import_react10.useState)(null);
|
|
1086
|
+
const [loading, setLoading] = (0, import_react10.useState)(false);
|
|
1087
|
+
const [error, setError] = (0, import_react10.useState)(null);
|
|
1088
|
+
const validate = (0, import_react10.useCallback)(async (code, orderAmount) => {
|
|
963
1089
|
setLoading(true);
|
|
964
1090
|
setError(null);
|
|
965
1091
|
try {
|
|
@@ -975,7 +1101,7 @@ function useValidateCoupon() {
|
|
|
975
1101
|
setLoading(false);
|
|
976
1102
|
}
|
|
977
1103
|
}, [client]);
|
|
978
|
-
const reset = (0,
|
|
1104
|
+
const reset = (0, import_react10.useCallback)(() => {
|
|
979
1105
|
setValidation(null);
|
|
980
1106
|
setError(null);
|
|
981
1107
|
}, []);
|
|
@@ -989,13 +1115,13 @@ function useValidateCoupon() {
|
|
|
989
1115
|
}
|
|
990
1116
|
|
|
991
1117
|
// src/hooks/useSubscriptions.ts
|
|
992
|
-
var
|
|
1118
|
+
var import_react11 = require("react");
|
|
993
1119
|
function useSubscriptions() {
|
|
994
1120
|
const client = useClient();
|
|
995
|
-
const [subscriptions, setSubscriptions] = (0,
|
|
996
|
-
const [loading, setLoading] = (0,
|
|
997
|
-
const [error, setError] = (0,
|
|
998
|
-
const fetchSubscriptions = (0,
|
|
1121
|
+
const [subscriptions, setSubscriptions] = (0, import_react11.useState)([]);
|
|
1122
|
+
const [loading, setLoading] = (0, import_react11.useState)(true);
|
|
1123
|
+
const [error, setError] = (0, import_react11.useState)(null);
|
|
1124
|
+
const fetchSubscriptions = (0, import_react11.useCallback)(async () => {
|
|
999
1125
|
if (!client.isAuthenticated()) {
|
|
1000
1126
|
setSubscriptions([]);
|
|
1001
1127
|
setLoading(false);
|
|
@@ -1012,7 +1138,7 @@ function useSubscriptions() {
|
|
|
1012
1138
|
setLoading(false);
|
|
1013
1139
|
}
|
|
1014
1140
|
}, [client]);
|
|
1015
|
-
(0,
|
|
1141
|
+
(0, import_react11.useEffect)(() => {
|
|
1016
1142
|
fetchSubscriptions();
|
|
1017
1143
|
}, [fetchSubscriptions]);
|
|
1018
1144
|
const activeSubscription = subscriptions.find((s) => s.is_active) ?? null;
|
|
@@ -1028,10 +1154,10 @@ function useSubscriptions() {
|
|
|
1028
1154
|
}
|
|
1029
1155
|
function useSubscription(id) {
|
|
1030
1156
|
const client = useClient();
|
|
1031
|
-
const [subscription, setSubscription] = (0,
|
|
1032
|
-
const [loading, setLoading] = (0,
|
|
1033
|
-
const [error, setError] = (0,
|
|
1034
|
-
const fetchSubscription = (0,
|
|
1157
|
+
const [subscription, setSubscription] = (0, import_react11.useState)(null);
|
|
1158
|
+
const [loading, setLoading] = (0, import_react11.useState)(true);
|
|
1159
|
+
const [error, setError] = (0, import_react11.useState)(null);
|
|
1160
|
+
const fetchSubscription = (0, import_react11.useCallback)(async () => {
|
|
1035
1161
|
setLoading(true);
|
|
1036
1162
|
setError(null);
|
|
1037
1163
|
try {
|
|
@@ -1043,20 +1169,20 @@ function useSubscription(id) {
|
|
|
1043
1169
|
setLoading(false);
|
|
1044
1170
|
}
|
|
1045
1171
|
}, [client, id]);
|
|
1046
|
-
(0,
|
|
1172
|
+
(0, import_react11.useEffect)(() => {
|
|
1047
1173
|
fetchSubscription();
|
|
1048
1174
|
}, [fetchSubscription]);
|
|
1049
|
-
const cancel = (0,
|
|
1175
|
+
const cancel = (0, import_react11.useCallback)(async (immediately = false) => {
|
|
1050
1176
|
const updated = await client.shop.cancelSubscription(id, immediately);
|
|
1051
1177
|
setSubscription(updated);
|
|
1052
1178
|
return updated;
|
|
1053
1179
|
}, [client, id]);
|
|
1054
|
-
const pause = (0,
|
|
1180
|
+
const pause = (0, import_react11.useCallback)(async () => {
|
|
1055
1181
|
const updated = await client.shop.pauseSubscription(id);
|
|
1056
1182
|
setSubscription(updated);
|
|
1057
1183
|
return updated;
|
|
1058
1184
|
}, [client, id]);
|
|
1059
|
-
const resume = (0,
|
|
1185
|
+
const resume = (0, import_react11.useCallback)(async () => {
|
|
1060
1186
|
const updated = await client.shop.resumeSubscription(id);
|
|
1061
1187
|
setSubscription(updated);
|
|
1062
1188
|
return updated;
|
|
@@ -1073,9 +1199,9 @@ function useSubscription(id) {
|
|
|
1073
1199
|
}
|
|
1074
1200
|
function useCreateSubscription() {
|
|
1075
1201
|
const client = useClient();
|
|
1076
|
-
const [loading, setLoading] = (0,
|
|
1077
|
-
const [error, setError] = (0,
|
|
1078
|
-
const createCheckout = (0,
|
|
1202
|
+
const [loading, setLoading] = (0, import_react11.useState)(false);
|
|
1203
|
+
const [error, setError] = (0, import_react11.useState)(null);
|
|
1204
|
+
const createCheckout = (0, import_react11.useCallback)(async (planId, successUrl, cancelUrl) => {
|
|
1079
1205
|
setLoading(true);
|
|
1080
1206
|
setError(null);
|
|
1081
1207
|
try {
|
|
@@ -1092,7 +1218,7 @@ function useCreateSubscription() {
|
|
|
1092
1218
|
setLoading(false);
|
|
1093
1219
|
}
|
|
1094
1220
|
}, [client]);
|
|
1095
|
-
const verifyCheckout = (0,
|
|
1221
|
+
const verifyCheckout = (0, import_react11.useCallback)(async (sessionId) => {
|
|
1096
1222
|
setLoading(true);
|
|
1097
1223
|
setError(null);
|
|
1098
1224
|
try {
|
|
@@ -1106,7 +1232,7 @@ function useCreateSubscription() {
|
|
|
1106
1232
|
setLoading(false);
|
|
1107
1233
|
}
|
|
1108
1234
|
}, [client]);
|
|
1109
|
-
const createSetupIntent = (0,
|
|
1235
|
+
const createSetupIntent = (0, import_react11.useCallback)(async () => {
|
|
1110
1236
|
setLoading(true);
|
|
1111
1237
|
setError(null);
|
|
1112
1238
|
try {
|
|
@@ -1130,13 +1256,13 @@ function useCreateSubscription() {
|
|
|
1130
1256
|
}
|
|
1131
1257
|
|
|
1132
1258
|
// src/hooks/useDownloads.ts
|
|
1133
|
-
var
|
|
1259
|
+
var import_react12 = require("react");
|
|
1134
1260
|
function useDownloads() {
|
|
1135
1261
|
const client = useClient();
|
|
1136
|
-
const [downloads, setDownloads] = (0,
|
|
1137
|
-
const [loading, setLoading] = (0,
|
|
1138
|
-
const [error, setError] = (0,
|
|
1139
|
-
const fetchDownloads = (0,
|
|
1262
|
+
const [downloads, setDownloads] = (0, import_react12.useState)([]);
|
|
1263
|
+
const [loading, setLoading] = (0, import_react12.useState)(true);
|
|
1264
|
+
const [error, setError] = (0, import_react12.useState)(null);
|
|
1265
|
+
const fetchDownloads = (0, import_react12.useCallback)(async () => {
|
|
1140
1266
|
if (!client.isAuthenticated()) {
|
|
1141
1267
|
setDownloads([]);
|
|
1142
1268
|
setLoading(false);
|
|
@@ -1153,13 +1279,13 @@ function useDownloads() {
|
|
|
1153
1279
|
setLoading(false);
|
|
1154
1280
|
}
|
|
1155
1281
|
}, [client]);
|
|
1156
|
-
(0,
|
|
1282
|
+
(0, import_react12.useEffect)(() => {
|
|
1157
1283
|
fetchDownloads();
|
|
1158
1284
|
}, [fetchDownloads]);
|
|
1159
|
-
const getDownloadUrl = (0,
|
|
1285
|
+
const getDownloadUrl = (0, import_react12.useCallback)((token) => {
|
|
1160
1286
|
return client.shop.getDownloadUrl(token);
|
|
1161
1287
|
}, [client]);
|
|
1162
|
-
const getDownloadInfo = (0,
|
|
1288
|
+
const getDownloadInfo = (0, import_react12.useCallback)(async (token) => {
|
|
1163
1289
|
return await client.shop.getDownloadInfo(token);
|
|
1164
1290
|
}, [client]);
|
|
1165
1291
|
return {
|
|
@@ -1173,10 +1299,10 @@ function useDownloads() {
|
|
|
1173
1299
|
}
|
|
1174
1300
|
function useOrderDownloads(orderNumber) {
|
|
1175
1301
|
const client = useClient();
|
|
1176
|
-
const [downloads, setDownloads] = (0,
|
|
1177
|
-
const [loading, setLoading] = (0,
|
|
1178
|
-
const [error, setError] = (0,
|
|
1179
|
-
const fetchDownloads = (0,
|
|
1302
|
+
const [downloads, setDownloads] = (0, import_react12.useState)([]);
|
|
1303
|
+
const [loading, setLoading] = (0, import_react12.useState)(true);
|
|
1304
|
+
const [error, setError] = (0, import_react12.useState)(null);
|
|
1305
|
+
const fetchDownloads = (0, import_react12.useCallback)(async () => {
|
|
1180
1306
|
if (!client.isAuthenticated()) {
|
|
1181
1307
|
setDownloads([]);
|
|
1182
1308
|
setLoading(false);
|
|
@@ -1193,13 +1319,13 @@ function useOrderDownloads(orderNumber) {
|
|
|
1193
1319
|
setLoading(false);
|
|
1194
1320
|
}
|
|
1195
1321
|
}, [client, orderNumber]);
|
|
1196
|
-
(0,
|
|
1322
|
+
(0, import_react12.useEffect)(() => {
|
|
1197
1323
|
fetchDownloads();
|
|
1198
1324
|
}, [fetchDownloads]);
|
|
1199
|
-
const getDownloadUrl = (0,
|
|
1325
|
+
const getDownloadUrl = (0, import_react12.useCallback)((token) => {
|
|
1200
1326
|
return client.shop.getDownloadUrl(token);
|
|
1201
1327
|
}, [client]);
|
|
1202
|
-
const getDownloadInfo = (0,
|
|
1328
|
+
const getDownloadInfo = (0, import_react12.useCallback)(async (token) => {
|
|
1203
1329
|
return await client.shop.getDownloadInfo(token);
|
|
1204
1330
|
}, [client]);
|
|
1205
1331
|
return {
|
|
@@ -1213,15 +1339,15 @@ function useOrderDownloads(orderNumber) {
|
|
|
1213
1339
|
}
|
|
1214
1340
|
|
|
1215
1341
|
// src/hooks/useReviews.ts
|
|
1216
|
-
var
|
|
1342
|
+
var import_react13 = require("react");
|
|
1217
1343
|
function useProductReviews(productSlug, params) {
|
|
1218
1344
|
const client = useClient();
|
|
1219
|
-
const [reviews, setReviews] = (0,
|
|
1220
|
-
const [stats, setStats] = (0,
|
|
1221
|
-
const [meta, setMeta] = (0,
|
|
1222
|
-
const [loading, setLoading] = (0,
|
|
1223
|
-
const [error, setError] = (0,
|
|
1224
|
-
const fetchReviews = (0,
|
|
1345
|
+
const [reviews, setReviews] = (0, import_react13.useState)([]);
|
|
1346
|
+
const [stats, setStats] = (0, import_react13.useState)(null);
|
|
1347
|
+
const [meta, setMeta] = (0, import_react13.useState)(null);
|
|
1348
|
+
const [loading, setLoading] = (0, import_react13.useState)(true);
|
|
1349
|
+
const [error, setError] = (0, import_react13.useState)(null);
|
|
1350
|
+
const fetchReviews = (0, import_react13.useCallback)(async () => {
|
|
1225
1351
|
setLoading(true);
|
|
1226
1352
|
setError(null);
|
|
1227
1353
|
try {
|
|
@@ -1235,7 +1361,7 @@ function useProductReviews(productSlug, params) {
|
|
|
1235
1361
|
setLoading(false);
|
|
1236
1362
|
}
|
|
1237
1363
|
}, [client, productSlug, params]);
|
|
1238
|
-
(0,
|
|
1364
|
+
(0, import_react13.useEffect)(() => {
|
|
1239
1365
|
fetchReviews();
|
|
1240
1366
|
}, [fetchReviews]);
|
|
1241
1367
|
return {
|
|
@@ -1249,11 +1375,11 @@ function useProductReviews(productSlug, params) {
|
|
|
1249
1375
|
}
|
|
1250
1376
|
function useCanReview(productSlug) {
|
|
1251
1377
|
const client = useClient();
|
|
1252
|
-
const [canReview, setCanReview] = (0,
|
|
1253
|
-
const [reason, setReason] = (0,
|
|
1254
|
-
const [loading, setLoading] = (0,
|
|
1255
|
-
const [error, setError] = (0,
|
|
1256
|
-
const check = (0,
|
|
1378
|
+
const [canReview, setCanReview] = (0, import_react13.useState)(false);
|
|
1379
|
+
const [reason, setReason] = (0, import_react13.useState)(null);
|
|
1380
|
+
const [loading, setLoading] = (0, import_react13.useState)(true);
|
|
1381
|
+
const [error, setError] = (0, import_react13.useState)(null);
|
|
1382
|
+
const check = (0, import_react13.useCallback)(async () => {
|
|
1257
1383
|
setLoading(true);
|
|
1258
1384
|
setError(null);
|
|
1259
1385
|
try {
|
|
@@ -1268,7 +1394,7 @@ function useCanReview(productSlug) {
|
|
|
1268
1394
|
setLoading(false);
|
|
1269
1395
|
}
|
|
1270
1396
|
}, [client, productSlug]);
|
|
1271
|
-
(0,
|
|
1397
|
+
(0, import_react13.useEffect)(() => {
|
|
1272
1398
|
if (client.isAuthenticated()) {
|
|
1273
1399
|
check();
|
|
1274
1400
|
} else {
|
|
@@ -1287,9 +1413,9 @@ function useCanReview(productSlug) {
|
|
|
1287
1413
|
}
|
|
1288
1414
|
function useCreateReview() {
|
|
1289
1415
|
const client = useClient();
|
|
1290
|
-
const [loading, setLoading] = (0,
|
|
1291
|
-
const [error, setError] = (0,
|
|
1292
|
-
const createReview = (0,
|
|
1416
|
+
const [loading, setLoading] = (0, import_react13.useState)(false);
|
|
1417
|
+
const [error, setError] = (0, import_react13.useState)(null);
|
|
1418
|
+
const createReview = (0, import_react13.useCallback)(async (productSlug, data) => {
|
|
1293
1419
|
setLoading(true);
|
|
1294
1420
|
setError(null);
|
|
1295
1421
|
try {
|
|
@@ -1310,11 +1436,11 @@ function useCreateReview() {
|
|
|
1310
1436
|
}
|
|
1311
1437
|
function useMyReviews(params) {
|
|
1312
1438
|
const client = useClient();
|
|
1313
|
-
const [reviews, setReviews] = (0,
|
|
1314
|
-
const [meta, setMeta] = (0,
|
|
1315
|
-
const [loading, setLoading] = (0,
|
|
1316
|
-
const [error, setError] = (0,
|
|
1317
|
-
const fetchReviews = (0,
|
|
1439
|
+
const [reviews, setReviews] = (0, import_react13.useState)([]);
|
|
1440
|
+
const [meta, setMeta] = (0, import_react13.useState)(null);
|
|
1441
|
+
const [loading, setLoading] = (0, import_react13.useState)(true);
|
|
1442
|
+
const [error, setError] = (0, import_react13.useState)(null);
|
|
1443
|
+
const fetchReviews = (0, import_react13.useCallback)(async () => {
|
|
1318
1444
|
if (!client.isAuthenticated()) {
|
|
1319
1445
|
setReviews([]);
|
|
1320
1446
|
setLoading(false);
|
|
@@ -1332,14 +1458,14 @@ function useMyReviews(params) {
|
|
|
1332
1458
|
setLoading(false);
|
|
1333
1459
|
}
|
|
1334
1460
|
}, [client, params]);
|
|
1335
|
-
(0,
|
|
1461
|
+
(0, import_react13.useEffect)(() => {
|
|
1336
1462
|
fetchReviews();
|
|
1337
1463
|
}, [fetchReviews]);
|
|
1338
|
-
const deleteReview = (0,
|
|
1464
|
+
const deleteReview = (0, import_react13.useCallback)(async (reviewId) => {
|
|
1339
1465
|
await client.shop.deleteReview(reviewId);
|
|
1340
1466
|
setReviews((prev) => prev.filter((r) => r.id !== reviewId));
|
|
1341
1467
|
}, [client]);
|
|
1342
|
-
const updateReview = (0,
|
|
1468
|
+
const updateReview = (0, import_react13.useCallback)(async (reviewId, data) => {
|
|
1343
1469
|
const updated = await client.shop.updateReview(reviewId, data);
|
|
1344
1470
|
setReviews((prev) => prev.map((r) => r.id === reviewId ? updated : r));
|
|
1345
1471
|
return updated;
|
|
@@ -1356,16 +1482,16 @@ function useMyReviews(params) {
|
|
|
1356
1482
|
}
|
|
1357
1483
|
|
|
1358
1484
|
// src/hooks/useBlog.ts
|
|
1359
|
-
var
|
|
1485
|
+
var import_react14 = require("react");
|
|
1360
1486
|
function useBlog(options = {}) {
|
|
1361
1487
|
const { autoFetch = true, ...params } = options;
|
|
1362
1488
|
const client = useClient();
|
|
1363
|
-
const [posts, setPosts] = (0,
|
|
1364
|
-
const [meta, setMeta] = (0,
|
|
1365
|
-
const [loading, setLoading] = (0,
|
|
1366
|
-
const [error, setError] = (0,
|
|
1367
|
-
const [currentParams, setCurrentParams] = (0,
|
|
1368
|
-
const fetchPosts = (0,
|
|
1489
|
+
const [posts, setPosts] = (0, import_react14.useState)([]);
|
|
1490
|
+
const [meta, setMeta] = (0, import_react14.useState)(null);
|
|
1491
|
+
const [loading, setLoading] = (0, import_react14.useState)(autoFetch);
|
|
1492
|
+
const [error, setError] = (0, import_react14.useState)(null);
|
|
1493
|
+
const [currentParams, setCurrentParams] = (0, import_react14.useState)(params);
|
|
1494
|
+
const fetchPosts = (0, import_react14.useCallback)(async (fetchParams, append = false) => {
|
|
1369
1495
|
setLoading(true);
|
|
1370
1496
|
setError(null);
|
|
1371
1497
|
try {
|
|
@@ -1382,18 +1508,18 @@ function useBlog(options = {}) {
|
|
|
1382
1508
|
setLoading(false);
|
|
1383
1509
|
}
|
|
1384
1510
|
}, [client]);
|
|
1385
|
-
(0,
|
|
1511
|
+
(0, import_react14.useEffect)(() => {
|
|
1386
1512
|
if (autoFetch) {
|
|
1387
1513
|
fetchPosts(params);
|
|
1388
1514
|
}
|
|
1389
1515
|
}, []);
|
|
1390
1516
|
const hasMore = meta ? meta.current_page < meta.last_page : false;
|
|
1391
|
-
const loadMore = (0,
|
|
1517
|
+
const loadMore = (0, import_react14.useCallback)(async () => {
|
|
1392
1518
|
if (!hasMore || loading) return;
|
|
1393
1519
|
const nextPage = (meta?.current_page ?? 0) + 1;
|
|
1394
1520
|
await fetchPosts({ ...currentParams, page: nextPage }, true);
|
|
1395
1521
|
}, [hasMore, loading, meta, currentParams, fetchPosts]);
|
|
1396
|
-
const refresh = (0,
|
|
1522
|
+
const refresh = (0, import_react14.useCallback)(async () => {
|
|
1397
1523
|
setCurrentParams(params);
|
|
1398
1524
|
await fetchPosts(params);
|
|
1399
1525
|
}, [params, fetchPosts]);
|
|
@@ -1409,10 +1535,10 @@ function useBlog(options = {}) {
|
|
|
1409
1535
|
}
|
|
1410
1536
|
function useBlogPost(slug) {
|
|
1411
1537
|
const client = useClient();
|
|
1412
|
-
const [post, setPost] = (0,
|
|
1413
|
-
const [loading, setLoading] = (0,
|
|
1414
|
-
const [error, setError] = (0,
|
|
1415
|
-
const fetchPost = (0,
|
|
1538
|
+
const [post, setPost] = (0, import_react14.useState)(null);
|
|
1539
|
+
const [loading, setLoading] = (0, import_react14.useState)(true);
|
|
1540
|
+
const [error, setError] = (0, import_react14.useState)(null);
|
|
1541
|
+
const fetchPost = (0, import_react14.useCallback)(async () => {
|
|
1416
1542
|
setLoading(true);
|
|
1417
1543
|
setError(null);
|
|
1418
1544
|
try {
|
|
@@ -1424,7 +1550,7 @@ function useBlogPost(slug) {
|
|
|
1424
1550
|
setLoading(false);
|
|
1425
1551
|
}
|
|
1426
1552
|
}, [client, slug]);
|
|
1427
|
-
(0,
|
|
1553
|
+
(0, import_react14.useEffect)(() => {
|
|
1428
1554
|
fetchPost();
|
|
1429
1555
|
}, [fetchPost]);
|
|
1430
1556
|
return {
|
|
@@ -1436,10 +1562,10 @@ function useBlogPost(slug) {
|
|
|
1436
1562
|
}
|
|
1437
1563
|
function useBlogCategories() {
|
|
1438
1564
|
const client = useClient();
|
|
1439
|
-
const [categories, setCategories] = (0,
|
|
1440
|
-
const [loading, setLoading] = (0,
|
|
1441
|
-
const [error, setError] = (0,
|
|
1442
|
-
const fetchCategories = (0,
|
|
1565
|
+
const [categories, setCategories] = (0, import_react14.useState)([]);
|
|
1566
|
+
const [loading, setLoading] = (0, import_react14.useState)(true);
|
|
1567
|
+
const [error, setError] = (0, import_react14.useState)(null);
|
|
1568
|
+
const fetchCategories = (0, import_react14.useCallback)(async () => {
|
|
1443
1569
|
setLoading(true);
|
|
1444
1570
|
setError(null);
|
|
1445
1571
|
try {
|
|
@@ -1451,7 +1577,7 @@ function useBlogCategories() {
|
|
|
1451
1577
|
setLoading(false);
|
|
1452
1578
|
}
|
|
1453
1579
|
}, [client]);
|
|
1454
|
-
(0,
|
|
1580
|
+
(0, import_react14.useEffect)(() => {
|
|
1455
1581
|
fetchCategories();
|
|
1456
1582
|
}, [fetchCategories]);
|
|
1457
1583
|
return {
|
|
@@ -1463,10 +1589,10 @@ function useBlogCategories() {
|
|
|
1463
1589
|
}
|
|
1464
1590
|
function useBlogTags() {
|
|
1465
1591
|
const client = useClient();
|
|
1466
|
-
const [tags, setTags] = (0,
|
|
1467
|
-
const [loading, setLoading] = (0,
|
|
1468
|
-
const [error, setError] = (0,
|
|
1469
|
-
const fetchTags = (0,
|
|
1592
|
+
const [tags, setTags] = (0, import_react14.useState)([]);
|
|
1593
|
+
const [loading, setLoading] = (0, import_react14.useState)(true);
|
|
1594
|
+
const [error, setError] = (0, import_react14.useState)(null);
|
|
1595
|
+
const fetchTags = (0, import_react14.useCallback)(async () => {
|
|
1470
1596
|
setLoading(true);
|
|
1471
1597
|
setError(null);
|
|
1472
1598
|
try {
|
|
@@ -1478,7 +1604,7 @@ function useBlogTags() {
|
|
|
1478
1604
|
setLoading(false);
|
|
1479
1605
|
}
|
|
1480
1606
|
}, [client]);
|
|
1481
|
-
(0,
|
|
1607
|
+
(0, import_react14.useEffect)(() => {
|
|
1482
1608
|
fetchTags();
|
|
1483
1609
|
}, [fetchTags]);
|
|
1484
1610
|
return {
|
|
@@ -1490,10 +1616,10 @@ function useBlogTags() {
|
|
|
1490
1616
|
}
|
|
1491
1617
|
function useFeaturedBlog(limit = 5) {
|
|
1492
1618
|
const client = useClient();
|
|
1493
|
-
const [posts, setPosts] = (0,
|
|
1494
|
-
const [loading, setLoading] = (0,
|
|
1495
|
-
const [error, setError] = (0,
|
|
1496
|
-
const fetchPosts = (0,
|
|
1619
|
+
const [posts, setPosts] = (0, import_react14.useState)([]);
|
|
1620
|
+
const [loading, setLoading] = (0, import_react14.useState)(true);
|
|
1621
|
+
const [error, setError] = (0, import_react14.useState)(null);
|
|
1622
|
+
const fetchPosts = (0, import_react14.useCallback)(async () => {
|
|
1497
1623
|
setLoading(true);
|
|
1498
1624
|
setError(null);
|
|
1499
1625
|
try {
|
|
@@ -1505,7 +1631,7 @@ function useFeaturedBlog(limit = 5) {
|
|
|
1505
1631
|
setLoading(false);
|
|
1506
1632
|
}
|
|
1507
1633
|
}, [client, limit]);
|
|
1508
|
-
(0,
|
|
1634
|
+
(0, import_react14.useEffect)(() => {
|
|
1509
1635
|
fetchPosts();
|
|
1510
1636
|
}, [fetchPosts]);
|
|
1511
1637
|
return {
|
|
@@ -1517,11 +1643,11 @@ function useFeaturedBlog(limit = 5) {
|
|
|
1517
1643
|
}
|
|
1518
1644
|
function useBlogSearch() {
|
|
1519
1645
|
const client = useClient();
|
|
1520
|
-
const [posts, setPosts] = (0,
|
|
1521
|
-
const [meta, setMeta] = (0,
|
|
1522
|
-
const [loading, setLoading] = (0,
|
|
1523
|
-
const [error, setError] = (0,
|
|
1524
|
-
const search = (0,
|
|
1646
|
+
const [posts, setPosts] = (0, import_react14.useState)([]);
|
|
1647
|
+
const [meta, setMeta] = (0, import_react14.useState)(null);
|
|
1648
|
+
const [loading, setLoading] = (0, import_react14.useState)(false);
|
|
1649
|
+
const [error, setError] = (0, import_react14.useState)(null);
|
|
1650
|
+
const search = (0, import_react14.useCallback)(async (query) => {
|
|
1525
1651
|
setLoading(true);
|
|
1526
1652
|
setError(null);
|
|
1527
1653
|
try {
|
|
@@ -1544,13 +1670,13 @@ function useBlogSearch() {
|
|
|
1544
1670
|
}
|
|
1545
1671
|
|
|
1546
1672
|
// src/hooks/useBoards.ts
|
|
1547
|
-
var
|
|
1673
|
+
var import_react15 = require("react");
|
|
1548
1674
|
function useBoards(params) {
|
|
1549
1675
|
const client = useClient();
|
|
1550
|
-
const [boards, setBoards] = (0,
|
|
1551
|
-
const [loading, setLoading] = (0,
|
|
1552
|
-
const [error, setError] = (0,
|
|
1553
|
-
const fetchBoards = (0,
|
|
1676
|
+
const [boards, setBoards] = (0, import_react15.useState)([]);
|
|
1677
|
+
const [loading, setLoading] = (0, import_react15.useState)(true);
|
|
1678
|
+
const [error, setError] = (0, import_react15.useState)(null);
|
|
1679
|
+
const fetchBoards = (0, import_react15.useCallback)(async () => {
|
|
1554
1680
|
setLoading(true);
|
|
1555
1681
|
setError(null);
|
|
1556
1682
|
try {
|
|
@@ -1562,7 +1688,7 @@ function useBoards(params) {
|
|
|
1562
1688
|
setLoading(false);
|
|
1563
1689
|
}
|
|
1564
1690
|
}, [client, params]);
|
|
1565
|
-
(0,
|
|
1691
|
+
(0, import_react15.useEffect)(() => {
|
|
1566
1692
|
fetchBoards();
|
|
1567
1693
|
}, [fetchBoards]);
|
|
1568
1694
|
return {
|
|
@@ -1574,10 +1700,10 @@ function useBoards(params) {
|
|
|
1574
1700
|
}
|
|
1575
1701
|
function useBoard(slug) {
|
|
1576
1702
|
const client = useClient();
|
|
1577
|
-
const [board, setBoard] = (0,
|
|
1578
|
-
const [loading, setLoading] = (0,
|
|
1579
|
-
const [error, setError] = (0,
|
|
1580
|
-
const fetchBoard = (0,
|
|
1703
|
+
const [board, setBoard] = (0, import_react15.useState)(null);
|
|
1704
|
+
const [loading, setLoading] = (0, import_react15.useState)(true);
|
|
1705
|
+
const [error, setError] = (0, import_react15.useState)(null);
|
|
1706
|
+
const fetchBoard = (0, import_react15.useCallback)(async () => {
|
|
1581
1707
|
setLoading(true);
|
|
1582
1708
|
setError(null);
|
|
1583
1709
|
try {
|
|
@@ -1589,7 +1715,7 @@ function useBoard(slug) {
|
|
|
1589
1715
|
setLoading(false);
|
|
1590
1716
|
}
|
|
1591
1717
|
}, [client, slug]);
|
|
1592
|
-
(0,
|
|
1718
|
+
(0, import_react15.useEffect)(() => {
|
|
1593
1719
|
fetchBoard();
|
|
1594
1720
|
}, [fetchBoard]);
|
|
1595
1721
|
return {
|
|
@@ -1601,12 +1727,12 @@ function useBoard(slug) {
|
|
|
1601
1727
|
}
|
|
1602
1728
|
function useBoardPosts(boardSlug, params) {
|
|
1603
1729
|
const client = useClient();
|
|
1604
|
-
const [posts, setPosts] = (0,
|
|
1605
|
-
const [meta, setMeta] = (0,
|
|
1606
|
-
const [loading, setLoading] = (0,
|
|
1607
|
-
const [error, setError] = (0,
|
|
1608
|
-
const [currentParams, setCurrentParams] = (0,
|
|
1609
|
-
const fetchPosts = (0,
|
|
1730
|
+
const [posts, setPosts] = (0, import_react15.useState)([]);
|
|
1731
|
+
const [meta, setMeta] = (0, import_react15.useState)(null);
|
|
1732
|
+
const [loading, setLoading] = (0, import_react15.useState)(true);
|
|
1733
|
+
const [error, setError] = (0, import_react15.useState)(null);
|
|
1734
|
+
const [currentParams, setCurrentParams] = (0, import_react15.useState)(params);
|
|
1735
|
+
const fetchPosts = (0, import_react15.useCallback)(async (fetchParams, append = false) => {
|
|
1610
1736
|
setLoading(true);
|
|
1611
1737
|
setError(null);
|
|
1612
1738
|
try {
|
|
@@ -1623,16 +1749,16 @@ function useBoardPosts(boardSlug, params) {
|
|
|
1623
1749
|
setLoading(false);
|
|
1624
1750
|
}
|
|
1625
1751
|
}, [client, boardSlug]);
|
|
1626
|
-
(0,
|
|
1752
|
+
(0, import_react15.useEffect)(() => {
|
|
1627
1753
|
fetchPosts(params);
|
|
1628
1754
|
}, []);
|
|
1629
1755
|
const hasMore = meta ? meta.current_page < meta.last_page : false;
|
|
1630
|
-
const loadMore = (0,
|
|
1756
|
+
const loadMore = (0, import_react15.useCallback)(async () => {
|
|
1631
1757
|
if (!hasMore || loading) return;
|
|
1632
1758
|
const nextPage = (meta?.current_page ?? 0) + 1;
|
|
1633
1759
|
await fetchPosts({ ...currentParams, page: nextPage }, true);
|
|
1634
1760
|
}, [hasMore, loading, meta, currentParams, fetchPosts]);
|
|
1635
|
-
const refresh = (0,
|
|
1761
|
+
const refresh = (0, import_react15.useCallback)(async () => {
|
|
1636
1762
|
setCurrentParams(params);
|
|
1637
1763
|
await fetchPosts(params);
|
|
1638
1764
|
}, [params, fetchPosts]);
|
|
@@ -1648,10 +1774,10 @@ function useBoardPosts(boardSlug, params) {
|
|
|
1648
1774
|
}
|
|
1649
1775
|
function useBoardPost(postId) {
|
|
1650
1776
|
const client = useClient();
|
|
1651
|
-
const [post, setPost] = (0,
|
|
1652
|
-
const [loading, setLoading] = (0,
|
|
1653
|
-
const [error, setError] = (0,
|
|
1654
|
-
const fetchPost = (0,
|
|
1777
|
+
const [post, setPost] = (0, import_react15.useState)(null);
|
|
1778
|
+
const [loading, setLoading] = (0, import_react15.useState)(true);
|
|
1779
|
+
const [error, setError] = (0, import_react15.useState)(null);
|
|
1780
|
+
const fetchPost = (0, import_react15.useCallback)(async () => {
|
|
1655
1781
|
setLoading(true);
|
|
1656
1782
|
setError(null);
|
|
1657
1783
|
try {
|
|
@@ -1663,7 +1789,7 @@ function useBoardPost(postId) {
|
|
|
1663
1789
|
setLoading(false);
|
|
1664
1790
|
}
|
|
1665
1791
|
}, [client, postId]);
|
|
1666
|
-
(0,
|
|
1792
|
+
(0, import_react15.useEffect)(() => {
|
|
1667
1793
|
fetchPost();
|
|
1668
1794
|
}, [fetchPost]);
|
|
1669
1795
|
return {
|
|
@@ -1675,9 +1801,9 @@ function useBoardPost(postId) {
|
|
|
1675
1801
|
}
|
|
1676
1802
|
function useCreateBoardPost() {
|
|
1677
1803
|
const client = useClient();
|
|
1678
|
-
const [loading, setLoading] = (0,
|
|
1679
|
-
const [error, setError] = (0,
|
|
1680
|
-
const createPost = (0,
|
|
1804
|
+
const [loading, setLoading] = (0, import_react15.useState)(false);
|
|
1805
|
+
const [error, setError] = (0, import_react15.useState)(null);
|
|
1806
|
+
const createPost = (0, import_react15.useCallback)(async (data) => {
|
|
1681
1807
|
setLoading(true);
|
|
1682
1808
|
setError(null);
|
|
1683
1809
|
try {
|
|
@@ -1698,15 +1824,15 @@ function useCreateBoardPost() {
|
|
|
1698
1824
|
}
|
|
1699
1825
|
|
|
1700
1826
|
// src/hooks/useComments.ts
|
|
1701
|
-
var
|
|
1827
|
+
var import_react16 = require("react");
|
|
1702
1828
|
function useComments(options) {
|
|
1703
1829
|
const { type, target, page, per_page } = options;
|
|
1704
1830
|
const client = useClient();
|
|
1705
|
-
const [comments, setComments] = (0,
|
|
1706
|
-
const [meta, setMeta] = (0,
|
|
1707
|
-
const [loading, setLoading] = (0,
|
|
1708
|
-
const [error, setError] = (0,
|
|
1709
|
-
const fetchComments = (0,
|
|
1831
|
+
const [comments, setComments] = (0, import_react16.useState)([]);
|
|
1832
|
+
const [meta, setMeta] = (0, import_react16.useState)(null);
|
|
1833
|
+
const [loading, setLoading] = (0, import_react16.useState)(true);
|
|
1834
|
+
const [error, setError] = (0, import_react16.useState)(null);
|
|
1835
|
+
const fetchComments = (0, import_react16.useCallback)(async () => {
|
|
1710
1836
|
setLoading(true);
|
|
1711
1837
|
setError(null);
|
|
1712
1838
|
try {
|
|
@@ -1731,10 +1857,10 @@ function useComments(options) {
|
|
|
1731
1857
|
setLoading(false);
|
|
1732
1858
|
}
|
|
1733
1859
|
}, [client, type, target, page, per_page]);
|
|
1734
|
-
(0,
|
|
1860
|
+
(0, import_react16.useEffect)(() => {
|
|
1735
1861
|
fetchComments();
|
|
1736
1862
|
}, [fetchComments]);
|
|
1737
|
-
const createComment = (0,
|
|
1863
|
+
const createComment = (0, import_react16.useCallback)(async (data) => {
|
|
1738
1864
|
let response;
|
|
1739
1865
|
switch (type) {
|
|
1740
1866
|
case "board":
|
|
@@ -1750,16 +1876,16 @@ function useComments(options) {
|
|
|
1750
1876
|
await fetchComments();
|
|
1751
1877
|
return response.data;
|
|
1752
1878
|
}, [client, type, target, fetchComments]);
|
|
1753
|
-
const updateComment = (0,
|
|
1879
|
+
const updateComment = (0, import_react16.useCallback)(async (commentId, content) => {
|
|
1754
1880
|
const response = await client.comments.update(commentId, { content });
|
|
1755
1881
|
setComments((prev) => prev.map((c) => c.id === commentId ? response.data : c));
|
|
1756
1882
|
return response.data;
|
|
1757
1883
|
}, [client]);
|
|
1758
|
-
const deleteComment = (0,
|
|
1884
|
+
const deleteComment = (0, import_react16.useCallback)(async (commentId, password) => {
|
|
1759
1885
|
await client.comments.delete(commentId, password ? { password } : void 0);
|
|
1760
1886
|
setComments((prev) => prev.filter((c) => c.id !== commentId));
|
|
1761
1887
|
}, [client]);
|
|
1762
|
-
const likeComment = (0,
|
|
1888
|
+
const likeComment = (0, import_react16.useCallback)(async (commentId) => {
|
|
1763
1889
|
const response = await client.comments.like(commentId);
|
|
1764
1890
|
setComments((prev) => prev.map(
|
|
1765
1891
|
(c) => c.id === commentId ? { ...c, likes: response.data.likes } : c
|
|
@@ -1780,15 +1906,15 @@ function useComments(options) {
|
|
|
1780
1906
|
}
|
|
1781
1907
|
|
|
1782
1908
|
// src/hooks/useForms.ts
|
|
1783
|
-
var
|
|
1909
|
+
var import_react17 = require("react");
|
|
1784
1910
|
function useForm(formSlug) {
|
|
1785
1911
|
const client = useClient();
|
|
1786
|
-
const [form, setForm] = (0,
|
|
1787
|
-
const [loading, setLoading] = (0,
|
|
1788
|
-
const [error, setError] = (0,
|
|
1789
|
-
const [submitting, setSubmitting] = (0,
|
|
1790
|
-
const [submitted, setSubmitted] = (0,
|
|
1791
|
-
const fetchForm = (0,
|
|
1912
|
+
const [form, setForm] = (0, import_react17.useState)(null);
|
|
1913
|
+
const [loading, setLoading] = (0, import_react17.useState)(true);
|
|
1914
|
+
const [error, setError] = (0, import_react17.useState)(null);
|
|
1915
|
+
const [submitting, setSubmitting] = (0, import_react17.useState)(false);
|
|
1916
|
+
const [submitted, setSubmitted] = (0, import_react17.useState)(false);
|
|
1917
|
+
const fetchForm = (0, import_react17.useCallback)(async () => {
|
|
1792
1918
|
setLoading(true);
|
|
1793
1919
|
setError(null);
|
|
1794
1920
|
try {
|
|
@@ -1800,10 +1926,10 @@ function useForm(formSlug) {
|
|
|
1800
1926
|
setLoading(false);
|
|
1801
1927
|
}
|
|
1802
1928
|
}, [client, formSlug]);
|
|
1803
|
-
(0,
|
|
1929
|
+
(0, import_react17.useEffect)(() => {
|
|
1804
1930
|
fetchForm();
|
|
1805
1931
|
}, [fetchForm]);
|
|
1806
|
-
const submit = (0,
|
|
1932
|
+
const submit = (0, import_react17.useCallback)(async (data) => {
|
|
1807
1933
|
setSubmitting(true);
|
|
1808
1934
|
setError(null);
|
|
1809
1935
|
try {
|
|
@@ -1818,7 +1944,7 @@ function useForm(formSlug) {
|
|
|
1818
1944
|
setSubmitting(false);
|
|
1819
1945
|
}
|
|
1820
1946
|
}, [client, formSlug]);
|
|
1821
|
-
const reset = (0,
|
|
1947
|
+
const reset = (0, import_react17.useCallback)(() => {
|
|
1822
1948
|
setSubmitted(false);
|
|
1823
1949
|
setError(null);
|
|
1824
1950
|
}, []);
|
|
@@ -1834,13 +1960,13 @@ function useForm(formSlug) {
|
|
|
1834
1960
|
}
|
|
1835
1961
|
|
|
1836
1962
|
// src/hooks/useReservation.ts
|
|
1837
|
-
var
|
|
1963
|
+
var import_react18 = require("react");
|
|
1838
1964
|
function useReservationServices() {
|
|
1839
1965
|
const client = useClient();
|
|
1840
|
-
const [services, setServices] = (0,
|
|
1841
|
-
const [loading, setLoading] = (0,
|
|
1842
|
-
const [error, setError] = (0,
|
|
1843
|
-
const fetchServices = (0,
|
|
1966
|
+
const [services, setServices] = (0, import_react18.useState)([]);
|
|
1967
|
+
const [loading, setLoading] = (0, import_react18.useState)(true);
|
|
1968
|
+
const [error, setError] = (0, import_react18.useState)(null);
|
|
1969
|
+
const fetchServices = (0, import_react18.useCallback)(async () => {
|
|
1844
1970
|
setLoading(true);
|
|
1845
1971
|
setError(null);
|
|
1846
1972
|
try {
|
|
@@ -1852,7 +1978,7 @@ function useReservationServices() {
|
|
|
1852
1978
|
setLoading(false);
|
|
1853
1979
|
}
|
|
1854
1980
|
}, [client]);
|
|
1855
|
-
(0,
|
|
1981
|
+
(0, import_react18.useEffect)(() => {
|
|
1856
1982
|
fetchServices();
|
|
1857
1983
|
}, [fetchServices]);
|
|
1858
1984
|
return {
|
|
@@ -1864,10 +1990,10 @@ function useReservationServices() {
|
|
|
1864
1990
|
}
|
|
1865
1991
|
function useReservationStaffs() {
|
|
1866
1992
|
const client = useClient();
|
|
1867
|
-
const [staffs, setStaffs] = (0,
|
|
1868
|
-
const [loading, setLoading] = (0,
|
|
1869
|
-
const [error, setError] = (0,
|
|
1870
|
-
const fetchStaffs = (0,
|
|
1993
|
+
const [staffs, setStaffs] = (0, import_react18.useState)([]);
|
|
1994
|
+
const [loading, setLoading] = (0, import_react18.useState)(true);
|
|
1995
|
+
const [error, setError] = (0, import_react18.useState)(null);
|
|
1996
|
+
const fetchStaffs = (0, import_react18.useCallback)(async () => {
|
|
1871
1997
|
setLoading(true);
|
|
1872
1998
|
setError(null);
|
|
1873
1999
|
try {
|
|
@@ -1879,7 +2005,7 @@ function useReservationStaffs() {
|
|
|
1879
2005
|
setLoading(false);
|
|
1880
2006
|
}
|
|
1881
2007
|
}, [client]);
|
|
1882
|
-
(0,
|
|
2008
|
+
(0, import_react18.useEffect)(() => {
|
|
1883
2009
|
fetchStaffs();
|
|
1884
2010
|
}, [fetchStaffs]);
|
|
1885
2011
|
return {
|
|
@@ -1891,10 +2017,10 @@ function useReservationStaffs() {
|
|
|
1891
2017
|
}
|
|
1892
2018
|
function useAvailableSlots(serviceId, date, staffId) {
|
|
1893
2019
|
const client = useClient();
|
|
1894
|
-
const [slots, setSlots] = (0,
|
|
1895
|
-
const [loading, setLoading] = (0,
|
|
1896
|
-
const [error, setError] = (0,
|
|
1897
|
-
const fetchSlots = (0,
|
|
2020
|
+
const [slots, setSlots] = (0, import_react18.useState)([]);
|
|
2021
|
+
const [loading, setLoading] = (0, import_react18.useState)(true);
|
|
2022
|
+
const [error, setError] = (0, import_react18.useState)(null);
|
|
2023
|
+
const fetchSlots = (0, import_react18.useCallback)(async () => {
|
|
1898
2024
|
if (!serviceId || !date) {
|
|
1899
2025
|
setSlots([]);
|
|
1900
2026
|
setLoading(false);
|
|
@@ -1915,7 +2041,7 @@ function useAvailableSlots(serviceId, date, staffId) {
|
|
|
1915
2041
|
setLoading(false);
|
|
1916
2042
|
}
|
|
1917
2043
|
}, [client, serviceId, date, staffId]);
|
|
1918
|
-
(0,
|
|
2044
|
+
(0, import_react18.useEffect)(() => {
|
|
1919
2045
|
fetchSlots();
|
|
1920
2046
|
}, [fetchSlots]);
|
|
1921
2047
|
return {
|
|
@@ -1927,11 +2053,11 @@ function useAvailableSlots(serviceId, date, staffId) {
|
|
|
1927
2053
|
}
|
|
1928
2054
|
function useMyReservations(params) {
|
|
1929
2055
|
const client = useClient();
|
|
1930
|
-
const [reservations, setReservations] = (0,
|
|
1931
|
-
const [meta, setMeta] = (0,
|
|
1932
|
-
const [loading, setLoading] = (0,
|
|
1933
|
-
const [error, setError] = (0,
|
|
1934
|
-
const fetchReservations = (0,
|
|
2056
|
+
const [reservations, setReservations] = (0, import_react18.useState)([]);
|
|
2057
|
+
const [meta, setMeta] = (0, import_react18.useState)(null);
|
|
2058
|
+
const [loading, setLoading] = (0, import_react18.useState)(true);
|
|
2059
|
+
const [error, setError] = (0, import_react18.useState)(null);
|
|
2060
|
+
const fetchReservations = (0, import_react18.useCallback)(async () => {
|
|
1935
2061
|
if (!client.isAuthenticated()) {
|
|
1936
2062
|
setReservations([]);
|
|
1937
2063
|
setLoading(false);
|
|
@@ -1949,7 +2075,7 @@ function useMyReservations(params) {
|
|
|
1949
2075
|
setLoading(false);
|
|
1950
2076
|
}
|
|
1951
2077
|
}, [client, params]);
|
|
1952
|
-
(0,
|
|
2078
|
+
(0, import_react18.useEffect)(() => {
|
|
1953
2079
|
fetchReservations();
|
|
1954
2080
|
}, [fetchReservations]);
|
|
1955
2081
|
return {
|
|
@@ -1962,9 +2088,9 @@ function useMyReservations(params) {
|
|
|
1962
2088
|
}
|
|
1963
2089
|
function useCreateReservation() {
|
|
1964
2090
|
const client = useClient();
|
|
1965
|
-
const [loading, setLoading] = (0,
|
|
1966
|
-
const [error, setError] = (0,
|
|
1967
|
-
const createReservation = (0,
|
|
2091
|
+
const [loading, setLoading] = (0, import_react18.useState)(false);
|
|
2092
|
+
const [error, setError] = (0, import_react18.useState)(null);
|
|
2093
|
+
const createReservation = (0, import_react18.useCallback)(async (data) => {
|
|
1968
2094
|
setLoading(true);
|
|
1969
2095
|
setError(null);
|
|
1970
2096
|
try {
|
|
@@ -1986,10 +2112,10 @@ function useCreateReservation() {
|
|
|
1986
2112
|
}
|
|
1987
2113
|
function useReservationSettings() {
|
|
1988
2114
|
const client = useClient();
|
|
1989
|
-
const [settings, setSettings] = (0,
|
|
1990
|
-
const [loading, setLoading] = (0,
|
|
1991
|
-
const [error, setError] = (0,
|
|
1992
|
-
const fetchSettings = (0,
|
|
2115
|
+
const [settings, setSettings] = (0, import_react18.useState)(null);
|
|
2116
|
+
const [loading, setLoading] = (0, import_react18.useState)(true);
|
|
2117
|
+
const [error, setError] = (0, import_react18.useState)(null);
|
|
2118
|
+
const fetchSettings = (0, import_react18.useCallback)(async () => {
|
|
1993
2119
|
setLoading(true);
|
|
1994
2120
|
setError(null);
|
|
1995
2121
|
try {
|
|
@@ -2001,7 +2127,7 @@ function useReservationSettings() {
|
|
|
2001
2127
|
setLoading(false);
|
|
2002
2128
|
}
|
|
2003
2129
|
}, [client]);
|
|
2004
|
-
(0,
|
|
2130
|
+
(0, import_react18.useEffect)(() => {
|
|
2005
2131
|
fetchSettings();
|
|
2006
2132
|
}, [fetchSettings]);
|
|
2007
2133
|
return {
|
|
@@ -2013,17 +2139,17 @@ function useReservationSettings() {
|
|
|
2013
2139
|
}
|
|
2014
2140
|
|
|
2015
2141
|
// src/hooks/useMedia.ts
|
|
2016
|
-
var
|
|
2142
|
+
var import_react19 = require("react");
|
|
2017
2143
|
function useMedia(options = {}) {
|
|
2018
2144
|
const { type, page, per_page, autoFetch = true } = options;
|
|
2019
2145
|
const client = useClient();
|
|
2020
|
-
const [files, setFiles] = (0,
|
|
2021
|
-
const [meta, setMeta] = (0,
|
|
2022
|
-
const [loading, setLoading] = (0,
|
|
2023
|
-
const [error, setError] = (0,
|
|
2024
|
-
const [uploading, setUploading] = (0,
|
|
2025
|
-
const [uploadProgress, setUploadProgress] = (0,
|
|
2026
|
-
const fetchMedia = (0,
|
|
2146
|
+
const [files, setFiles] = (0, import_react19.useState)([]);
|
|
2147
|
+
const [meta, setMeta] = (0, import_react19.useState)(null);
|
|
2148
|
+
const [loading, setLoading] = (0, import_react19.useState)(autoFetch);
|
|
2149
|
+
const [error, setError] = (0, import_react19.useState)(null);
|
|
2150
|
+
const [uploading, setUploading] = (0, import_react19.useState)(false);
|
|
2151
|
+
const [uploadProgress, setUploadProgress] = (0, import_react19.useState)(0);
|
|
2152
|
+
const fetchMedia = (0, import_react19.useCallback)(async () => {
|
|
2027
2153
|
if (!client.isAuthenticated()) {
|
|
2028
2154
|
setFiles([]);
|
|
2029
2155
|
setLoading(false);
|
|
@@ -2041,12 +2167,12 @@ function useMedia(options = {}) {
|
|
|
2041
2167
|
setLoading(false);
|
|
2042
2168
|
}
|
|
2043
2169
|
}, [client, type, page, per_page]);
|
|
2044
|
-
(0,
|
|
2170
|
+
(0, import_react19.useEffect)(() => {
|
|
2045
2171
|
if (autoFetch) {
|
|
2046
2172
|
fetchMedia();
|
|
2047
2173
|
}
|
|
2048
2174
|
}, [autoFetch, fetchMedia]);
|
|
2049
|
-
const upload = (0,
|
|
2175
|
+
const upload = (0, import_react19.useCallback)(async (file) => {
|
|
2050
2176
|
setUploading(true);
|
|
2051
2177
|
setUploadProgress(0);
|
|
2052
2178
|
setError(null);
|
|
@@ -2063,7 +2189,7 @@ function useMedia(options = {}) {
|
|
|
2063
2189
|
setUploading(false);
|
|
2064
2190
|
}
|
|
2065
2191
|
}, [client]);
|
|
2066
|
-
const uploadMultiple = (0,
|
|
2192
|
+
const uploadMultiple = (0, import_react19.useCallback)(async (filesToUpload) => {
|
|
2067
2193
|
setUploading(true);
|
|
2068
2194
|
setUploadProgress(0);
|
|
2069
2195
|
setError(null);
|
|
@@ -2084,7 +2210,7 @@ function useMedia(options = {}) {
|
|
|
2084
2210
|
setUploading(false);
|
|
2085
2211
|
}
|
|
2086
2212
|
}, [client]);
|
|
2087
|
-
const deleteFile = (0,
|
|
2213
|
+
const deleteFile = (0, import_react19.useCallback)(async (mediaId) => {
|
|
2088
2214
|
await client.media.delete(mediaId);
|
|
2089
2215
|
setFiles((prev) => prev.filter((f) => f.id !== mediaId));
|
|
2090
2216
|
}, [client]);
|
|
@@ -2103,13 +2229,13 @@ function useMedia(options = {}) {
|
|
|
2103
2229
|
}
|
|
2104
2230
|
|
|
2105
2231
|
// src/hooks/useEntities.ts
|
|
2106
|
-
var
|
|
2232
|
+
var import_react20 = require("react");
|
|
2107
2233
|
function useEntities() {
|
|
2108
2234
|
const client = useClient();
|
|
2109
|
-
const [entities, setEntities] = (0,
|
|
2110
|
-
const [loading, setLoading] = (0,
|
|
2111
|
-
const [error, setError] = (0,
|
|
2112
|
-
const fetchEntities = (0,
|
|
2235
|
+
const [entities, setEntities] = (0, import_react20.useState)([]);
|
|
2236
|
+
const [loading, setLoading] = (0, import_react20.useState)(true);
|
|
2237
|
+
const [error, setError] = (0, import_react20.useState)(null);
|
|
2238
|
+
const fetchEntities = (0, import_react20.useCallback)(async () => {
|
|
2113
2239
|
setLoading(true);
|
|
2114
2240
|
setError(null);
|
|
2115
2241
|
try {
|
|
@@ -2121,7 +2247,7 @@ function useEntities() {
|
|
|
2121
2247
|
setLoading(false);
|
|
2122
2248
|
}
|
|
2123
2249
|
}, [client]);
|
|
2124
|
-
(0,
|
|
2250
|
+
(0, import_react20.useEffect)(() => {
|
|
2125
2251
|
fetchEntities();
|
|
2126
2252
|
}, [fetchEntities]);
|
|
2127
2253
|
return {
|
|
@@ -2133,10 +2259,10 @@ function useEntities() {
|
|
|
2133
2259
|
}
|
|
2134
2260
|
function useEntity(slug) {
|
|
2135
2261
|
const client = useClient();
|
|
2136
|
-
const [entity, setEntity] = (0,
|
|
2137
|
-
const [loading, setLoading] = (0,
|
|
2138
|
-
const [error, setError] = (0,
|
|
2139
|
-
const fetchEntity = (0,
|
|
2262
|
+
const [entity, setEntity] = (0, import_react20.useState)(null);
|
|
2263
|
+
const [loading, setLoading] = (0, import_react20.useState)(true);
|
|
2264
|
+
const [error, setError] = (0, import_react20.useState)(null);
|
|
2265
|
+
const fetchEntity = (0, import_react20.useCallback)(async () => {
|
|
2140
2266
|
setLoading(true);
|
|
2141
2267
|
setError(null);
|
|
2142
2268
|
try {
|
|
@@ -2148,7 +2274,7 @@ function useEntity(slug) {
|
|
|
2148
2274
|
setLoading(false);
|
|
2149
2275
|
}
|
|
2150
2276
|
}, [client, slug]);
|
|
2151
|
-
(0,
|
|
2277
|
+
(0, import_react20.useEffect)(() => {
|
|
2152
2278
|
fetchEntity();
|
|
2153
2279
|
}, [fetchEntity]);
|
|
2154
2280
|
return {
|
|
@@ -2160,12 +2286,12 @@ function useEntity(slug) {
|
|
|
2160
2286
|
}
|
|
2161
2287
|
function useEntityRecords(slug, params) {
|
|
2162
2288
|
const client = useClient();
|
|
2163
|
-
const [records, setRecords] = (0,
|
|
2164
|
-
const [meta, setMeta] = (0,
|
|
2165
|
-
const [loading, setLoading] = (0,
|
|
2166
|
-
const [error, setError] = (0,
|
|
2167
|
-
const [currentParams, setCurrentParams] = (0,
|
|
2168
|
-
const fetchRecords = (0,
|
|
2289
|
+
const [records, setRecords] = (0, import_react20.useState)([]);
|
|
2290
|
+
const [meta, setMeta] = (0, import_react20.useState)(null);
|
|
2291
|
+
const [loading, setLoading] = (0, import_react20.useState)(true);
|
|
2292
|
+
const [error, setError] = (0, import_react20.useState)(null);
|
|
2293
|
+
const [currentParams, setCurrentParams] = (0, import_react20.useState)(params);
|
|
2294
|
+
const fetchRecords = (0, import_react20.useCallback)(async (fetchParams, append = false) => {
|
|
2169
2295
|
setLoading(true);
|
|
2170
2296
|
setError(null);
|
|
2171
2297
|
try {
|
|
@@ -2182,30 +2308,30 @@ function useEntityRecords(slug, params) {
|
|
|
2182
2308
|
setLoading(false);
|
|
2183
2309
|
}
|
|
2184
2310
|
}, [client, slug]);
|
|
2185
|
-
(0,
|
|
2311
|
+
(0, import_react20.useEffect)(() => {
|
|
2186
2312
|
fetchRecords(params);
|
|
2187
2313
|
}, []);
|
|
2188
2314
|
const hasMore = meta ? meta.current_page < meta.last_page : false;
|
|
2189
|
-
const loadMore = (0,
|
|
2315
|
+
const loadMore = (0, import_react20.useCallback)(async () => {
|
|
2190
2316
|
if (!hasMore || loading) return;
|
|
2191
2317
|
const nextPage = (meta?.current_page ?? 0) + 1;
|
|
2192
2318
|
await fetchRecords({ ...currentParams, page: nextPage }, true);
|
|
2193
2319
|
}, [hasMore, loading, meta, currentParams, fetchRecords]);
|
|
2194
|
-
const createRecord = (0,
|
|
2320
|
+
const createRecord = (0, import_react20.useCallback)(async (data) => {
|
|
2195
2321
|
const record = await client.entities.createRecord(slug, data);
|
|
2196
2322
|
setRecords((prev) => [record, ...prev]);
|
|
2197
2323
|
return record;
|
|
2198
2324
|
}, [client, slug]);
|
|
2199
|
-
const updateRecord = (0,
|
|
2325
|
+
const updateRecord = (0, import_react20.useCallback)(async (id, data) => {
|
|
2200
2326
|
const record = await client.entities.updateRecord(slug, id, data);
|
|
2201
2327
|
setRecords((prev) => prev.map((r) => r.id === id ? record : r));
|
|
2202
2328
|
return record;
|
|
2203
2329
|
}, [client, slug]);
|
|
2204
|
-
const deleteRecord = (0,
|
|
2330
|
+
const deleteRecord = (0, import_react20.useCallback)(async (id) => {
|
|
2205
2331
|
await client.entities.deleteRecord(slug, id);
|
|
2206
2332
|
setRecords((prev) => prev.filter((r) => r.id !== id));
|
|
2207
2333
|
}, [client, slug]);
|
|
2208
|
-
const refresh = (0,
|
|
2334
|
+
const refresh = (0, import_react20.useCallback)(async () => {
|
|
2209
2335
|
setCurrentParams(params);
|
|
2210
2336
|
await fetchRecords(params);
|
|
2211
2337
|
}, [params, fetchRecords]);
|
|
@@ -2224,10 +2350,10 @@ function useEntityRecords(slug, params) {
|
|
|
2224
2350
|
}
|
|
2225
2351
|
function useEntityRecord(slug, id) {
|
|
2226
2352
|
const client = useClient();
|
|
2227
|
-
const [record, setRecord] = (0,
|
|
2228
|
-
const [loading, setLoading] = (0,
|
|
2229
|
-
const [error, setError] = (0,
|
|
2230
|
-
const fetchRecord = (0,
|
|
2353
|
+
const [record, setRecord] = (0, import_react20.useState)(null);
|
|
2354
|
+
const [loading, setLoading] = (0, import_react20.useState)(true);
|
|
2355
|
+
const [error, setError] = (0, import_react20.useState)(null);
|
|
2356
|
+
const fetchRecord = (0, import_react20.useCallback)(async () => {
|
|
2231
2357
|
setLoading(true);
|
|
2232
2358
|
setError(null);
|
|
2233
2359
|
try {
|
|
@@ -2239,10 +2365,10 @@ function useEntityRecord(slug, id) {
|
|
|
2239
2365
|
setLoading(false);
|
|
2240
2366
|
}
|
|
2241
2367
|
}, [client, slug, id]);
|
|
2242
|
-
(0,
|
|
2368
|
+
(0, import_react20.useEffect)(() => {
|
|
2243
2369
|
fetchRecord();
|
|
2244
2370
|
}, [fetchRecord]);
|
|
2245
|
-
const update = (0,
|
|
2371
|
+
const update = (0, import_react20.useCallback)(async (data) => {
|
|
2246
2372
|
const updated = await client.entities.updateRecord(slug, id, data);
|
|
2247
2373
|
setRecord(updated);
|
|
2248
2374
|
return updated;
|
|
@@ -2257,7 +2383,7 @@ function useEntityRecord(slug, id) {
|
|
|
2257
2383
|
}
|
|
2258
2384
|
function useTypedEntity(slug) {
|
|
2259
2385
|
const client = useClient();
|
|
2260
|
-
return (0,
|
|
2386
|
+
return (0, import_react20.useMemo)(() => ({
|
|
2261
2387
|
useRecords: (params) => {
|
|
2262
2388
|
const result = useEntityRecords(slug, params);
|
|
2263
2389
|
return {
|
|
@@ -2283,10 +2409,78 @@ function useTypedEntity(slug) {
|
|
|
2283
2409
|
delete: (id) => client.entities.deleteRecord(slug, id)
|
|
2284
2410
|
}), [client, slug]);
|
|
2285
2411
|
}
|
|
2412
|
+
|
|
2413
|
+
// src/components/RichContent.tsx
|
|
2414
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
2415
|
+
var quillStyles = `
|
|
2416
|
+
/* Quill Alignment */
|
|
2417
|
+
.ql-align-center { text-align: center; }
|
|
2418
|
+
.ql-align-right { text-align: right; }
|
|
2419
|
+
.ql-align-justify { text-align: justify; }
|
|
2420
|
+
|
|
2421
|
+
/* Quill Font Sizes */
|
|
2422
|
+
.ql-size-small { font-size: 0.75em; }
|
|
2423
|
+
.ql-size-large { font-size: 1.5em; }
|
|
2424
|
+
.ql-size-huge { font-size: 2.5em; }
|
|
2425
|
+
|
|
2426
|
+
/* Quill Fonts */
|
|
2427
|
+
.ql-font-serif { font-family: Georgia, Times New Roman, serif; }
|
|
2428
|
+
.ql-font-monospace { font-family: Monaco, Courier New, monospace; }
|
|
2429
|
+
|
|
2430
|
+
/* Quill Indent */
|
|
2431
|
+
.ql-indent-1 { padding-left: 3em; }
|
|
2432
|
+
.ql-indent-2 { padding-left: 6em; }
|
|
2433
|
+
.ql-indent-3 { padding-left: 9em; }
|
|
2434
|
+
.ql-indent-4 { padding-left: 12em; }
|
|
2435
|
+
.ql-indent-5 { padding-left: 15em; }
|
|
2436
|
+
|
|
2437
|
+
/* Quill Video */
|
|
2438
|
+
.ql-video {
|
|
2439
|
+
display: block;
|
|
2440
|
+
max-width: 100%;
|
|
2441
|
+
margin: 1em 0;
|
|
2442
|
+
}
|
|
2443
|
+
|
|
2444
|
+
/* Quill Code Block */
|
|
2445
|
+
.ql-code-block-container {
|
|
2446
|
+
background-color: #23241f;
|
|
2447
|
+
color: #f8f8f2;
|
|
2448
|
+
border-radius: 0.375rem;
|
|
2449
|
+
padding: 1em;
|
|
2450
|
+
margin: 1em 0;
|
|
2451
|
+
overflow-x: auto;
|
|
2452
|
+
}
|
|
2453
|
+
`;
|
|
2454
|
+
function RichContent({
|
|
2455
|
+
html,
|
|
2456
|
+
className = "",
|
|
2457
|
+
prose = true,
|
|
2458
|
+
proseVariant = "default",
|
|
2459
|
+
proseSize = "base",
|
|
2460
|
+
maxWidth = "none"
|
|
2461
|
+
}) {
|
|
2462
|
+
const proseClasses = prose ? [
|
|
2463
|
+
"prose",
|
|
2464
|
+
proseVariant !== "default" && `prose-${proseVariant}`,
|
|
2465
|
+
proseSize !== "base" && `prose-${proseSize}`,
|
|
2466
|
+
maxWidth !== "none" && `max-w-${maxWidth}`
|
|
2467
|
+
].filter(Boolean).join(" ") : "";
|
|
2468
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
|
|
2469
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("style", { dangerouslySetInnerHTML: { __html: quillStyles } }),
|
|
2470
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
2471
|
+
"div",
|
|
2472
|
+
{
|
|
2473
|
+
className: `rich-content ${proseClasses} ${className}`.trim(),
|
|
2474
|
+
dangerouslySetInnerHTML: { __html: html }
|
|
2475
|
+
}
|
|
2476
|
+
)
|
|
2477
|
+
] });
|
|
2478
|
+
}
|
|
2286
2479
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2287
2480
|
0 && (module.exports = {
|
|
2288
2481
|
DiffsomeContext,
|
|
2289
2482
|
DiffsomeProvider,
|
|
2483
|
+
RichContent,
|
|
2290
2484
|
useAuth,
|
|
2291
2485
|
useAvailableSlots,
|
|
2292
2486
|
useBlog,
|
|
@@ -2311,6 +2505,7 @@ function useTypedEntity(slug) {
|
|
|
2311
2505
|
useCreateReservation,
|
|
2312
2506
|
useCreateReview,
|
|
2313
2507
|
useCreateSubscription,
|
|
2508
|
+
useCurrency,
|
|
2314
2509
|
useDiffsome,
|
|
2315
2510
|
useDigitalProducts,
|
|
2316
2511
|
useDownloads,
|
|
@@ -2335,6 +2530,7 @@ function useTypedEntity(slug) {
|
|
|
2335
2530
|
useReservationServices,
|
|
2336
2531
|
useReservationSettings,
|
|
2337
2532
|
useReservationStaffs,
|
|
2533
|
+
useSite,
|
|
2338
2534
|
useSocialAuth,
|
|
2339
2535
|
useStripePayment,
|
|
2340
2536
|
useSubscription,
|