@q2devel/q2-core 1.0.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/api/cart/Cart.service.d.ts +27 -0
- package/dist/api/cart/Cart.service.d.ts.map +1 -0
- package/dist/api/cart/Cart.service.js +205 -0
- package/dist/api/cart/CartService.types.d.ts +156 -0
- package/dist/api/cart/CartService.types.d.ts.map +1 -0
- package/dist/api/cart/CartService.types.js +1 -0
- package/dist/api/checkout/Checkout.service.d.ts +10 -0
- package/dist/api/checkout/Checkout.service.d.ts.map +1 -0
- package/dist/api/checkout/Checkout.service.js +31 -0
- package/dist/api/checkout/CheckoutService.types.d.ts +57 -0
- package/dist/api/checkout/CheckoutService.types.d.ts.map +1 -0
- package/dist/api/checkout/CheckoutService.types.js +1 -0
- package/dist/api/content/getBanners.d.ts +9 -0
- package/dist/api/content/getBanners.d.ts.map +1 -0
- package/dist/api/content/getBanners.js +32 -0
- package/dist/api/content/getBlog.d.ts +11 -0
- package/dist/api/content/getBlog.d.ts.map +1 -0
- package/dist/api/content/getBlog.js +43 -0
- package/dist/api/getTerms.d.ts +10 -0
- package/dist/api/getTerms.d.ts.map +1 -0
- package/dist/api/getTerms.js +38 -0
- package/dist/api/products/getProducts.d.ts +27 -0
- package/dist/api/products/getProducts.d.ts.map +1 -0
- package/dist/api/products/getProducts.js +125 -0
- package/dist/api/user/getUserCart.d.ts +1 -0
- package/dist/api/user/getUserCart.d.ts.map +1 -0
- package/dist/api/user/getUserCart.js +1 -0
- package/dist/api/user/resetPassword.d.ts +8 -0
- package/dist/api/user/resetPassword.d.ts.map +1 -0
- package/dist/api/user/resetPassword.js +4 -0
- package/dist/api/wishlist/Wishlist.service.d.ts +12 -0
- package/dist/api/wishlist/Wishlist.service.d.ts.map +1 -0
- package/dist/api/wishlist/Wishlist.service.js +73 -0
- package/dist/api/wishlist/WishlistService.types.d.ts +77 -0
- package/dist/api/wishlist/WishlistService.types.d.ts.map +1 -0
- package/dist/api/wishlist/WishlistService.types.js +1 -0
- package/dist/context/cart/BasketContext.d.ts +38 -0
- package/dist/context/cart/BasketContext.d.ts.map +1 -0
- package/dist/context/cart/BasketContext.js +408 -0
- package/dist/context.d.ts +14 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +1 -0
- package/dist/hooks/cart/api/useAddToCart.d.ts +4 -0
- package/dist/hooks/cart/api/useAddToCart.d.ts.map +1 -0
- package/dist/hooks/cart/api/useAddToCart.js +17 -0
- package/dist/hooks/cart/api/useClearCart.d.ts +5 -0
- package/dist/hooks/cart/api/useClearCart.d.ts.map +1 -0
- package/dist/hooks/cart/api/useClearCart.js +17 -0
- package/dist/hooks/cart/api/useDeleteCartItem.d.ts +7 -0
- package/dist/hooks/cart/api/useDeleteCartItem.d.ts.map +1 -0
- package/dist/hooks/cart/api/useDeleteCartItem.js +24 -0
- package/dist/hooks/cart/api/useGetCartToken.d.ts +177 -0
- package/dist/hooks/cart/api/useGetCartToken.d.ts.map +1 -0
- package/dist/hooks/cart/api/useGetCartToken.js +42 -0
- package/dist/hooks/cart/api/useGetCurrentCart.d.ts +9 -0
- package/dist/hooks/cart/api/useGetCurrentCart.d.ts.map +1 -0
- package/dist/hooks/cart/api/useGetCurrentCart.js +13 -0
- package/dist/hooks/cart/api/useGetUserCart.d.ts +4 -0
- package/dist/hooks/cart/api/useGetUserCart.d.ts.map +1 -0
- package/dist/hooks/cart/api/useGetUserCart.js +14 -0
- package/dist/hooks/cart/api/useUpdateCart.d.ts +10 -0
- package/dist/hooks/cart/api/useUpdateCart.d.ts.map +1 -0
- package/dist/hooks/cart/api/useUpdateCart.js +22 -0
- package/dist/hooks/checkout/useUpdateCheckout.d.ts +7 -0
- package/dist/hooks/checkout/useUpdateCheckout.d.ts.map +1 -0
- package/dist/hooks/checkout/useUpdateCheckout.js +15 -0
- package/dist/hooks/wishlist/api/useAddToWishlist.d.ts +4 -0
- package/dist/hooks/wishlist/api/useAddToWishlist.d.ts.map +1 -0
- package/dist/hooks/wishlist/api/useAddToWishlist.js +12 -0
- package/dist/hooks/wishlist/api/useCreateWishlist.d.ts +4 -0
- package/dist/hooks/wishlist/api/useCreateWishlist.d.ts.map +1 -0
- package/dist/hooks/wishlist/api/useCreateWishlist.js +15 -0
- package/dist/hooks/wishlist/api/useDeleteWishlist.d.ts +4 -0
- package/dist/hooks/wishlist/api/useDeleteWishlist.d.ts.map +1 -0
- package/dist/hooks/wishlist/api/useDeleteWishlist.js +16 -0
- package/dist/hooks/wishlist/api/useDeleteWishlistItem.d.ts +4 -0
- package/dist/hooks/wishlist/api/useDeleteWishlistItem.d.ts.map +1 -0
- package/dist/hooks/wishlist/api/useDeleteWishlistItem.js +11 -0
- package/dist/hooks/wishlist/api/useGetWishlistItems.d.ts +3 -0
- package/dist/hooks/wishlist/api/useGetWishlistItems.d.ts.map +1 -0
- package/dist/hooks/wishlist/api/useGetWishlistItems.js +9 -0
- package/dist/hooks/wishlist/api/useGetWishlistList.d.ts +4 -0
- package/dist/hooks/wishlist/api/useGetWishlistList.d.ts.map +1 -0
- package/dist/hooks/wishlist/api/useGetWishlistList.js +13 -0
- package/dist/hooks/wishlist/useWishlist.d.ts +22 -0
- package/dist/hooks/wishlist/useWishlist.d.ts.map +1 -0
- package/dist/hooks/wishlist/useWishlist.js +202 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +13 -0
- package/dist/types/ResetPassword.d.ts +8 -0
- package/dist/types/ResetPassword.d.ts.map +1 -0
- package/dist/types/ResetPassword.js +1 -0
- package/dist/types/Term.d.ts +15 -0
- package/dist/types/Term.d.ts.map +1 -0
- package/dist/types/Term.js +1 -0
- package/dist/types/content/Banners.d.ts +14 -0
- package/dist/types/content/Banners.d.ts.map +1 -0
- package/dist/types/content/Banners.js +1 -0
- package/dist/types/content/Blog.d.ts +12 -0
- package/dist/types/content/Blog.d.ts.map +1 -0
- package/dist/types/content/Blog.js +1 -0
- package/dist/types/content/ResetPassword.d.ts +8 -0
- package/dist/types/content/ResetPassword.d.ts.map +1 -0
- package/dist/types/content/ResetPassword.js +1 -0
- package/dist/types/products/Product.d.ts +69 -0
- package/dist/types/products/Product.d.ts.map +1 -0
- package/dist/types/products/Product.js +1 -0
- package/dist/types/user/ResetPassword.d.ts +8 -0
- package/dist/types/user/ResetPassword.d.ts.map +1 -0
- package/dist/types/user/ResetPassword.js +1 -0
- package/dist/types/wishlist/Wishlist.d.ts +31 -0
- package/dist/types/wishlist/Wishlist.d.ts.map +1 -0
- package/dist/types/wishlist/Wishlist.js +1 -0
- package/dist/utils/generalHelper.d.ts +12 -0
- package/dist/utils/generalHelper.d.ts.map +1 -0
- package/dist/utils/generalHelper.js +37 -0
- package/dist/utils/mapIncludedResources.d.ts +21 -0
- package/dist/utils/mapIncludedResources.d.ts.map +1 -0
- package/dist/utils/mapIncludedResources.js +37 -0
- package/package.json +31 -0
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import { CoreContext } from '../../../context';
|
|
2
|
+
export declare const useGetCartToken: (ctx: CoreContext) => {
|
|
3
|
+
cartToken: string | null;
|
|
4
|
+
createCartToken: () => string;
|
|
5
|
+
getExistingCartToken: () => string | null;
|
|
6
|
+
data: string;
|
|
7
|
+
error: Error;
|
|
8
|
+
isError: true;
|
|
9
|
+
isPending: false;
|
|
10
|
+
isLoading: false;
|
|
11
|
+
isLoadingError: false;
|
|
12
|
+
isRefetchError: true;
|
|
13
|
+
isSuccess: false;
|
|
14
|
+
isPlaceholderData: false;
|
|
15
|
+
status: "error";
|
|
16
|
+
dataUpdatedAt: number;
|
|
17
|
+
errorUpdatedAt: number;
|
|
18
|
+
failureCount: number;
|
|
19
|
+
failureReason: Error | null;
|
|
20
|
+
errorUpdateCount: number;
|
|
21
|
+
isFetched: boolean;
|
|
22
|
+
isFetchedAfterMount: boolean;
|
|
23
|
+
isFetching: boolean;
|
|
24
|
+
isInitialLoading: boolean;
|
|
25
|
+
isPaused: boolean;
|
|
26
|
+
isRefetching: boolean;
|
|
27
|
+
isStale: boolean;
|
|
28
|
+
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<string, Error>>;
|
|
29
|
+
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
30
|
+
promise: Promise<string>;
|
|
31
|
+
} | {
|
|
32
|
+
cartToken: string | null;
|
|
33
|
+
createCartToken: () => string;
|
|
34
|
+
getExistingCartToken: () => string | null;
|
|
35
|
+
data: string;
|
|
36
|
+
error: null;
|
|
37
|
+
isError: false;
|
|
38
|
+
isPending: false;
|
|
39
|
+
isLoading: false;
|
|
40
|
+
isLoadingError: false;
|
|
41
|
+
isRefetchError: false;
|
|
42
|
+
isSuccess: true;
|
|
43
|
+
isPlaceholderData: false;
|
|
44
|
+
status: "success";
|
|
45
|
+
dataUpdatedAt: number;
|
|
46
|
+
errorUpdatedAt: number;
|
|
47
|
+
failureCount: number;
|
|
48
|
+
failureReason: Error | null;
|
|
49
|
+
errorUpdateCount: number;
|
|
50
|
+
isFetched: boolean;
|
|
51
|
+
isFetchedAfterMount: boolean;
|
|
52
|
+
isFetching: boolean;
|
|
53
|
+
isInitialLoading: boolean;
|
|
54
|
+
isPaused: boolean;
|
|
55
|
+
isRefetching: boolean;
|
|
56
|
+
isStale: boolean;
|
|
57
|
+
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<string, Error>>;
|
|
58
|
+
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
59
|
+
promise: Promise<string>;
|
|
60
|
+
} | {
|
|
61
|
+
cartToken: string | null;
|
|
62
|
+
createCartToken: () => string;
|
|
63
|
+
getExistingCartToken: () => string | null;
|
|
64
|
+
data: undefined;
|
|
65
|
+
error: Error;
|
|
66
|
+
isError: true;
|
|
67
|
+
isPending: false;
|
|
68
|
+
isLoading: false;
|
|
69
|
+
isLoadingError: true;
|
|
70
|
+
isRefetchError: false;
|
|
71
|
+
isSuccess: false;
|
|
72
|
+
isPlaceholderData: false;
|
|
73
|
+
status: "error";
|
|
74
|
+
dataUpdatedAt: number;
|
|
75
|
+
errorUpdatedAt: number;
|
|
76
|
+
failureCount: number;
|
|
77
|
+
failureReason: Error | null;
|
|
78
|
+
errorUpdateCount: number;
|
|
79
|
+
isFetched: boolean;
|
|
80
|
+
isFetchedAfterMount: boolean;
|
|
81
|
+
isFetching: boolean;
|
|
82
|
+
isInitialLoading: boolean;
|
|
83
|
+
isPaused: boolean;
|
|
84
|
+
isRefetching: boolean;
|
|
85
|
+
isStale: boolean;
|
|
86
|
+
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<string, Error>>;
|
|
87
|
+
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
88
|
+
promise: Promise<string>;
|
|
89
|
+
} | {
|
|
90
|
+
cartToken: string | null;
|
|
91
|
+
createCartToken: () => string;
|
|
92
|
+
getExistingCartToken: () => string | null;
|
|
93
|
+
data: undefined;
|
|
94
|
+
error: null;
|
|
95
|
+
isError: false;
|
|
96
|
+
isPending: true;
|
|
97
|
+
isLoading: true;
|
|
98
|
+
isLoadingError: false;
|
|
99
|
+
isRefetchError: false;
|
|
100
|
+
isSuccess: false;
|
|
101
|
+
isPlaceholderData: false;
|
|
102
|
+
status: "pending";
|
|
103
|
+
dataUpdatedAt: number;
|
|
104
|
+
errorUpdatedAt: number;
|
|
105
|
+
failureCount: number;
|
|
106
|
+
failureReason: Error | null;
|
|
107
|
+
errorUpdateCount: number;
|
|
108
|
+
isFetched: boolean;
|
|
109
|
+
isFetchedAfterMount: boolean;
|
|
110
|
+
isFetching: boolean;
|
|
111
|
+
isInitialLoading: boolean;
|
|
112
|
+
isPaused: boolean;
|
|
113
|
+
isRefetching: boolean;
|
|
114
|
+
isStale: boolean;
|
|
115
|
+
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<string, Error>>;
|
|
116
|
+
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
117
|
+
promise: Promise<string>;
|
|
118
|
+
} | {
|
|
119
|
+
cartToken: string | null;
|
|
120
|
+
createCartToken: () => string;
|
|
121
|
+
getExistingCartToken: () => string | null;
|
|
122
|
+
data: undefined;
|
|
123
|
+
error: null;
|
|
124
|
+
isError: false;
|
|
125
|
+
isPending: true;
|
|
126
|
+
isLoadingError: false;
|
|
127
|
+
isRefetchError: false;
|
|
128
|
+
isSuccess: false;
|
|
129
|
+
isPlaceholderData: false;
|
|
130
|
+
status: "pending";
|
|
131
|
+
dataUpdatedAt: number;
|
|
132
|
+
errorUpdatedAt: number;
|
|
133
|
+
failureCount: number;
|
|
134
|
+
failureReason: Error | null;
|
|
135
|
+
errorUpdateCount: number;
|
|
136
|
+
isFetched: boolean;
|
|
137
|
+
isFetchedAfterMount: boolean;
|
|
138
|
+
isFetching: boolean;
|
|
139
|
+
isLoading: boolean;
|
|
140
|
+
isInitialLoading: boolean;
|
|
141
|
+
isPaused: boolean;
|
|
142
|
+
isRefetching: boolean;
|
|
143
|
+
isStale: boolean;
|
|
144
|
+
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<string, Error>>;
|
|
145
|
+
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
146
|
+
promise: Promise<string>;
|
|
147
|
+
} | {
|
|
148
|
+
cartToken: string | null;
|
|
149
|
+
createCartToken: () => string;
|
|
150
|
+
getExistingCartToken: () => string | null;
|
|
151
|
+
data: string;
|
|
152
|
+
isError: false;
|
|
153
|
+
error: null;
|
|
154
|
+
isPending: false;
|
|
155
|
+
isLoading: false;
|
|
156
|
+
isLoadingError: false;
|
|
157
|
+
isRefetchError: false;
|
|
158
|
+
isSuccess: true;
|
|
159
|
+
isPlaceholderData: true;
|
|
160
|
+
status: "success";
|
|
161
|
+
dataUpdatedAt: number;
|
|
162
|
+
errorUpdatedAt: number;
|
|
163
|
+
failureCount: number;
|
|
164
|
+
failureReason: Error | null;
|
|
165
|
+
errorUpdateCount: number;
|
|
166
|
+
isFetched: boolean;
|
|
167
|
+
isFetchedAfterMount: boolean;
|
|
168
|
+
isFetching: boolean;
|
|
169
|
+
isInitialLoading: boolean;
|
|
170
|
+
isPaused: boolean;
|
|
171
|
+
isRefetching: boolean;
|
|
172
|
+
isStale: boolean;
|
|
173
|
+
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<string, Error>>;
|
|
174
|
+
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
175
|
+
promise: Promise<string>;
|
|
176
|
+
};
|
|
177
|
+
//# sourceMappingURL=useGetCartToken.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useGetCartToken.d.ts","sourceRoot":"","sources":["../../../../hooks/cart/api/useGetCartToken.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,eAAO,MAAM,eAAe,GAAI,KAAK,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwC/C,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// src/hooks/api/cart/useGetCartToken.ts
|
|
2
|
+
import { useQuery } from '@tanstack/react-query';
|
|
3
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
4
|
+
import { getCartToken } from '../../../api/cart/Cart.service';
|
|
5
|
+
import { generateCartToken } from '../../../utils/generalHelper';
|
|
6
|
+
export const useGetCartToken = (ctx) => {
|
|
7
|
+
const [cartToken, setCartToken] = useState(null);
|
|
8
|
+
const [shouldFetchToken, setShouldFetchToken] = useState(false);
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
getExistingCartToken();
|
|
11
|
+
}, []);
|
|
12
|
+
const createCartToken = useCallback(() => {
|
|
13
|
+
const newToken = generateCartToken();
|
|
14
|
+
setCartToken(newToken);
|
|
15
|
+
localStorage.setItem('cartToken', newToken);
|
|
16
|
+
setShouldFetchToken(true);
|
|
17
|
+
return newToken;
|
|
18
|
+
}, []);
|
|
19
|
+
const getExistingCartToken = useCallback(() => {
|
|
20
|
+
const token = localStorage.getItem('cartToken');
|
|
21
|
+
if (token) {
|
|
22
|
+
setCartToken(token);
|
|
23
|
+
setShouldFetchToken(false);
|
|
24
|
+
}
|
|
25
|
+
return token;
|
|
26
|
+
}, []);
|
|
27
|
+
const cartQuery = useQuery({
|
|
28
|
+
queryKey: ['cart', cartToken],
|
|
29
|
+
queryFn: ({ signal }) => {
|
|
30
|
+
if (!cartToken)
|
|
31
|
+
throw new Error('Cart token is not available');
|
|
32
|
+
return getCartToken(ctx, { signal }); // ✅ signal vložen do configu
|
|
33
|
+
},
|
|
34
|
+
enabled: !!cartToken && shouldFetchToken,
|
|
35
|
+
});
|
|
36
|
+
return {
|
|
37
|
+
...cartQuery,
|
|
38
|
+
cartToken,
|
|
39
|
+
createCartToken,
|
|
40
|
+
getExistingCartToken,
|
|
41
|
+
};
|
|
42
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Cart } from '../../../api/cart/CartService.types';
|
|
2
|
+
import { CoreContext } from '../../../context';
|
|
3
|
+
type UseGetCartProps = {
|
|
4
|
+
activeToken?: string;
|
|
5
|
+
ctx: CoreContext;
|
|
6
|
+
};
|
|
7
|
+
export declare const useGetCurrentCart: ({ activeToken, ctx }: UseGetCartProps) => import("@tanstack/react-query").UseQueryResult<Cart, Error>;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=useGetCurrentCart.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useGetCurrentCart.d.ts","sourceRoot":"","sources":["../../../../hooks/cart/api/useGetCurrentCart.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,IAAI,EAAE,MAAM,qCAAqC,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,KAAK,eAAe,GAAG;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,GAAG,EAAE,WAAW,CAAC;CACpB,CAAA;AAED,eAAO,MAAM,iBAAiB,GAAI,sBAAmB,eAAe,gEASnE,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { useQuery } from '@tanstack/react-query';
|
|
2
|
+
import { getCurrentCart } from '../../../api/cart/Cart.service';
|
|
3
|
+
export const useGetCurrentCart = ({ activeToken, ctx }) => {
|
|
4
|
+
return useQuery({
|
|
5
|
+
queryKey: ['cart', activeToken],
|
|
6
|
+
queryFn: ({ signal }) => {
|
|
7
|
+
if (!activeToken)
|
|
8
|
+
throw new Error('Cart token is not available');
|
|
9
|
+
return getCurrentCart(ctx, activeToken, { signal });
|
|
10
|
+
},
|
|
11
|
+
enabled: !!activeToken && !ctx.userId,
|
|
12
|
+
});
|
|
13
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Cart } from '../../../api/cart/CartService.types';
|
|
2
|
+
import { CoreContext } from '../../../context';
|
|
3
|
+
export declare const useGetUserCart: (ctx: CoreContext) => import("@tanstack/react-query").UseQueryResult<Cart, Error>;
|
|
4
|
+
//# sourceMappingURL=useGetUserCart.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useGetUserCart.d.ts","sourceRoot":"","sources":["../../../../hooks/cart/api/useGetUserCart.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,qCAAqC,CAAC;AAE3D,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,eAAO,MAAM,cAAc,GAAI,KAAK,WAAW,gEAY9C,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { getUserCart } from '../../../api/cart/Cart.service';
|
|
2
|
+
import { useQuery } from '@tanstack/react-query';
|
|
3
|
+
export const useGetUserCart = (ctx) => {
|
|
4
|
+
return useQuery({
|
|
5
|
+
queryKey: ['userCart', ctx.userId],
|
|
6
|
+
queryFn: async ({ signal }) => {
|
|
7
|
+
if (!ctx.userId) {
|
|
8
|
+
throw new Error('User ID is required to get user cart');
|
|
9
|
+
}
|
|
10
|
+
return getUserCart(ctx, { signal });
|
|
11
|
+
},
|
|
12
|
+
enabled: !!ctx.userId,
|
|
13
|
+
});
|
|
14
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { UpdateCartItemRequest, CartItem } from '../../../api/cart/CartService.types';
|
|
2
|
+
import { CoreContext } from '../../../context';
|
|
3
|
+
type UpdateCartItemVariables = {
|
|
4
|
+
orderId: string;
|
|
5
|
+
itemId: string;
|
|
6
|
+
request: UpdateCartItemRequest;
|
|
7
|
+
};
|
|
8
|
+
export declare const useUpdateCartItem: (ctx: CoreContext) => import("@tanstack/react-query").UseMutationResult<CartItem, Error, UpdateCartItemVariables, unknown>;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=useUpdateCart.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useUpdateCart.d.ts","sourceRoot":"","sources":["../../../../hooks/cart/api/useUpdateCart.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,QAAQ,EAAE,MAAM,qCAAqC,CAAC;AAEtF,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,KAAK,uBAAuB,GAAG;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,qBAAqB,CAAC;CAChC,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAI,KAAK,WAAW,yGAkBjD,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { updateCartItem } from '../../../api/cart/Cart.service';
|
|
2
|
+
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
|
3
|
+
export const useUpdateCartItem = (ctx) => {
|
|
4
|
+
const queryClient = useQueryClient();
|
|
5
|
+
return useMutation({
|
|
6
|
+
mutationFn: async ({ orderId, itemId, request }) => {
|
|
7
|
+
return updateCartItem(ctx, orderId, itemId, request);
|
|
8
|
+
},
|
|
9
|
+
onSuccess: () => {
|
|
10
|
+
if (ctx.userId) {
|
|
11
|
+
queryClient.invalidateQueries({ queryKey: ['userCart', ctx.userId] });
|
|
12
|
+
}
|
|
13
|
+
else if (ctx.cartToken) {
|
|
14
|
+
queryClient.invalidateQueries({ queryKey: ['cart', ctx.cartToken] });
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
queryClient.invalidateQueries({ queryKey: ['cart'] });
|
|
18
|
+
queryClient.invalidateQueries({ queryKey: ['userCart'] });
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { CheckoutRequest, UserCheckoutRequest } from '../../api/checkout/CheckoutService.types';
|
|
2
|
+
import { CoreContext } from '../../context';
|
|
3
|
+
export declare const useUpdateCheckout: (ctx: CoreContext) => import("@tanstack/react-query").UseMutationResult<import("../../api/cart/CartService.types").Cart, Error, {
|
|
4
|
+
orderId: string;
|
|
5
|
+
request: CheckoutRequest | UserCheckoutRequest;
|
|
6
|
+
}, unknown>;
|
|
7
|
+
//# sourceMappingURL=useUpdateCheckout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useUpdateCheckout.d.ts","sourceRoot":"","sources":["../../../hooks/checkout/useUpdateCheckout.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,0CAA0C,CAAC;AAEhG,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,eAAO,MAAM,iBAAiB,GAAI,KAAK,WAAW;aAQ7B,MAAM;aACN,eAAe,GAAG,mBAAmB;WAUzD,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { updateOrderForCheckout } from '../../api/checkout/Checkout.service';
|
|
2
|
+
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
|
3
|
+
export const useUpdateCheckout = (ctx) => {
|
|
4
|
+
const queryClient = useQueryClient();
|
|
5
|
+
return useMutation({
|
|
6
|
+
mutationFn: ({ orderId, request }) => {
|
|
7
|
+
return updateOrderForCheckout(ctx, orderId, request);
|
|
8
|
+
},
|
|
9
|
+
onSuccess: () => {
|
|
10
|
+
queryClient.invalidateQueries({ queryKey: ['cart'] });
|
|
11
|
+
queryClient.invalidateQueries({ queryKey: ['userCart'] });
|
|
12
|
+
queryClient.invalidateQueries({ queryKey: ['order'] });
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { AddToWishlistRequest } from '../../../api/wishlist//WishlistService.types';
|
|
2
|
+
import { CoreContext } from '../../../context';
|
|
3
|
+
export declare const useAddToWishlist: (ctx: CoreContext) => import("@tanstack/react-query").UseMutationResult<void, Error, AddToWishlistRequest, unknown>;
|
|
4
|
+
//# sourceMappingURL=useAddToWishlist.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAddToWishlist.d.ts","sourceRoot":"","sources":["../../../../hooks/wishlist/api/useAddToWishlist.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,oBAAoB,EAAE,MAAM,8CAA8C,CAAA;AACnF,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAE9C,eAAO,MAAM,gBAAgB,GAAI,KAAK,WAAW,kGAShD,CAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// app/hooks/useAddToWishlist.ts
|
|
2
|
+
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
|
3
|
+
import { addToWishlist } from '../../../api/wishlist/Wishlist.service';
|
|
4
|
+
export const useAddToWishlist = (ctx) => {
|
|
5
|
+
const queryClient = useQueryClient();
|
|
6
|
+
return useMutation({
|
|
7
|
+
mutationFn: (request) => addToWishlist(ctx, request),
|
|
8
|
+
onSuccess: () => {
|
|
9
|
+
queryClient.invalidateQueries({ queryKey: ['wishlist'] });
|
|
10
|
+
},
|
|
11
|
+
});
|
|
12
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { CreateWishlistRequest, CreateWishlistResponse } from '../../../api/wishlist/WishlistService.types';
|
|
2
|
+
import { CoreContext } from '../../../context';
|
|
3
|
+
export declare const useCreateWishlist: (ctx: CoreContext) => import("@tanstack/react-query").UseMutationResult<CreateWishlistResponse, Error, CreateWishlistRequest, unknown>;
|
|
4
|
+
//# sourceMappingURL=useCreateWishlist.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCreateWishlist.d.ts","sourceRoot":"","sources":["../../../../hooks/wishlist/api/useCreateWishlist.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EACvB,MAAM,6CAA6C,CAAA;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAE9C,eAAO,MAAM,iBAAiB,GAAI,KAAK,WAAW,qHAcjD,CAAA"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
|
2
|
+
import { createWishlist } from '../../../api/wishlist/Wishlist.service';
|
|
3
|
+
export const useCreateWishlist = (ctx) => {
|
|
4
|
+
const queryClient = useQueryClient();
|
|
5
|
+
return useMutation({
|
|
6
|
+
mutationFn: (request) => createWishlist(ctx, request, {
|
|
7
|
+
headers: {
|
|
8
|
+
Authorization: `Bearer ${ctx.accessToken}`,
|
|
9
|
+
},
|
|
10
|
+
}),
|
|
11
|
+
onSuccess: () => {
|
|
12
|
+
queryClient.invalidateQueries({ queryKey: ['wishlist'] });
|
|
13
|
+
},
|
|
14
|
+
});
|
|
15
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { DeleteWishlistRequest } from '../../../api/wishlist/WishlistService.types';
|
|
2
|
+
import { CoreContext } from '../../../context';
|
|
3
|
+
export declare const useDeleteWishlist: (ctx: CoreContext) => import("@tanstack/react-query").UseMutationResult<void, Error, DeleteWishlistRequest, unknown>;
|
|
4
|
+
//# sourceMappingURL=useDeleteWishlist.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDeleteWishlist.d.ts","sourceRoot":"","sources":["../../../../hooks/wishlist/api/useDeleteWishlist.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,MAAM,6CAA6C,CAAA;AACnF,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAE9C,eAAO,MAAM,iBAAiB,GAAI,KAAK,WAAW,mGAejD,CAAA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
|
2
|
+
import { deleteWishlist } from '../../../api/wishlist/Wishlist.service';
|
|
3
|
+
export const useDeleteWishlist = (ctx) => {
|
|
4
|
+
const queryClient = useQueryClient();
|
|
5
|
+
return useMutation({
|
|
6
|
+
mutationFn: (request) => deleteWishlist(ctx, request, {
|
|
7
|
+
headers: {
|
|
8
|
+
Authorization: `Bearer ${ctx.accessToken}`,
|
|
9
|
+
},
|
|
10
|
+
}),
|
|
11
|
+
onSuccess: () => {
|
|
12
|
+
queryClient.invalidateQueries({ queryKey: ['wishlist'] });
|
|
13
|
+
queryClient.invalidateQueries({ queryKey: ['wishlist', 'items'] });
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { DeleteWishlistItemRequest } from '../../../api/wishlist/WishlistService.types';
|
|
2
|
+
import { CoreContext } from '../../../context';
|
|
3
|
+
export declare const useDeleteWishlistItem: (ctx: CoreContext) => import("@tanstack/react-query").UseMutationResult<void, Error, DeleteWishlistItemRequest, unknown>;
|
|
4
|
+
//# sourceMappingURL=useDeleteWishlistItem.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDeleteWishlistItem.d.ts","sourceRoot":"","sources":["../../../../hooks/wishlist/api/useDeleteWishlistItem.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,yBAAyB,EAAE,MAAM,6CAA6C,CAAA;AACvF,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAE9C,eAAO,MAAM,qBAAqB,GAAI,KAAK,WAAW,uGAUrD,CAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
|
2
|
+
import { deleteWishlistItem } from '../../../api/wishlist/Wishlist.service';
|
|
3
|
+
export const useDeleteWishlistItem = (ctx) => {
|
|
4
|
+
const queryClient = useQueryClient();
|
|
5
|
+
return useMutation({
|
|
6
|
+
mutationFn: (request) => deleteWishlistItem(ctx, request),
|
|
7
|
+
onSuccess: () => {
|
|
8
|
+
queryClient.invalidateQueries({ queryKey: ['wishlist', 'items'] });
|
|
9
|
+
},
|
|
10
|
+
});
|
|
11
|
+
};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { CoreContext } from '../../../context';
|
|
2
|
+
export declare const useGetWishlistItems: (ctx: CoreContext, wishlistIds?: string[]) => import("@tanstack/react-query").UseQueryResult<import("../../../api/wishlist/WishlistService.types").GetWishlistItemsResponse, Error>;
|
|
3
|
+
//# sourceMappingURL=useGetWishlistItems.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useGetWishlistItems.d.ts","sourceRoot":"","sources":["../../../../hooks/wishlist/api/useGetWishlistItems.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAE9C,eAAO,MAAM,mBAAmB,GAAI,KAAK,WAAW,EAAE,cAAc,MAAM,EAAE,0IAM3E,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { useQuery } from '@tanstack/react-query';
|
|
2
|
+
import { getWishlistItems } from '../../../api/wishlist/Wishlist.service';
|
|
3
|
+
export const useGetWishlistItems = (ctx, wishlistIds) => {
|
|
4
|
+
return useQuery({
|
|
5
|
+
queryKey: ['wishlist', 'items', wishlistIds],
|
|
6
|
+
queryFn: () => getWishlistItems(ctx, wishlistIds ?? []),
|
|
7
|
+
enabled: !!wishlistIds && wishlistIds.length > 0,
|
|
8
|
+
});
|
|
9
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { GetWishlistResponse } from '../../../api/wishlist/WishlistService.types';
|
|
2
|
+
import { CoreContext } from '../../../context';
|
|
3
|
+
export declare const useGetWishlistList: (ctx: CoreContext) => import("@tanstack/react-query").UseQueryResult<GetWishlistResponse, Error>;
|
|
4
|
+
//# sourceMappingURL=useGetWishlistList.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useGetWishlistList.d.ts","sourceRoot":"","sources":["../../../../hooks/wishlist/api/useGetWishlistList.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,6CAA6C,CAAA;AACjF,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAE9C,eAAO,MAAM,kBAAkB,GAAI,KAAK,WAAW,+EAWlD,CAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { useQuery } from '@tanstack/react-query';
|
|
2
|
+
import { getWishlistList } from '../../../api/wishlist/Wishlist.service';
|
|
3
|
+
export const useGetWishlistList = (ctx) => {
|
|
4
|
+
return useQuery({
|
|
5
|
+
queryKey: ['wishlist'],
|
|
6
|
+
queryFn: () => getWishlistList(ctx, {
|
|
7
|
+
headers: {
|
|
8
|
+
Authorization: ctx.accessToken ? `Bearer ${ctx.accessToken}` : undefined,
|
|
9
|
+
},
|
|
10
|
+
}),
|
|
11
|
+
enabled: !!ctx.accessToken,
|
|
12
|
+
});
|
|
13
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Product } from '../../types/products/Product';
|
|
2
|
+
import { Wishlist } from '../../api/wishlist/WishlistService.types';
|
|
3
|
+
import { ProductCardWishlist } from '../../types/wishlist/Wishlist';
|
|
4
|
+
import { CoreContext } from '../../context';
|
|
5
|
+
export declare const useWishlist: (ctx: CoreContext) => {
|
|
6
|
+
isLogged: boolean;
|
|
7
|
+
isWishlistPending: boolean;
|
|
8
|
+
isProductInFavorites: (productUuid: string) => boolean;
|
|
9
|
+
handleLikeToggle: (product: Product) => void;
|
|
10
|
+
wishlistsForDropdown: ProductCardWishlist[];
|
|
11
|
+
allWishlistsForDropdown: ProductCardWishlist[];
|
|
12
|
+
isProductInWishlist: (productUuid: string) => boolean;
|
|
13
|
+
getProductWishlistIds: (productUuid: string) => string[];
|
|
14
|
+
handleWishlistToggle: (product: Product) => void;
|
|
15
|
+
handleAddToWishlist: (product: Product, wishlistId: string) => void;
|
|
16
|
+
handleCreateWishlist: (name: string, product: Product) => void;
|
|
17
|
+
handleRemoveFromWishlist: (product: Product, wishlistId: string) => void;
|
|
18
|
+
handleDeleteWishlist: (wishlistId: string) => void;
|
|
19
|
+
favoritesWishlist: Wishlist | undefined;
|
|
20
|
+
wishlistItems: import("../../api/wishlist/WishlistService.types").WishlistItem[];
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=useWishlist.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useWishlist.d.ts","sourceRoot":"","sources":["../../../hooks/wishlist/useWishlist.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAA;AAEtD,OAAO,EAAE,QAAQ,EAAE,MAAM,0CAA0C,CAAA;AACnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAA;AAOnE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAI3C,eAAO,MAAM,WAAW,GAAI,KAAK,WAAW;;;wCAgCtB,MAAM;gCAqCV,OAAO;;;uCAvBH,MAAM;yCA2KN,MAAM,KAAG,MAAM,EAAE;oCArGrB,OAAO;mCAuDP,OAAO,cAAc,MAAM;iCAW9B,MAAM,WAAW,OAAO;wCA6CrB,OAAO,cAAc,MAAM;uCAgBxB,MAAM;;;CAyB1B,CAAA"}
|