@eetech-commerce/cart-react 0.5.1 → 0.5.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/README.md CHANGED
@@ -41,7 +41,7 @@ function App() {
41
41
  }
42
42
 
43
43
  function Shop() {
44
- const { data: cart, isLoading } = useCart();
44
+ const { cart, isLoading } = useCart();
45
45
  const { addToCart, isPending } = useAddToCart();
46
46
 
47
47
  if (isLoading) return <div>Loading cart...</div>;
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import * as _tanstack_query_core from '@tanstack/query-core';
1
2
  import * as _tanstack_react_query from '@tanstack/react-query';
2
3
  import { QueryClient } from '@tanstack/react-query';
3
4
  import { loadStripe } from '@stripe/stripe-js';
@@ -667,7 +668,169 @@ interface MutationCallbacks<TData = unknown, TError = Error> {
667
668
  onError?: (error: TError) => void;
668
669
  }
669
670
 
670
- declare function useCart(): _tanstack_react_query.UseQueryResult<CartResponseDto, Error>;
671
+ declare function useCart(): {
672
+ error: Error;
673
+ isError: true;
674
+ isPending: false;
675
+ isLoading: false;
676
+ isLoadingError: false;
677
+ isRefetchError: true;
678
+ isSuccess: false;
679
+ isPlaceholderData: false;
680
+ status: "error";
681
+ dataUpdatedAt: number;
682
+ errorUpdatedAt: number;
683
+ failureCount: number;
684
+ failureReason: Error | null;
685
+ errorUpdateCount: number;
686
+ isFetched: boolean;
687
+ isFetchedAfterMount: boolean;
688
+ isFetching: boolean;
689
+ isInitialLoading: boolean;
690
+ isPaused: boolean;
691
+ isRefetching: boolean;
692
+ isStale: boolean;
693
+ isEnabled: boolean;
694
+ refetch: (options?: _tanstack_query_core.RefetchOptions) => Promise<_tanstack_query_core.QueryObserverResult<CartResponseDto, Error>>;
695
+ fetchStatus: _tanstack_query_core.FetchStatus;
696
+ promise: Promise<CartResponseDto>;
697
+ cart: CartResponseDto | undefined;
698
+ } | {
699
+ error: null;
700
+ isError: false;
701
+ isPending: false;
702
+ isLoading: false;
703
+ isLoadingError: false;
704
+ isRefetchError: false;
705
+ isSuccess: true;
706
+ isPlaceholderData: false;
707
+ status: "success";
708
+ dataUpdatedAt: number;
709
+ errorUpdatedAt: number;
710
+ failureCount: number;
711
+ failureReason: Error | null;
712
+ errorUpdateCount: number;
713
+ isFetched: boolean;
714
+ isFetchedAfterMount: boolean;
715
+ isFetching: boolean;
716
+ isInitialLoading: boolean;
717
+ isPaused: boolean;
718
+ isRefetching: boolean;
719
+ isStale: boolean;
720
+ isEnabled: boolean;
721
+ refetch: (options?: _tanstack_query_core.RefetchOptions) => Promise<_tanstack_query_core.QueryObserverResult<CartResponseDto, Error>>;
722
+ fetchStatus: _tanstack_query_core.FetchStatus;
723
+ promise: Promise<CartResponseDto>;
724
+ cart: CartResponseDto | undefined;
725
+ } | {
726
+ error: Error;
727
+ isError: true;
728
+ isPending: false;
729
+ isLoading: false;
730
+ isLoadingError: true;
731
+ isRefetchError: false;
732
+ isSuccess: false;
733
+ isPlaceholderData: false;
734
+ status: "error";
735
+ dataUpdatedAt: number;
736
+ errorUpdatedAt: number;
737
+ failureCount: number;
738
+ failureReason: Error | null;
739
+ errorUpdateCount: number;
740
+ isFetched: boolean;
741
+ isFetchedAfterMount: boolean;
742
+ isFetching: boolean;
743
+ isInitialLoading: boolean;
744
+ isPaused: boolean;
745
+ isRefetching: boolean;
746
+ isStale: boolean;
747
+ isEnabled: boolean;
748
+ refetch: (options?: _tanstack_query_core.RefetchOptions) => Promise<_tanstack_query_core.QueryObserverResult<CartResponseDto, Error>>;
749
+ fetchStatus: _tanstack_query_core.FetchStatus;
750
+ promise: Promise<CartResponseDto>;
751
+ cart: CartResponseDto | undefined;
752
+ } | {
753
+ error: null;
754
+ isError: false;
755
+ isPending: true;
756
+ isLoading: true;
757
+ isLoadingError: false;
758
+ isRefetchError: false;
759
+ isSuccess: false;
760
+ isPlaceholderData: false;
761
+ status: "pending";
762
+ dataUpdatedAt: number;
763
+ errorUpdatedAt: number;
764
+ failureCount: number;
765
+ failureReason: Error | null;
766
+ errorUpdateCount: number;
767
+ isFetched: boolean;
768
+ isFetchedAfterMount: boolean;
769
+ isFetching: boolean;
770
+ isInitialLoading: boolean;
771
+ isPaused: boolean;
772
+ isRefetching: boolean;
773
+ isStale: boolean;
774
+ isEnabled: boolean;
775
+ refetch: (options?: _tanstack_query_core.RefetchOptions) => Promise<_tanstack_query_core.QueryObserverResult<CartResponseDto, Error>>;
776
+ fetchStatus: _tanstack_query_core.FetchStatus;
777
+ promise: Promise<CartResponseDto>;
778
+ cart: CartResponseDto | undefined;
779
+ } | {
780
+ error: null;
781
+ isError: false;
782
+ isPending: true;
783
+ isLoadingError: false;
784
+ isRefetchError: false;
785
+ isSuccess: false;
786
+ isPlaceholderData: false;
787
+ status: "pending";
788
+ dataUpdatedAt: number;
789
+ errorUpdatedAt: number;
790
+ failureCount: number;
791
+ failureReason: Error | null;
792
+ errorUpdateCount: number;
793
+ isFetched: boolean;
794
+ isFetchedAfterMount: boolean;
795
+ isFetching: boolean;
796
+ isLoading: boolean;
797
+ isInitialLoading: boolean;
798
+ isPaused: boolean;
799
+ isRefetching: boolean;
800
+ isStale: boolean;
801
+ isEnabled: boolean;
802
+ refetch: (options?: _tanstack_query_core.RefetchOptions) => Promise<_tanstack_query_core.QueryObserverResult<CartResponseDto, Error>>;
803
+ fetchStatus: _tanstack_query_core.FetchStatus;
804
+ promise: Promise<CartResponseDto>;
805
+ cart: CartResponseDto | undefined;
806
+ } | {
807
+ isError: false;
808
+ error: null;
809
+ isPending: false;
810
+ isLoading: false;
811
+ isLoadingError: false;
812
+ isRefetchError: false;
813
+ isSuccess: true;
814
+ isPlaceholderData: true;
815
+ status: "success";
816
+ dataUpdatedAt: number;
817
+ errorUpdatedAt: number;
818
+ failureCount: number;
819
+ failureReason: Error | null;
820
+ errorUpdateCount: number;
821
+ isFetched: boolean;
822
+ isFetchedAfterMount: boolean;
823
+ isFetching: boolean;
824
+ isInitialLoading: boolean;
825
+ isPaused: boolean;
826
+ isRefetching: boolean;
827
+ isStale: boolean;
828
+ isEnabled: boolean;
829
+ refetch: (options?: _tanstack_query_core.RefetchOptions) => Promise<_tanstack_query_core.QueryObserverResult<CartResponseDto, Error>>;
830
+ fetchStatus: _tanstack_query_core.FetchStatus;
831
+ promise: Promise<CartResponseDto>;
832
+ cart: CartResponseDto | undefined;
833
+ };
671
834
  interface CreateCartParams {
672
835
  currency?: string;
673
836
  metadata?: Record<string, unknown>;
package/dist/index.js CHANGED
@@ -1198,7 +1198,7 @@ var paymentKeys = {
1198
1198
  // src/hooks/cart.ts
1199
1199
  function useCart() {
1200
1200
  const { tenantSlug, cartSessionId, cartApiUrl } = useCartContext();
1201
- return useQuery({
1201
+ const { data, ...rest } = useQuery({
1202
1202
  ...cartControllerGetCartV1Options({
1203
1203
  baseUrl: cartApiUrl,
1204
1204
  path: {
@@ -1208,6 +1208,7 @@ function useCart() {
1208
1208
  }),
1209
1209
  enabled: !!cartSessionId
1210
1210
  });
1211
+ return { cart: data, ...rest };
1211
1212
  }
1212
1213
  function useCreateCart() {
1213
1214
  const { tenantSlug, cartApiUrl, setCartSessionId } = useCartContext();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eetech-commerce/cart-react",
3
- "version": "0.5.1",
3
+ "version": "0.5.2",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "access": "public"