@instockng/api-client 1.0.41 → 1.0.43
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/fetchers/carts.d.ts
CHANGED
|
@@ -5081,7 +5081,7 @@ export declare function initiateCheckout(cartId: string, data: {
|
|
|
5081
5081
|
* @param cartId - Cart UUID
|
|
5082
5082
|
* @returns Array of cart items with their discounted add-on products
|
|
5083
5083
|
*/
|
|
5084
|
-
export declare function fetchCartUpsellAddons(cartId: string): Promise<{
|
|
5084
|
+
export declare function fetchCartUpsellAddons(cartId: string, limit?: number): Promise<{
|
|
5085
5085
|
error: {
|
|
5086
5086
|
code: string;
|
|
5087
5087
|
message: string;
|
package/dist/fetchers/carts.js
CHANGED
|
@@ -196,10 +196,12 @@ export async function initiateCheckout(cartId, data) {
|
|
|
196
196
|
* @param cartId - Cart UUID
|
|
197
197
|
* @returns Array of cart items with their discounted add-on products
|
|
198
198
|
*/
|
|
199
|
-
export async function fetchCartUpsellAddons(cartId) {
|
|
199
|
+
export async function fetchCartUpsellAddons(cartId, limit) {
|
|
200
200
|
const clients = createRpcClients(API_URL);
|
|
201
201
|
const res = await clients.carts[':id']['upsell-addons'].$get({
|
|
202
202
|
param: { id: cartId },
|
|
203
|
+
// @ts-ignore - Hono RPC type inference issue with query parameters
|
|
204
|
+
query: limit ? { limit: String(limit) } : {},
|
|
203
205
|
});
|
|
204
206
|
if (!res.ok) {
|
|
205
207
|
throw new Error(`Failed to fetch upsell add-ons: ${res.statusText}`);
|
|
@@ -5685,7 +5685,7 @@ export declare function useGetCartRecommendations(cartId: string | null | undefi
|
|
|
5685
5685
|
* @param cartId - Cart UUID
|
|
5686
5686
|
* @param options - React Query options
|
|
5687
5687
|
*/
|
|
5688
|
-
export declare function useGetCartUpsellAddons(cartId: string | null | undefined, options?: Omit<UseQueryOptions<Awaited<ReturnType<typeof fetchCartUpsellAddons>>, Error>, 'queryKey' | 'queryFn'>): import("@tanstack/react-query").UseQueryResult<{
|
|
5688
|
+
export declare function useGetCartUpsellAddons(cartId: string | null | undefined, limit?: number, options?: Omit<UseQueryOptions<Awaited<ReturnType<typeof fetchCartUpsellAddons>>, Error>, 'queryKey' | 'queryFn'>): import("@tanstack/react-query").UseQueryResult<{
|
|
5689
5689
|
productId: string;
|
|
5690
5690
|
productName: string;
|
|
5691
5691
|
productThumbnailUrl: string | null;
|
|
@@ -132,11 +132,11 @@ export function useAddCartItem(cartId, options) {
|
|
|
132
132
|
mutationFn: (data) => addCartItem(cartId, data.sku, data.quantity, data.fbc, data.fbp, data.ttp, data.ttclid, data.fromUpsell, data.upsellDiscountPercent),
|
|
133
133
|
onSuccess: (...args) => {
|
|
134
134
|
const [, variables] = args;
|
|
135
|
-
queryClient.invalidateQueries({ queryKey: queryKeys.public.carts.detail(cartId) });
|
|
135
|
+
queryClient.invalidateQueries({ queryKey: queryKeys.public.carts.detail(cartId), exact: true });
|
|
136
136
|
if (variables.refreshRecommendations) {
|
|
137
|
-
queryClient.invalidateQueries({ queryKey: queryKeys.public.carts.recommendations(cartId) });
|
|
137
|
+
queryClient.invalidateQueries({ queryKey: queryKeys.public.carts.recommendations(cartId), exact: true });
|
|
138
138
|
}
|
|
139
|
-
queryClient.invalidateQueries({ queryKey: queryKeys.public.carts.upsellAddons(cartId) });
|
|
139
|
+
queryClient.invalidateQueries({ queryKey: queryKeys.public.carts.upsellAddons(cartId), exact: true });
|
|
140
140
|
options?.onSuccess?.(...args);
|
|
141
141
|
},
|
|
142
142
|
});
|
|
@@ -159,8 +159,8 @@ export function useUpdateCartItem(cartId, options) {
|
|
|
159
159
|
...options,
|
|
160
160
|
mutationFn: ({ itemId, quantity }) => updateCartItem(cartId, itemId, quantity),
|
|
161
161
|
onSuccess: (...args) => {
|
|
162
|
-
queryClient.invalidateQueries({ queryKey: queryKeys.public.carts.detail(cartId) });
|
|
163
|
-
queryClient.invalidateQueries({ queryKey: queryKeys.public.carts.upsellAddons(cartId) });
|
|
162
|
+
queryClient.invalidateQueries({ queryKey: queryKeys.public.carts.detail(cartId), exact: true });
|
|
163
|
+
queryClient.invalidateQueries({ queryKey: queryKeys.public.carts.upsellAddons(cartId), exact: true });
|
|
164
164
|
options?.onSuccess?.(...args);
|
|
165
165
|
},
|
|
166
166
|
});
|
|
@@ -183,9 +183,9 @@ export function useRemoveCartItem(cartId, options) {
|
|
|
183
183
|
...options,
|
|
184
184
|
mutationFn: (itemId) => removeCartItem(cartId, itemId),
|
|
185
185
|
onSuccess: (...args) => {
|
|
186
|
-
queryClient.invalidateQueries({ queryKey: queryKeys.public.carts.detail(cartId) });
|
|
187
|
-
queryClient.invalidateQueries({ queryKey: queryKeys.public.carts.recommendations(cartId) });
|
|
188
|
-
queryClient.invalidateQueries({ queryKey: queryKeys.public.carts.upsellAddons(cartId) });
|
|
186
|
+
queryClient.invalidateQueries({ queryKey: queryKeys.public.carts.detail(cartId), exact: true });
|
|
187
|
+
queryClient.invalidateQueries({ queryKey: queryKeys.public.carts.recommendations(cartId), exact: true });
|
|
188
|
+
queryClient.invalidateQueries({ queryKey: queryKeys.public.carts.upsellAddons(cartId), exact: true });
|
|
189
189
|
options?.onSuccess?.(...args);
|
|
190
190
|
},
|
|
191
191
|
});
|
|
@@ -267,10 +267,10 @@ export function useGetCartRecommendations(cartId, limit, options) {
|
|
|
267
267
|
* @param cartId - Cart UUID
|
|
268
268
|
* @param options - React Query options
|
|
269
269
|
*/
|
|
270
|
-
export function useGetCartUpsellAddons(cartId, options) {
|
|
270
|
+
export function useGetCartUpsellAddons(cartId, limit, options) {
|
|
271
271
|
return useQueryUnwrapped({
|
|
272
272
|
queryKey: cartId ? queryKeys.public.carts.upsellAddons(cartId) : ['public', 'carts', 'upsell-addons'],
|
|
273
|
-
queryFn: () => fetchCartUpsellAddons(cartId),
|
|
273
|
+
queryFn: () => fetchCartUpsellAddons(cartId, limit),
|
|
274
274
|
enabled: !!cartId,
|
|
275
275
|
...options,
|
|
276
276
|
});
|