@diffsome/react 1.1.2 → 1.2.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.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  // src/context/DiffsomeContext.tsx
2
- import { createContext, useContext, useState, useEffect, useMemo } from "react";
2
+ import { createContext, useContext, useState, useEffect, useCallback, useMemo } from "react";
3
3
  import { Diffsome } from "@diffsome/sdk";
4
4
  import { jsx } from "react/jsx-runtime";
5
5
  var DiffsomeContext = createContext(null);
@@ -14,6 +14,10 @@ var getEnvVar = (key) => {
14
14
  };
15
15
  function DiffsomeProvider({ children, config = {} }) {
16
16
  const [isReady, setIsReady] = useState(false);
17
+ const [cart, setCart] = useState(null);
18
+ const [cartLoading, setCartLoading] = useState(true);
19
+ const [wishlistItems, setWishlistItems] = useState([]);
20
+ const [wishlistLoading, setWishlistLoading] = useState(true);
17
21
  const tenantId = config.tenantId || getEnvVar("DIFFSOME_TENANT_ID");
18
22
  const apiKey = config.apiKey || getEnvVar("DIFFSOME_API_KEY");
19
23
  const baseUrl = config.baseUrl || getEnvVar("DIFFSOME_BASE_URL");
@@ -31,13 +35,59 @@ function DiffsomeProvider({ children, config = {} }) {
31
35
  storageType: config.storageType ?? "localStorage"
32
36
  });
33
37
  }, [tenantId, baseUrl, apiKey, config.persistToken, config.storageType]);
38
+ const refreshCart = useCallback(async () => {
39
+ setCartLoading(true);
40
+ try {
41
+ const cartData = await client.shop.getCart();
42
+ setCart(cartData);
43
+ } catch (err) {
44
+ setCart(null);
45
+ } finally {
46
+ setCartLoading(false);
47
+ }
48
+ }, [client]);
49
+ const refreshWishlist = useCallback(async () => {
50
+ if (!client.isAuthenticated()) {
51
+ setWishlistItems([]);
52
+ setWishlistLoading(false);
53
+ return;
54
+ }
55
+ setWishlistLoading(true);
56
+ try {
57
+ const response = await client.shop.getWishlist({ per_page: 100 });
58
+ setWishlistItems(response.data);
59
+ } catch (err) {
60
+ setWishlistItems([]);
61
+ } finally {
62
+ setWishlistLoading(false);
63
+ }
64
+ }, [client]);
34
65
  useEffect(() => {
35
66
  setIsReady(true);
36
- }, []);
67
+ refreshCart();
68
+ refreshWishlist();
69
+ }, [refreshCart, refreshWishlist]);
70
+ useEffect(() => {
71
+ const handleAuthChange = () => {
72
+ refreshWishlist();
73
+ };
74
+ if (typeof window !== "undefined") {
75
+ window.addEventListener("storage", handleAuthChange);
76
+ return () => window.removeEventListener("storage", handleAuthChange);
77
+ }
78
+ }, [refreshWishlist]);
37
79
  const value = useMemo(() => ({
38
80
  client,
39
- isReady
40
- }), [client, isReady]);
81
+ isReady,
82
+ cart,
83
+ cartLoading,
84
+ setCart,
85
+ refreshCart,
86
+ wishlistItems,
87
+ wishlistLoading,
88
+ setWishlistItems,
89
+ refreshWishlist
90
+ }), [client, isReady, cart, cartLoading, refreshCart, wishlistItems, wishlistLoading, refreshWishlist]);
41
91
  return /* @__PURE__ */ jsx(DiffsomeContext.Provider, { value, children });
42
92
  }
43
93
  function useDiffsome() {
@@ -194,27 +244,9 @@ function useSocialAuth() {
194
244
  }
195
245
 
196
246
  // src/hooks/useCart.ts
197
- import { useState as useState4, useEffect as useEffect4, useCallback as useCallback4 } from "react";
247
+ import { useCallback as useCallback4 } from "react";
198
248
  function useCart() {
199
- const client = useClient();
200
- const [cart, setCart] = useState4(null);
201
- const [loading, setLoading] = useState4(true);
202
- const [error, setError] = useState4(null);
203
- const fetchCart = useCallback4(async () => {
204
- try {
205
- const cartData = await client.shop.getCart();
206
- setCart(cartData);
207
- setError(null);
208
- } catch (err) {
209
- setCart(null);
210
- setError(err instanceof Error ? err : new Error("Failed to fetch cart"));
211
- } finally {
212
- setLoading(false);
213
- }
214
- }, [client]);
215
- useEffect4(() => {
216
- fetchCart();
217
- }, [fetchCart]);
249
+ const { client, cart, cartLoading, setCart, refreshCart } = useDiffsome();
218
250
  const addToCart = useCallback4(async (productId, quantity = 1, variantId, options) => {
219
251
  const data = {
220
252
  product_id: productId,
@@ -225,25 +257,21 @@ function useCart() {
225
257
  const updatedCart = await client.shop.addToCart(data);
226
258
  setCart(updatedCart);
227
259
  return updatedCart;
228
- }, [client]);
260
+ }, [client, setCart]);
229
261
  const updateItem = useCallback4(async (itemId, quantity) => {
230
262
  const updatedCart = await client.shop.updateCartItem(itemId, { quantity });
231
263
  setCart(updatedCart);
232
264
  return updatedCart;
233
- }, [client]);
265
+ }, [client, setCart]);
234
266
  const removeItem = useCallback4(async (itemId) => {
235
267
  const updatedCart = await client.shop.removeFromCart(itemId);
236
268
  setCart(updatedCart);
237
269
  return updatedCart;
238
- }, [client]);
270
+ }, [client, setCart]);
239
271
  const clearCart = useCallback4(async () => {
240
272
  await client.shop.clearCart();
241
273
  setCart(null);
242
- }, [client]);
243
- const refresh = useCallback4(async () => {
244
- setLoading(true);
245
- await fetchCart();
246
- }, [fetchCart]);
274
+ }, [client, setCart]);
247
275
  const isInCart = useCallback4((productId, variantId) => {
248
276
  if (!cart?.items) return false;
249
277
  return cart.items.some(
@@ -265,117 +293,77 @@ function useCart() {
265
293
  subtotal: cart?.subtotal ?? 0,
266
294
  shippingFee: cart?.shipping_fee ?? 0,
267
295
  total: cart?.total ?? 0,
268
- loading,
269
- error,
296
+ loading: cartLoading,
270
297
  addToCart,
271
298
  updateItem,
272
299
  removeItem,
273
300
  clearCart,
274
- refresh,
301
+ refresh: refreshCart,
275
302
  isInCart,
276
303
  getItemQuantity
277
304
  };
278
305
  }
279
306
 
280
307
  // src/hooks/useWishlist.ts
281
- import { useState as useState5, useEffect as useEffect5, useCallback as useCallback5 } from "react";
308
+ import { useState as useState4, useCallback as useCallback5, useMemo as useMemo2 } from "react";
282
309
  function useWishlist() {
283
- const client = useClient();
284
- const [items, setItems] = useState5([]);
285
- const [loading, setLoading] = useState5(true);
286
- const [error, setError] = useState5(null);
287
- const [wishlistMap, setWishlistMap] = useState5({});
288
- const fetchWishlist = useCallback5(async () => {
289
- if (!client.isAuthenticated()) {
290
- setItems([]);
291
- setWishlistMap({});
292
- setLoading(false);
293
- return;
294
- }
295
- try {
296
- const response = await client.shop.getWishlist({ per_page: 100 });
297
- setItems(response.data);
298
- const map = {};
299
- response.data.forEach((item) => {
300
- const key = item.variant_id ? `${item.product_id}_${item.variant_id}` : String(item.product_id);
301
- map[key] = true;
302
- });
303
- setWishlistMap(map);
304
- setError(null);
305
- } catch (err) {
306
- setItems([]);
307
- setWishlistMap({});
308
- setError(err instanceof Error ? err : new Error("Failed to fetch wishlist"));
309
- } finally {
310
- setLoading(false);
311
- }
312
- }, [client]);
313
- useEffect5(() => {
314
- fetchWishlist();
315
- }, [fetchWishlist]);
310
+ const { client, wishlistItems, wishlistLoading, setWishlistItems, refreshWishlist, setCart } = useDiffsome();
311
+ const [error, setError] = useState4(null);
312
+ const wishlistMap = useMemo2(() => {
313
+ const map = {};
314
+ wishlistItems.forEach((item) => {
315
+ const key = item.variant_id ? `${item.product_id}_${item.variant_id}` : String(item.product_id);
316
+ map[key] = true;
317
+ });
318
+ return map;
319
+ }, [wishlistItems]);
316
320
  const isInWishlist = useCallback5((productId, variantId) => {
317
321
  const key = variantId ? `${productId}_${variantId}` : String(productId);
318
322
  return wishlistMap[key] || false;
319
323
  }, [wishlistMap]);
320
324
  const toggleWishlist = useCallback5(async (productId, variantId) => {
321
325
  const result = await client.shop.toggleWishlist(productId, variantId);
322
- const key = variantId ? `${productId}_${variantId}` : String(productId);
323
- setWishlistMap((prev) => ({
324
- ...prev,
325
- [key]: result.in_wishlist
326
- }));
327
326
  if (result.action === "added") {
328
- await fetchWishlist();
327
+ await refreshWishlist();
329
328
  } else {
330
- setItems((prev) => prev.filter(
329
+ setWishlistItems(wishlistItems.filter(
331
330
  (item) => !(item.product_id === productId && item.variant_id === variantId)
332
331
  ));
333
332
  }
334
333
  return result;
335
- }, [client, fetchWishlist]);
334
+ }, [client, refreshWishlist, setWishlistItems, wishlistItems]);
336
335
  const addToWishlist = useCallback5(async (productId, variantId, note) => {
337
336
  const item = await client.shop.addToWishlist({
338
337
  product_id: productId,
339
338
  variant_id: variantId,
340
339
  note
341
340
  });
342
- await fetchWishlist();
341
+ await refreshWishlist();
343
342
  return item;
344
- }, [client, fetchWishlist]);
343
+ }, [client, refreshWishlist]);
345
344
  const removeFromWishlist = useCallback5(async (wishlistId) => {
346
- const item = items.find((i) => i.id === wishlistId);
347
345
  await client.shop.removeFromWishlist(wishlistId);
348
- if (item) {
349
- const key = item.variant_id ? `${item.product_id}_${item.variant_id}` : String(item.product_id);
350
- setWishlistMap((prev) => {
351
- const next = { ...prev };
352
- delete next[key];
353
- return next;
354
- });
355
- }
356
- setItems((prev) => prev.filter((i) => i.id !== wishlistId));
357
- }, [client, items]);
346
+ setWishlistItems(wishlistItems.filter((i) => i.id !== wishlistId));
347
+ }, [client, setWishlistItems, wishlistItems]);
358
348
  const moveToCart = useCallback5(async (wishlistIds) => {
359
349
  const result = await client.shop.moveWishlistToCart(wishlistIds);
360
- await fetchWishlist();
350
+ await refreshWishlist();
351
+ const cartData = await client.shop.getCart();
352
+ setCart(cartData);
361
353
  return result;
362
- }, [client, fetchWishlist]);
354
+ }, [client, refreshWishlist, setCart]);
363
355
  const updateNote = useCallback5(async (wishlistId, note) => {
364
356
  const item = await client.shop.updateWishlistNote(wishlistId, note);
365
- setItems((prev) => prev.map((i) => i.id === wishlistId ? item : i));
357
+ setWishlistItems(wishlistItems.map((i) => i.id === wishlistId ? item : i));
366
358
  return item;
367
- }, [client]);
359
+ }, [client, setWishlistItems, wishlistItems]);
368
360
  const getProductWishlistCount = useCallback5(async (productSlug) => {
369
361
  return await client.shop.getProductWishlistCount(productSlug);
370
362
  }, [client]);
371
- const refresh = useCallback5(async () => {
372
- setLoading(true);
373
- await fetchWishlist();
374
- }, [fetchWishlist]);
375
363
  return {
376
- items,
377
- count: items.length,
378
- loading,
364
+ items: wishlistItems,
365
+ count: wishlistItems.length,
366
+ loading: wishlistLoading,
379
367
  error,
380
368
  isInWishlist,
381
369
  toggleWishlist,
@@ -384,20 +372,20 @@ function useWishlist() {
384
372
  moveToCart,
385
373
  updateNote,
386
374
  getProductWishlistCount,
387
- refresh
375
+ refresh: refreshWishlist
388
376
  };
389
377
  }
390
378
 
391
379
  // src/hooks/useProducts.ts
392
- import { useState as useState6, useEffect as useEffect6, useCallback as useCallback6 } from "react";
380
+ import { useState as useState5, useEffect as useEffect4, useCallback as useCallback6 } from "react";
393
381
  function useProducts(options = {}) {
394
382
  const { autoFetch = true, ...params } = options;
395
383
  const client = useClient();
396
- const [products, setProducts] = useState6([]);
397
- const [meta, setMeta] = useState6(null);
398
- const [loading, setLoading] = useState6(autoFetch);
399
- const [error, setError] = useState6(null);
400
- const [currentParams, setCurrentParams] = useState6(params);
384
+ const [products, setProducts] = useState5([]);
385
+ const [meta, setMeta] = useState5(null);
386
+ const [loading, setLoading] = useState5(autoFetch);
387
+ const [error, setError] = useState5(null);
388
+ const [currentParams, setCurrentParams] = useState5(params);
401
389
  const fetchProducts = useCallback6(async (fetchParams, append = false) => {
402
390
  setLoading(true);
403
391
  setError(null);
@@ -415,7 +403,7 @@ function useProducts(options = {}) {
415
403
  setLoading(false);
416
404
  }
417
405
  }, [client]);
418
- useEffect6(() => {
406
+ useEffect4(() => {
419
407
  if (autoFetch) {
420
408
  fetchProducts(params);
421
409
  }
@@ -448,9 +436,9 @@ function useProducts(options = {}) {
448
436
  }
449
437
  function useProduct(idOrSlug) {
450
438
  const client = useClient();
451
- const [product, setProduct] = useState6(null);
452
- const [loading, setLoading] = useState6(true);
453
- const [error, setError] = useState6(null);
439
+ const [product, setProduct] = useState5(null);
440
+ const [loading, setLoading] = useState5(true);
441
+ const [error, setError] = useState5(null);
454
442
  const fetchProduct = useCallback6(async () => {
455
443
  setLoading(true);
456
444
  setError(null);
@@ -463,7 +451,7 @@ function useProduct(idOrSlug) {
463
451
  setLoading(false);
464
452
  }
465
453
  }, [client, idOrSlug]);
466
- useEffect6(() => {
454
+ useEffect4(() => {
467
455
  fetchProduct();
468
456
  }, [fetchProduct]);
469
457
  return {
@@ -475,9 +463,9 @@ function useProduct(idOrSlug) {
475
463
  }
476
464
  function useCategories() {
477
465
  const client = useClient();
478
- const [categories, setCategories] = useState6([]);
479
- const [loading, setLoading] = useState6(true);
480
- const [error, setError] = useState6(null);
466
+ const [categories, setCategories] = useState5([]);
467
+ const [loading, setLoading] = useState5(true);
468
+ const [error, setError] = useState5(null);
481
469
  const fetchCategories = useCallback6(async () => {
482
470
  setLoading(true);
483
471
  setError(null);
@@ -490,7 +478,7 @@ function useCategories() {
490
478
  setLoading(false);
491
479
  }
492
480
  }, [client]);
493
- useEffect6(() => {
481
+ useEffect4(() => {
494
482
  fetchCategories();
495
483
  }, [fetchCategories]);
496
484
  return {
@@ -502,9 +490,9 @@ function useCategories() {
502
490
  }
503
491
  function useFeaturedProducts(limit = 8) {
504
492
  const client = useClient();
505
- const [products, setProducts] = useState6([]);
506
- const [loading, setLoading] = useState6(true);
507
- const [error, setError] = useState6(null);
493
+ const [products, setProducts] = useState5([]);
494
+ const [loading, setLoading] = useState5(true);
495
+ const [error, setError] = useState5(null);
508
496
  const fetchProducts = useCallback6(async () => {
509
497
  setLoading(true);
510
498
  setError(null);
@@ -517,7 +505,7 @@ function useFeaturedProducts(limit = 8) {
517
505
  setLoading(false);
518
506
  }
519
507
  }, [client, limit]);
520
- useEffect6(() => {
508
+ useEffect4(() => {
521
509
  fetchProducts();
522
510
  }, [fetchProducts]);
523
511
  return {
@@ -529,10 +517,10 @@ function useFeaturedProducts(limit = 8) {
529
517
  }
530
518
  function useProductsByType(type, params) {
531
519
  const client = useClient();
532
- const [products, setProducts] = useState6([]);
533
- const [meta, setMeta] = useState6(null);
534
- const [loading, setLoading] = useState6(true);
535
- const [error, setError] = useState6(null);
520
+ const [products, setProducts] = useState5([]);
521
+ const [meta, setMeta] = useState5(null);
522
+ const [loading, setLoading] = useState5(true);
523
+ const [error, setError] = useState5(null);
536
524
  const fetchProducts = useCallback6(async () => {
537
525
  setLoading(true);
538
526
  setError(null);
@@ -546,7 +534,7 @@ function useProductsByType(type, params) {
546
534
  setLoading(false);
547
535
  }
548
536
  }, [client, type, params]);
549
- useEffect6(() => {
537
+ useEffect4(() => {
550
538
  fetchProducts();
551
539
  }, [fetchProducts]);
552
540
  return {
@@ -568,9 +556,9 @@ function useBundleProducts(params) {
568
556
  }
569
557
  function useBundleItems(productSlug) {
570
558
  const client = useClient();
571
- const [bundle, setBundle] = useState6(null);
572
- const [loading, setLoading] = useState6(true);
573
- const [error, setError] = useState6(null);
559
+ const [bundle, setBundle] = useState5(null);
560
+ const [loading, setLoading] = useState5(true);
561
+ const [error, setError] = useState5(null);
574
562
  const fetchBundle = useCallback6(async () => {
575
563
  setLoading(true);
576
564
  setError(null);
@@ -583,7 +571,7 @@ function useBundleItems(productSlug) {
583
571
  setLoading(false);
584
572
  }
585
573
  }, [client, productSlug]);
586
- useEffect6(() => {
574
+ useEffect4(() => {
587
575
  fetchBundle();
588
576
  }, [fetchBundle]);
589
577
  return {
@@ -595,13 +583,13 @@ function useBundleItems(productSlug) {
595
583
  }
596
584
 
597
585
  // src/hooks/useOrders.ts
598
- import { useState as useState7, useEffect as useEffect7, useCallback as useCallback7 } from "react";
586
+ import { useState as useState6, useEffect as useEffect5, useCallback as useCallback7 } from "react";
599
587
  function useOrders(params) {
600
588
  const client = useClient();
601
- const [orders, setOrders] = useState7([]);
602
- const [meta, setMeta] = useState7(null);
603
- const [loading, setLoading] = useState7(true);
604
- const [error, setError] = useState7(null);
589
+ const [orders, setOrders] = useState6([]);
590
+ const [meta, setMeta] = useState6(null);
591
+ const [loading, setLoading] = useState6(true);
592
+ const [error, setError] = useState6(null);
605
593
  const fetchOrders = useCallback7(async (fetchParams, append = false) => {
606
594
  if (!client.isAuthenticated()) {
607
595
  setOrders([]);
@@ -624,7 +612,7 @@ function useOrders(params) {
624
612
  setLoading(false);
625
613
  }
626
614
  }, [client]);
627
- useEffect7(() => {
615
+ useEffect5(() => {
628
616
  fetchOrders(params);
629
617
  }, []);
630
618
  const hasMore = meta ? meta.current_page < meta.last_page : false;
@@ -648,9 +636,9 @@ function useOrders(params) {
648
636
  }
649
637
  function useOrder(idOrNumber) {
650
638
  const client = useClient();
651
- const [order, setOrder] = useState7(null);
652
- const [loading, setLoading] = useState7(true);
653
- const [error, setError] = useState7(null);
639
+ const [order, setOrder] = useState6(null);
640
+ const [loading, setLoading] = useState6(true);
641
+ const [error, setError] = useState6(null);
654
642
  const fetchOrder = useCallback7(async () => {
655
643
  setLoading(true);
656
644
  setError(null);
@@ -663,7 +651,7 @@ function useOrder(idOrNumber) {
663
651
  setLoading(false);
664
652
  }
665
653
  }, [client, idOrNumber]);
666
- useEffect7(() => {
654
+ useEffect5(() => {
667
655
  fetchOrder();
668
656
  }, [fetchOrder]);
669
657
  const cancel = useCallback7(async () => {
@@ -682,8 +670,8 @@ function useOrder(idOrNumber) {
682
670
  }
683
671
  function useCreateOrder() {
684
672
  const client = useClient();
685
- const [loading, setLoading] = useState7(false);
686
- const [error, setError] = useState7(null);
673
+ const [loading, setLoading] = useState6(false);
674
+ const [error, setError] = useState6(null);
687
675
  const createOrder = useCallback7(async (data) => {
688
676
  setLoading(true);
689
677
  setError(null);
@@ -705,12 +693,12 @@ function useCreateOrder() {
705
693
  }
706
694
 
707
695
  // src/hooks/usePayment.ts
708
- import { useState as useState8, useCallback as useCallback8 } from "react";
696
+ import { useState as useState7, useCallback as useCallback8 } from "react";
709
697
  function usePaymentStatus() {
710
698
  const client = useClient();
711
- const [status, setStatus] = useState8(null);
712
- const [loading, setLoading] = useState8(true);
713
- const [error, setError] = useState8(null);
699
+ const [status, setStatus] = useState7(null);
700
+ const [loading, setLoading] = useState7(true);
701
+ const [error, setError] = useState7(null);
714
702
  const fetchStatus = useCallback8(async () => {
715
703
  setLoading(true);
716
704
  setError(null);
@@ -735,8 +723,8 @@ function usePaymentStatus() {
735
723
  }
736
724
  function useTossPayment() {
737
725
  const client = useClient();
738
- const [loading, setLoading] = useState8(false);
739
- const [error, setError] = useState8(null);
726
+ const [loading, setLoading] = useState7(false);
727
+ const [error, setError] = useState7(null);
740
728
  const preparePayment = useCallback8(async (orderNumber, successUrl, failUrl) => {
741
729
  setLoading(true);
742
730
  setError(null);
@@ -794,8 +782,8 @@ function useTossPayment() {
794
782
  }
795
783
  function useStripePayment() {
796
784
  const client = useClient();
797
- const [loading, setLoading] = useState8(false);
798
- const [error, setError] = useState8(null);
785
+ const [loading, setLoading] = useState7(false);
786
+ const [error, setError] = useState7(null);
799
787
  const createCheckout = useCallback8(async (orderNumber, successUrl, cancelUrl) => {
800
788
  setLoading(true);
801
789
  setError(null);
@@ -849,12 +837,12 @@ function useStripePayment() {
849
837
  }
850
838
 
851
839
  // src/hooks/useCoupons.ts
852
- import { useState as useState9, useEffect as useEffect8, useCallback as useCallback9 } from "react";
840
+ import { useState as useState8, useEffect as useEffect6, useCallback as useCallback9 } from "react";
853
841
  function useCoupons() {
854
842
  const client = useClient();
855
- const [coupons, setCoupons] = useState9([]);
856
- const [loading, setLoading] = useState9(true);
857
- const [error, setError] = useState9(null);
843
+ const [coupons, setCoupons] = useState8([]);
844
+ const [loading, setLoading] = useState8(true);
845
+ const [error, setError] = useState8(null);
858
846
  const fetchCoupons = useCallback9(async () => {
859
847
  if (!client.isAuthenticated()) {
860
848
  setCoupons([]);
@@ -872,7 +860,7 @@ function useCoupons() {
872
860
  setLoading(false);
873
861
  }
874
862
  }, [client]);
875
- useEffect8(() => {
863
+ useEffect6(() => {
876
864
  fetchCoupons();
877
865
  }, [fetchCoupons]);
878
866
  return {
@@ -884,9 +872,9 @@ function useCoupons() {
884
872
  }
885
873
  function useValidateCoupon() {
886
874
  const client = useClient();
887
- const [validation, setValidation] = useState9(null);
888
- const [loading, setLoading] = useState9(false);
889
- const [error, setError] = useState9(null);
875
+ const [validation, setValidation] = useState8(null);
876
+ const [loading, setLoading] = useState8(false);
877
+ const [error, setError] = useState8(null);
890
878
  const validate = useCallback9(async (code, orderAmount) => {
891
879
  setLoading(true);
892
880
  setError(null);
@@ -917,12 +905,12 @@ function useValidateCoupon() {
917
905
  }
918
906
 
919
907
  // src/hooks/useSubscriptions.ts
920
- import { useState as useState10, useEffect as useEffect9, useCallback as useCallback10 } from "react";
908
+ import { useState as useState9, useEffect as useEffect7, useCallback as useCallback10 } from "react";
921
909
  function useSubscriptions() {
922
910
  const client = useClient();
923
- const [subscriptions, setSubscriptions] = useState10([]);
924
- const [loading, setLoading] = useState10(true);
925
- const [error, setError] = useState10(null);
911
+ const [subscriptions, setSubscriptions] = useState9([]);
912
+ const [loading, setLoading] = useState9(true);
913
+ const [error, setError] = useState9(null);
926
914
  const fetchSubscriptions = useCallback10(async () => {
927
915
  if (!client.isAuthenticated()) {
928
916
  setSubscriptions([]);
@@ -940,7 +928,7 @@ function useSubscriptions() {
940
928
  setLoading(false);
941
929
  }
942
930
  }, [client]);
943
- useEffect9(() => {
931
+ useEffect7(() => {
944
932
  fetchSubscriptions();
945
933
  }, [fetchSubscriptions]);
946
934
  const activeSubscription = subscriptions.find((s) => s.is_active) ?? null;
@@ -956,9 +944,9 @@ function useSubscriptions() {
956
944
  }
957
945
  function useSubscription(id) {
958
946
  const client = useClient();
959
- const [subscription, setSubscription] = useState10(null);
960
- const [loading, setLoading] = useState10(true);
961
- const [error, setError] = useState10(null);
947
+ const [subscription, setSubscription] = useState9(null);
948
+ const [loading, setLoading] = useState9(true);
949
+ const [error, setError] = useState9(null);
962
950
  const fetchSubscription = useCallback10(async () => {
963
951
  setLoading(true);
964
952
  setError(null);
@@ -971,7 +959,7 @@ function useSubscription(id) {
971
959
  setLoading(false);
972
960
  }
973
961
  }, [client, id]);
974
- useEffect9(() => {
962
+ useEffect7(() => {
975
963
  fetchSubscription();
976
964
  }, [fetchSubscription]);
977
965
  const cancel = useCallback10(async (immediately = false) => {
@@ -1001,8 +989,8 @@ function useSubscription(id) {
1001
989
  }
1002
990
  function useCreateSubscription() {
1003
991
  const client = useClient();
1004
- const [loading, setLoading] = useState10(false);
1005
- const [error, setError] = useState10(null);
992
+ const [loading, setLoading] = useState9(false);
993
+ const [error, setError] = useState9(null);
1006
994
  const createCheckout = useCallback10(async (planId, successUrl, cancelUrl) => {
1007
995
  setLoading(true);
1008
996
  setError(null);
@@ -1058,12 +1046,12 @@ function useCreateSubscription() {
1058
1046
  }
1059
1047
 
1060
1048
  // src/hooks/useDownloads.ts
1061
- import { useState as useState11, useEffect as useEffect10, useCallback as useCallback11 } from "react";
1049
+ import { useState as useState10, useEffect as useEffect8, useCallback as useCallback11 } from "react";
1062
1050
  function useDownloads() {
1063
1051
  const client = useClient();
1064
- const [downloads, setDownloads] = useState11([]);
1065
- const [loading, setLoading] = useState11(true);
1066
- const [error, setError] = useState11(null);
1052
+ const [downloads, setDownloads] = useState10([]);
1053
+ const [loading, setLoading] = useState10(true);
1054
+ const [error, setError] = useState10(null);
1067
1055
  const fetchDownloads = useCallback11(async () => {
1068
1056
  if (!client.isAuthenticated()) {
1069
1057
  setDownloads([]);
@@ -1081,7 +1069,7 @@ function useDownloads() {
1081
1069
  setLoading(false);
1082
1070
  }
1083
1071
  }, [client]);
1084
- useEffect10(() => {
1072
+ useEffect8(() => {
1085
1073
  fetchDownloads();
1086
1074
  }, [fetchDownloads]);
1087
1075
  const getDownloadUrl = useCallback11((token) => {
@@ -1101,9 +1089,9 @@ function useDownloads() {
1101
1089
  }
1102
1090
  function useOrderDownloads(orderNumber) {
1103
1091
  const client = useClient();
1104
- const [downloads, setDownloads] = useState11([]);
1105
- const [loading, setLoading] = useState11(true);
1106
- const [error, setError] = useState11(null);
1092
+ const [downloads, setDownloads] = useState10([]);
1093
+ const [loading, setLoading] = useState10(true);
1094
+ const [error, setError] = useState10(null);
1107
1095
  const fetchDownloads = useCallback11(async () => {
1108
1096
  if (!client.isAuthenticated()) {
1109
1097
  setDownloads([]);
@@ -1121,7 +1109,7 @@ function useOrderDownloads(orderNumber) {
1121
1109
  setLoading(false);
1122
1110
  }
1123
1111
  }, [client, orderNumber]);
1124
- useEffect10(() => {
1112
+ useEffect8(() => {
1125
1113
  fetchDownloads();
1126
1114
  }, [fetchDownloads]);
1127
1115
  const getDownloadUrl = useCallback11((token) => {
@@ -1141,14 +1129,14 @@ function useOrderDownloads(orderNumber) {
1141
1129
  }
1142
1130
 
1143
1131
  // src/hooks/useReviews.ts
1144
- import { useState as useState12, useEffect as useEffect11, useCallback as useCallback12 } from "react";
1132
+ import { useState as useState11, useEffect as useEffect9, useCallback as useCallback12 } from "react";
1145
1133
  function useProductReviews(productSlug, params) {
1146
1134
  const client = useClient();
1147
- const [reviews, setReviews] = useState12([]);
1148
- const [stats, setStats] = useState12(null);
1149
- const [meta, setMeta] = useState12(null);
1150
- const [loading, setLoading] = useState12(true);
1151
- const [error, setError] = useState12(null);
1135
+ const [reviews, setReviews] = useState11([]);
1136
+ const [stats, setStats] = useState11(null);
1137
+ const [meta, setMeta] = useState11(null);
1138
+ const [loading, setLoading] = useState11(true);
1139
+ const [error, setError] = useState11(null);
1152
1140
  const fetchReviews = useCallback12(async () => {
1153
1141
  setLoading(true);
1154
1142
  setError(null);
@@ -1163,7 +1151,7 @@ function useProductReviews(productSlug, params) {
1163
1151
  setLoading(false);
1164
1152
  }
1165
1153
  }, [client, productSlug, params]);
1166
- useEffect11(() => {
1154
+ useEffect9(() => {
1167
1155
  fetchReviews();
1168
1156
  }, [fetchReviews]);
1169
1157
  return {
@@ -1177,10 +1165,10 @@ function useProductReviews(productSlug, params) {
1177
1165
  }
1178
1166
  function useCanReview(productSlug) {
1179
1167
  const client = useClient();
1180
- const [canReview, setCanReview] = useState12(false);
1181
- const [reason, setReason] = useState12(null);
1182
- const [loading, setLoading] = useState12(true);
1183
- const [error, setError] = useState12(null);
1168
+ const [canReview, setCanReview] = useState11(false);
1169
+ const [reason, setReason] = useState11(null);
1170
+ const [loading, setLoading] = useState11(true);
1171
+ const [error, setError] = useState11(null);
1184
1172
  const check = useCallback12(async () => {
1185
1173
  setLoading(true);
1186
1174
  setError(null);
@@ -1196,7 +1184,7 @@ function useCanReview(productSlug) {
1196
1184
  setLoading(false);
1197
1185
  }
1198
1186
  }, [client, productSlug]);
1199
- useEffect11(() => {
1187
+ useEffect9(() => {
1200
1188
  if (client.isAuthenticated()) {
1201
1189
  check();
1202
1190
  } else {
@@ -1215,8 +1203,8 @@ function useCanReview(productSlug) {
1215
1203
  }
1216
1204
  function useCreateReview() {
1217
1205
  const client = useClient();
1218
- const [loading, setLoading] = useState12(false);
1219
- const [error, setError] = useState12(null);
1206
+ const [loading, setLoading] = useState11(false);
1207
+ const [error, setError] = useState11(null);
1220
1208
  const createReview = useCallback12(async (productSlug, data) => {
1221
1209
  setLoading(true);
1222
1210
  setError(null);
@@ -1238,10 +1226,10 @@ function useCreateReview() {
1238
1226
  }
1239
1227
  function useMyReviews(params) {
1240
1228
  const client = useClient();
1241
- const [reviews, setReviews] = useState12([]);
1242
- const [meta, setMeta] = useState12(null);
1243
- const [loading, setLoading] = useState12(true);
1244
- const [error, setError] = useState12(null);
1229
+ const [reviews, setReviews] = useState11([]);
1230
+ const [meta, setMeta] = useState11(null);
1231
+ const [loading, setLoading] = useState11(true);
1232
+ const [error, setError] = useState11(null);
1245
1233
  const fetchReviews = useCallback12(async () => {
1246
1234
  if (!client.isAuthenticated()) {
1247
1235
  setReviews([]);
@@ -1260,7 +1248,7 @@ function useMyReviews(params) {
1260
1248
  setLoading(false);
1261
1249
  }
1262
1250
  }, [client, params]);
1263
- useEffect11(() => {
1251
+ useEffect9(() => {
1264
1252
  fetchReviews();
1265
1253
  }, [fetchReviews]);
1266
1254
  const deleteReview = useCallback12(async (reviewId) => {
@@ -1284,15 +1272,15 @@ function useMyReviews(params) {
1284
1272
  }
1285
1273
 
1286
1274
  // src/hooks/useBlog.ts
1287
- import { useState as useState13, useEffect as useEffect12, useCallback as useCallback13 } from "react";
1275
+ import { useState as useState12, useEffect as useEffect10, useCallback as useCallback13 } from "react";
1288
1276
  function useBlog(options = {}) {
1289
1277
  const { autoFetch = true, ...params } = options;
1290
1278
  const client = useClient();
1291
- const [posts, setPosts] = useState13([]);
1292
- const [meta, setMeta] = useState13(null);
1293
- const [loading, setLoading] = useState13(autoFetch);
1294
- const [error, setError] = useState13(null);
1295
- const [currentParams, setCurrentParams] = useState13(params);
1279
+ const [posts, setPosts] = useState12([]);
1280
+ const [meta, setMeta] = useState12(null);
1281
+ const [loading, setLoading] = useState12(autoFetch);
1282
+ const [error, setError] = useState12(null);
1283
+ const [currentParams, setCurrentParams] = useState12(params);
1296
1284
  const fetchPosts = useCallback13(async (fetchParams, append = false) => {
1297
1285
  setLoading(true);
1298
1286
  setError(null);
@@ -1310,7 +1298,7 @@ function useBlog(options = {}) {
1310
1298
  setLoading(false);
1311
1299
  }
1312
1300
  }, [client]);
1313
- useEffect12(() => {
1301
+ useEffect10(() => {
1314
1302
  if (autoFetch) {
1315
1303
  fetchPosts(params);
1316
1304
  }
@@ -1337,9 +1325,9 @@ function useBlog(options = {}) {
1337
1325
  }
1338
1326
  function useBlogPost(slug) {
1339
1327
  const client = useClient();
1340
- const [post, setPost] = useState13(null);
1341
- const [loading, setLoading] = useState13(true);
1342
- const [error, setError] = useState13(null);
1328
+ const [post, setPost] = useState12(null);
1329
+ const [loading, setLoading] = useState12(true);
1330
+ const [error, setError] = useState12(null);
1343
1331
  const fetchPost = useCallback13(async () => {
1344
1332
  setLoading(true);
1345
1333
  setError(null);
@@ -1352,7 +1340,7 @@ function useBlogPost(slug) {
1352
1340
  setLoading(false);
1353
1341
  }
1354
1342
  }, [client, slug]);
1355
- useEffect12(() => {
1343
+ useEffect10(() => {
1356
1344
  fetchPost();
1357
1345
  }, [fetchPost]);
1358
1346
  return {
@@ -1364,9 +1352,9 @@ function useBlogPost(slug) {
1364
1352
  }
1365
1353
  function useBlogCategories() {
1366
1354
  const client = useClient();
1367
- const [categories, setCategories] = useState13([]);
1368
- const [loading, setLoading] = useState13(true);
1369
- const [error, setError] = useState13(null);
1355
+ const [categories, setCategories] = useState12([]);
1356
+ const [loading, setLoading] = useState12(true);
1357
+ const [error, setError] = useState12(null);
1370
1358
  const fetchCategories = useCallback13(async () => {
1371
1359
  setLoading(true);
1372
1360
  setError(null);
@@ -1379,7 +1367,7 @@ function useBlogCategories() {
1379
1367
  setLoading(false);
1380
1368
  }
1381
1369
  }, [client]);
1382
- useEffect12(() => {
1370
+ useEffect10(() => {
1383
1371
  fetchCategories();
1384
1372
  }, [fetchCategories]);
1385
1373
  return {
@@ -1391,9 +1379,9 @@ function useBlogCategories() {
1391
1379
  }
1392
1380
  function useBlogTags() {
1393
1381
  const client = useClient();
1394
- const [tags, setTags] = useState13([]);
1395
- const [loading, setLoading] = useState13(true);
1396
- const [error, setError] = useState13(null);
1382
+ const [tags, setTags] = useState12([]);
1383
+ const [loading, setLoading] = useState12(true);
1384
+ const [error, setError] = useState12(null);
1397
1385
  const fetchTags = useCallback13(async () => {
1398
1386
  setLoading(true);
1399
1387
  setError(null);
@@ -1406,7 +1394,7 @@ function useBlogTags() {
1406
1394
  setLoading(false);
1407
1395
  }
1408
1396
  }, [client]);
1409
- useEffect12(() => {
1397
+ useEffect10(() => {
1410
1398
  fetchTags();
1411
1399
  }, [fetchTags]);
1412
1400
  return {
@@ -1418,9 +1406,9 @@ function useBlogTags() {
1418
1406
  }
1419
1407
  function useFeaturedBlog(limit = 5) {
1420
1408
  const client = useClient();
1421
- const [posts, setPosts] = useState13([]);
1422
- const [loading, setLoading] = useState13(true);
1423
- const [error, setError] = useState13(null);
1409
+ const [posts, setPosts] = useState12([]);
1410
+ const [loading, setLoading] = useState12(true);
1411
+ const [error, setError] = useState12(null);
1424
1412
  const fetchPosts = useCallback13(async () => {
1425
1413
  setLoading(true);
1426
1414
  setError(null);
@@ -1433,7 +1421,7 @@ function useFeaturedBlog(limit = 5) {
1433
1421
  setLoading(false);
1434
1422
  }
1435
1423
  }, [client, limit]);
1436
- useEffect12(() => {
1424
+ useEffect10(() => {
1437
1425
  fetchPosts();
1438
1426
  }, [fetchPosts]);
1439
1427
  return {
@@ -1445,10 +1433,10 @@ function useFeaturedBlog(limit = 5) {
1445
1433
  }
1446
1434
  function useBlogSearch() {
1447
1435
  const client = useClient();
1448
- const [posts, setPosts] = useState13([]);
1449
- const [meta, setMeta] = useState13(null);
1450
- const [loading, setLoading] = useState13(false);
1451
- const [error, setError] = useState13(null);
1436
+ const [posts, setPosts] = useState12([]);
1437
+ const [meta, setMeta] = useState12(null);
1438
+ const [loading, setLoading] = useState12(false);
1439
+ const [error, setError] = useState12(null);
1452
1440
  const search = useCallback13(async (query) => {
1453
1441
  setLoading(true);
1454
1442
  setError(null);
@@ -1472,12 +1460,12 @@ function useBlogSearch() {
1472
1460
  }
1473
1461
 
1474
1462
  // src/hooks/useBoards.ts
1475
- import { useState as useState14, useEffect as useEffect13, useCallback as useCallback14 } from "react";
1463
+ import { useState as useState13, useEffect as useEffect11, useCallback as useCallback14 } from "react";
1476
1464
  function useBoards(params) {
1477
1465
  const client = useClient();
1478
- const [boards, setBoards] = useState14([]);
1479
- const [loading, setLoading] = useState14(true);
1480
- const [error, setError] = useState14(null);
1466
+ const [boards, setBoards] = useState13([]);
1467
+ const [loading, setLoading] = useState13(true);
1468
+ const [error, setError] = useState13(null);
1481
1469
  const fetchBoards = useCallback14(async () => {
1482
1470
  setLoading(true);
1483
1471
  setError(null);
@@ -1490,7 +1478,7 @@ function useBoards(params) {
1490
1478
  setLoading(false);
1491
1479
  }
1492
1480
  }, [client, params]);
1493
- useEffect13(() => {
1481
+ useEffect11(() => {
1494
1482
  fetchBoards();
1495
1483
  }, [fetchBoards]);
1496
1484
  return {
@@ -1502,9 +1490,9 @@ function useBoards(params) {
1502
1490
  }
1503
1491
  function useBoard(slug) {
1504
1492
  const client = useClient();
1505
- const [board, setBoard] = useState14(null);
1506
- const [loading, setLoading] = useState14(true);
1507
- const [error, setError] = useState14(null);
1493
+ const [board, setBoard] = useState13(null);
1494
+ const [loading, setLoading] = useState13(true);
1495
+ const [error, setError] = useState13(null);
1508
1496
  const fetchBoard = useCallback14(async () => {
1509
1497
  setLoading(true);
1510
1498
  setError(null);
@@ -1517,7 +1505,7 @@ function useBoard(slug) {
1517
1505
  setLoading(false);
1518
1506
  }
1519
1507
  }, [client, slug]);
1520
- useEffect13(() => {
1508
+ useEffect11(() => {
1521
1509
  fetchBoard();
1522
1510
  }, [fetchBoard]);
1523
1511
  return {
@@ -1529,11 +1517,11 @@ function useBoard(slug) {
1529
1517
  }
1530
1518
  function useBoardPosts(boardSlug, params) {
1531
1519
  const client = useClient();
1532
- const [posts, setPosts] = useState14([]);
1533
- const [meta, setMeta] = useState14(null);
1534
- const [loading, setLoading] = useState14(true);
1535
- const [error, setError] = useState14(null);
1536
- const [currentParams, setCurrentParams] = useState14(params);
1520
+ const [posts, setPosts] = useState13([]);
1521
+ const [meta, setMeta] = useState13(null);
1522
+ const [loading, setLoading] = useState13(true);
1523
+ const [error, setError] = useState13(null);
1524
+ const [currentParams, setCurrentParams] = useState13(params);
1537
1525
  const fetchPosts = useCallback14(async (fetchParams, append = false) => {
1538
1526
  setLoading(true);
1539
1527
  setError(null);
@@ -1551,7 +1539,7 @@ function useBoardPosts(boardSlug, params) {
1551
1539
  setLoading(false);
1552
1540
  }
1553
1541
  }, [client, boardSlug]);
1554
- useEffect13(() => {
1542
+ useEffect11(() => {
1555
1543
  fetchPosts(params);
1556
1544
  }, []);
1557
1545
  const hasMore = meta ? meta.current_page < meta.last_page : false;
@@ -1576,9 +1564,9 @@ function useBoardPosts(boardSlug, params) {
1576
1564
  }
1577
1565
  function useBoardPost(postId) {
1578
1566
  const client = useClient();
1579
- const [post, setPost] = useState14(null);
1580
- const [loading, setLoading] = useState14(true);
1581
- const [error, setError] = useState14(null);
1567
+ const [post, setPost] = useState13(null);
1568
+ const [loading, setLoading] = useState13(true);
1569
+ const [error, setError] = useState13(null);
1582
1570
  const fetchPost = useCallback14(async () => {
1583
1571
  setLoading(true);
1584
1572
  setError(null);
@@ -1591,7 +1579,7 @@ function useBoardPost(postId) {
1591
1579
  setLoading(false);
1592
1580
  }
1593
1581
  }, [client, postId]);
1594
- useEffect13(() => {
1582
+ useEffect11(() => {
1595
1583
  fetchPost();
1596
1584
  }, [fetchPost]);
1597
1585
  return {
@@ -1603,8 +1591,8 @@ function useBoardPost(postId) {
1603
1591
  }
1604
1592
  function useCreateBoardPost() {
1605
1593
  const client = useClient();
1606
- const [loading, setLoading] = useState14(false);
1607
- const [error, setError] = useState14(null);
1594
+ const [loading, setLoading] = useState13(false);
1595
+ const [error, setError] = useState13(null);
1608
1596
  const createPost = useCallback14(async (data) => {
1609
1597
  setLoading(true);
1610
1598
  setError(null);
@@ -1626,14 +1614,14 @@ function useCreateBoardPost() {
1626
1614
  }
1627
1615
 
1628
1616
  // src/hooks/useComments.ts
1629
- import { useState as useState15, useEffect as useEffect14, useCallback as useCallback15 } from "react";
1617
+ import { useState as useState14, useEffect as useEffect12, useCallback as useCallback15 } from "react";
1630
1618
  function useComments(options) {
1631
1619
  const { type, target, page, per_page } = options;
1632
1620
  const client = useClient();
1633
- const [comments, setComments] = useState15([]);
1634
- const [meta, setMeta] = useState15(null);
1635
- const [loading, setLoading] = useState15(true);
1636
- const [error, setError] = useState15(null);
1621
+ const [comments, setComments] = useState14([]);
1622
+ const [meta, setMeta] = useState14(null);
1623
+ const [loading, setLoading] = useState14(true);
1624
+ const [error, setError] = useState14(null);
1637
1625
  const fetchComments = useCallback15(async () => {
1638
1626
  setLoading(true);
1639
1627
  setError(null);
@@ -1659,7 +1647,7 @@ function useComments(options) {
1659
1647
  setLoading(false);
1660
1648
  }
1661
1649
  }, [client, type, target, page, per_page]);
1662
- useEffect14(() => {
1650
+ useEffect12(() => {
1663
1651
  fetchComments();
1664
1652
  }, [fetchComments]);
1665
1653
  const createComment = useCallback15(async (data) => {
@@ -1708,14 +1696,14 @@ function useComments(options) {
1708
1696
  }
1709
1697
 
1710
1698
  // src/hooks/useForms.ts
1711
- import { useState as useState16, useEffect as useEffect15, useCallback as useCallback16 } from "react";
1699
+ import { useState as useState15, useEffect as useEffect13, useCallback as useCallback16 } from "react";
1712
1700
  function useForm(formSlug) {
1713
1701
  const client = useClient();
1714
- const [form, setForm] = useState16(null);
1715
- const [loading, setLoading] = useState16(true);
1716
- const [error, setError] = useState16(null);
1717
- const [submitting, setSubmitting] = useState16(false);
1718
- const [submitted, setSubmitted] = useState16(false);
1702
+ const [form, setForm] = useState15(null);
1703
+ const [loading, setLoading] = useState15(true);
1704
+ const [error, setError] = useState15(null);
1705
+ const [submitting, setSubmitting] = useState15(false);
1706
+ const [submitted, setSubmitted] = useState15(false);
1719
1707
  const fetchForm = useCallback16(async () => {
1720
1708
  setLoading(true);
1721
1709
  setError(null);
@@ -1728,7 +1716,7 @@ function useForm(formSlug) {
1728
1716
  setLoading(false);
1729
1717
  }
1730
1718
  }, [client, formSlug]);
1731
- useEffect15(() => {
1719
+ useEffect13(() => {
1732
1720
  fetchForm();
1733
1721
  }, [fetchForm]);
1734
1722
  const submit = useCallback16(async (data) => {
@@ -1762,12 +1750,12 @@ function useForm(formSlug) {
1762
1750
  }
1763
1751
 
1764
1752
  // src/hooks/useReservation.ts
1765
- import { useState as useState17, useEffect as useEffect16, useCallback as useCallback17 } from "react";
1753
+ import { useState as useState16, useEffect as useEffect14, useCallback as useCallback17 } from "react";
1766
1754
  function useReservationServices() {
1767
1755
  const client = useClient();
1768
- const [services, setServices] = useState17([]);
1769
- const [loading, setLoading] = useState17(true);
1770
- const [error, setError] = useState17(null);
1756
+ const [services, setServices] = useState16([]);
1757
+ const [loading, setLoading] = useState16(true);
1758
+ const [error, setError] = useState16(null);
1771
1759
  const fetchServices = useCallback17(async () => {
1772
1760
  setLoading(true);
1773
1761
  setError(null);
@@ -1780,7 +1768,7 @@ function useReservationServices() {
1780
1768
  setLoading(false);
1781
1769
  }
1782
1770
  }, [client]);
1783
- useEffect16(() => {
1771
+ useEffect14(() => {
1784
1772
  fetchServices();
1785
1773
  }, [fetchServices]);
1786
1774
  return {
@@ -1792,9 +1780,9 @@ function useReservationServices() {
1792
1780
  }
1793
1781
  function useReservationStaffs() {
1794
1782
  const client = useClient();
1795
- const [staffs, setStaffs] = useState17([]);
1796
- const [loading, setLoading] = useState17(true);
1797
- const [error, setError] = useState17(null);
1783
+ const [staffs, setStaffs] = useState16([]);
1784
+ const [loading, setLoading] = useState16(true);
1785
+ const [error, setError] = useState16(null);
1798
1786
  const fetchStaffs = useCallback17(async () => {
1799
1787
  setLoading(true);
1800
1788
  setError(null);
@@ -1807,7 +1795,7 @@ function useReservationStaffs() {
1807
1795
  setLoading(false);
1808
1796
  }
1809
1797
  }, [client]);
1810
- useEffect16(() => {
1798
+ useEffect14(() => {
1811
1799
  fetchStaffs();
1812
1800
  }, [fetchStaffs]);
1813
1801
  return {
@@ -1819,9 +1807,9 @@ function useReservationStaffs() {
1819
1807
  }
1820
1808
  function useAvailableSlots(serviceId, date, staffId) {
1821
1809
  const client = useClient();
1822
- const [slots, setSlots] = useState17([]);
1823
- const [loading, setLoading] = useState17(true);
1824
- const [error, setError] = useState17(null);
1810
+ const [slots, setSlots] = useState16([]);
1811
+ const [loading, setLoading] = useState16(true);
1812
+ const [error, setError] = useState16(null);
1825
1813
  const fetchSlots = useCallback17(async () => {
1826
1814
  if (!serviceId || !date) {
1827
1815
  setSlots([]);
@@ -1843,7 +1831,7 @@ function useAvailableSlots(serviceId, date, staffId) {
1843
1831
  setLoading(false);
1844
1832
  }
1845
1833
  }, [client, serviceId, date, staffId]);
1846
- useEffect16(() => {
1834
+ useEffect14(() => {
1847
1835
  fetchSlots();
1848
1836
  }, [fetchSlots]);
1849
1837
  return {
@@ -1855,10 +1843,10 @@ function useAvailableSlots(serviceId, date, staffId) {
1855
1843
  }
1856
1844
  function useMyReservations(params) {
1857
1845
  const client = useClient();
1858
- const [reservations, setReservations] = useState17([]);
1859
- const [meta, setMeta] = useState17(null);
1860
- const [loading, setLoading] = useState17(true);
1861
- const [error, setError] = useState17(null);
1846
+ const [reservations, setReservations] = useState16([]);
1847
+ const [meta, setMeta] = useState16(null);
1848
+ const [loading, setLoading] = useState16(true);
1849
+ const [error, setError] = useState16(null);
1862
1850
  const fetchReservations = useCallback17(async () => {
1863
1851
  if (!client.isAuthenticated()) {
1864
1852
  setReservations([]);
@@ -1877,7 +1865,7 @@ function useMyReservations(params) {
1877
1865
  setLoading(false);
1878
1866
  }
1879
1867
  }, [client, params]);
1880
- useEffect16(() => {
1868
+ useEffect14(() => {
1881
1869
  fetchReservations();
1882
1870
  }, [fetchReservations]);
1883
1871
  return {
@@ -1890,8 +1878,8 @@ function useMyReservations(params) {
1890
1878
  }
1891
1879
  function useCreateReservation() {
1892
1880
  const client = useClient();
1893
- const [loading, setLoading] = useState17(false);
1894
- const [error, setError] = useState17(null);
1881
+ const [loading, setLoading] = useState16(false);
1882
+ const [error, setError] = useState16(null);
1895
1883
  const createReservation = useCallback17(async (data) => {
1896
1884
  setLoading(true);
1897
1885
  setError(null);
@@ -1914,9 +1902,9 @@ function useCreateReservation() {
1914
1902
  }
1915
1903
  function useReservationSettings() {
1916
1904
  const client = useClient();
1917
- const [settings, setSettings] = useState17(null);
1918
- const [loading, setLoading] = useState17(true);
1919
- const [error, setError] = useState17(null);
1905
+ const [settings, setSettings] = useState16(null);
1906
+ const [loading, setLoading] = useState16(true);
1907
+ const [error, setError] = useState16(null);
1920
1908
  const fetchSettings = useCallback17(async () => {
1921
1909
  setLoading(true);
1922
1910
  setError(null);
@@ -1929,7 +1917,7 @@ function useReservationSettings() {
1929
1917
  setLoading(false);
1930
1918
  }
1931
1919
  }, [client]);
1932
- useEffect16(() => {
1920
+ useEffect14(() => {
1933
1921
  fetchSettings();
1934
1922
  }, [fetchSettings]);
1935
1923
  return {
@@ -1941,16 +1929,16 @@ function useReservationSettings() {
1941
1929
  }
1942
1930
 
1943
1931
  // src/hooks/useMedia.ts
1944
- import { useState as useState18, useEffect as useEffect17, useCallback as useCallback18 } from "react";
1932
+ import { useState as useState17, useEffect as useEffect15, useCallback as useCallback18 } from "react";
1945
1933
  function useMedia(options = {}) {
1946
1934
  const { type, page, per_page, autoFetch = true } = options;
1947
1935
  const client = useClient();
1948
- const [files, setFiles] = useState18([]);
1949
- const [meta, setMeta] = useState18(null);
1950
- const [loading, setLoading] = useState18(autoFetch);
1951
- const [error, setError] = useState18(null);
1952
- const [uploading, setUploading] = useState18(false);
1953
- const [uploadProgress, setUploadProgress] = useState18(0);
1936
+ const [files, setFiles] = useState17([]);
1937
+ const [meta, setMeta] = useState17(null);
1938
+ const [loading, setLoading] = useState17(autoFetch);
1939
+ const [error, setError] = useState17(null);
1940
+ const [uploading, setUploading] = useState17(false);
1941
+ const [uploadProgress, setUploadProgress] = useState17(0);
1954
1942
  const fetchMedia = useCallback18(async () => {
1955
1943
  if (!client.isAuthenticated()) {
1956
1944
  setFiles([]);
@@ -1969,7 +1957,7 @@ function useMedia(options = {}) {
1969
1957
  setLoading(false);
1970
1958
  }
1971
1959
  }, [client, type, page, per_page]);
1972
- useEffect17(() => {
1960
+ useEffect15(() => {
1973
1961
  if (autoFetch) {
1974
1962
  fetchMedia();
1975
1963
  }
@@ -2031,12 +2019,12 @@ function useMedia(options = {}) {
2031
2019
  }
2032
2020
 
2033
2021
  // src/hooks/useEntities.ts
2034
- import { useState as useState19, useEffect as useEffect18, useCallback as useCallback19, useMemo as useMemo2 } from "react";
2022
+ import { useState as useState18, useEffect as useEffect16, useCallback as useCallback19, useMemo as useMemo3 } from "react";
2035
2023
  function useEntities() {
2036
2024
  const client = useClient();
2037
- const [entities, setEntities] = useState19([]);
2038
- const [loading, setLoading] = useState19(true);
2039
- const [error, setError] = useState19(null);
2025
+ const [entities, setEntities] = useState18([]);
2026
+ const [loading, setLoading] = useState18(true);
2027
+ const [error, setError] = useState18(null);
2040
2028
  const fetchEntities = useCallback19(async () => {
2041
2029
  setLoading(true);
2042
2030
  setError(null);
@@ -2049,7 +2037,7 @@ function useEntities() {
2049
2037
  setLoading(false);
2050
2038
  }
2051
2039
  }, [client]);
2052
- useEffect18(() => {
2040
+ useEffect16(() => {
2053
2041
  fetchEntities();
2054
2042
  }, [fetchEntities]);
2055
2043
  return {
@@ -2061,9 +2049,9 @@ function useEntities() {
2061
2049
  }
2062
2050
  function useEntity(slug) {
2063
2051
  const client = useClient();
2064
- const [entity, setEntity] = useState19(null);
2065
- const [loading, setLoading] = useState19(true);
2066
- const [error, setError] = useState19(null);
2052
+ const [entity, setEntity] = useState18(null);
2053
+ const [loading, setLoading] = useState18(true);
2054
+ const [error, setError] = useState18(null);
2067
2055
  const fetchEntity = useCallback19(async () => {
2068
2056
  setLoading(true);
2069
2057
  setError(null);
@@ -2076,7 +2064,7 @@ function useEntity(slug) {
2076
2064
  setLoading(false);
2077
2065
  }
2078
2066
  }, [client, slug]);
2079
- useEffect18(() => {
2067
+ useEffect16(() => {
2080
2068
  fetchEntity();
2081
2069
  }, [fetchEntity]);
2082
2070
  return {
@@ -2088,11 +2076,11 @@ function useEntity(slug) {
2088
2076
  }
2089
2077
  function useEntityRecords(slug, params) {
2090
2078
  const client = useClient();
2091
- const [records, setRecords] = useState19([]);
2092
- const [meta, setMeta] = useState19(null);
2093
- const [loading, setLoading] = useState19(true);
2094
- const [error, setError] = useState19(null);
2095
- const [currentParams, setCurrentParams] = useState19(params);
2079
+ const [records, setRecords] = useState18([]);
2080
+ const [meta, setMeta] = useState18(null);
2081
+ const [loading, setLoading] = useState18(true);
2082
+ const [error, setError] = useState18(null);
2083
+ const [currentParams, setCurrentParams] = useState18(params);
2096
2084
  const fetchRecords = useCallback19(async (fetchParams, append = false) => {
2097
2085
  setLoading(true);
2098
2086
  setError(null);
@@ -2110,7 +2098,7 @@ function useEntityRecords(slug, params) {
2110
2098
  setLoading(false);
2111
2099
  }
2112
2100
  }, [client, slug]);
2113
- useEffect18(() => {
2101
+ useEffect16(() => {
2114
2102
  fetchRecords(params);
2115
2103
  }, []);
2116
2104
  const hasMore = meta ? meta.current_page < meta.last_page : false;
@@ -2152,9 +2140,9 @@ function useEntityRecords(slug, params) {
2152
2140
  }
2153
2141
  function useEntityRecord(slug, id) {
2154
2142
  const client = useClient();
2155
- const [record, setRecord] = useState19(null);
2156
- const [loading, setLoading] = useState19(true);
2157
- const [error, setError] = useState19(null);
2143
+ const [record, setRecord] = useState18(null);
2144
+ const [loading, setLoading] = useState18(true);
2145
+ const [error, setError] = useState18(null);
2158
2146
  const fetchRecord = useCallback19(async () => {
2159
2147
  setLoading(true);
2160
2148
  setError(null);
@@ -2167,7 +2155,7 @@ function useEntityRecord(slug, id) {
2167
2155
  setLoading(false);
2168
2156
  }
2169
2157
  }, [client, slug, id]);
2170
- useEffect18(() => {
2158
+ useEffect16(() => {
2171
2159
  fetchRecord();
2172
2160
  }, [fetchRecord]);
2173
2161
  const update = useCallback19(async (data) => {
@@ -2185,7 +2173,7 @@ function useEntityRecord(slug, id) {
2185
2173
  }
2186
2174
  function useTypedEntity(slug) {
2187
2175
  const client = useClient();
2188
- return useMemo2(() => ({
2176
+ return useMemo3(() => ({
2189
2177
  useRecords: (params) => {
2190
2178
  const result = useEntityRecords(slug, params);
2191
2179
  return {