@viu/emporix-sdk-react 2.2.0 → 2.4.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/hooks.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { Customer, AuthContext, Product, PaginatedItems, Category, CategoryNode, Cart, CartItemInput, CartItemUpdate, CartAddress, CartCreated, CreateCartInput, CheckoutResult, CheckoutInput, QuoteCheckoutInput, PaymentMode, PriceMatchByContextInput, PriceMatch, Media, SegmentCategoryTree, SegmentItem, Segment, PasswordChangeInput, CustomerUpdateInput, Address, AddressCreateInput, AddressUpdateInput, PasswordResetRequestInput, PasswordResetConfirmInput, Site, LegalEntity, ContactAssignment, Location, IamGroup, ContactAssignmentCreate, LegalEntityCreate, LocationCreate, LegalEntityUpdate, ContactAssignmentUpdate, LocationUpdate, OrderStatus, Order, SalesOrderPatch, Availability } from '@viu/emporix-sdk';
1
+ import { Customer, AuthContext, Product, PaginatedItems, ShoppingListItem, ShoppingListDraft, ShoppingList, Category, CategoryNode, Cart, CartItemInput, CartItemUpdate, CartAddress, CartCreated, CreateCartInput, CheckoutResult, CheckoutInput, QuoteCheckoutInput, PaymentMode, PriceMatchByContextInput, PriceMatch, Media, SegmentCategoryTree, SegmentItem, Segment, PasswordChangeInput, CustomerUpdateInput, Address, AddressCreateInput, AddressUpdateInput, PasswordResetRequestInput, PasswordResetConfirmInput, Site, LegalEntity, ContactAssignment, Location, IamGroup, ContactAssignmentCreate, LegalEntityCreate, LocationCreate, LegalEntityUpdate, ContactAssignmentUpdate, LocationUpdate, OrderStatus, Order, SalesOrderPatch, Availability, RedemptionInput, RedemptionCreated, PointsSummary, RedeemOptionList, RedeemCouponResult, RedeemMyPointsInput, ReturnCreated, ReturnInput, ReturnList, Return } from '@viu/emporix-sdk';
2
2
  import * as _tanstack_react_query from '@tanstack/react-query';
3
3
  import { UseQueryResult, UseInfiniteQueryResult, UseMutationResult } from '@tanstack/react-query';
4
4
  import { S as SiteContextValue } from './provider-BhvQWnnh.cjs';
@@ -81,6 +81,39 @@ declare function useProductsByCodes(codes: string[], options?: {
81
81
  chunkSize?: number;
82
82
  } & QueryOpts): UseQueryResult<Product[]>;
83
83
 
84
+ /** The caller's shopping lists (customer-only). Optionally filtered by name. */
85
+ declare function useShoppingLists(opts?: {
86
+ name?: string;
87
+ }): UseQueryResult<ShoppingList[]>;
88
+ /** Create a shopping list. */
89
+ declare function useCreateShoppingList(): UseMutationResult<{
90
+ id: string;
91
+ }, unknown, ShoppingListDraft>;
92
+ /** Delete a named list (or all the customer's lists when `name` is omitted). */
93
+ declare function useDeleteShoppingList(): UseMutationResult<void, unknown, {
94
+ customerId: string;
95
+ name?: string;
96
+ }>;
97
+ /** Add/replace an item in a list. */
98
+ declare function useAddToShoppingList(): UseMutationResult<void, unknown, {
99
+ customerId: string;
100
+ listName: string;
101
+ item: ShoppingListItem;
102
+ }>;
103
+ /** Remove an item from a list by productId. */
104
+ declare function useRemoveFromShoppingList(): UseMutationResult<void, unknown, {
105
+ customerId: string;
106
+ listName: string;
107
+ productId: string;
108
+ }>;
109
+ /** Set an item's quantity (0 removes it). */
110
+ declare function useSetShoppingListItemQuantity(): UseMutationResult<void, unknown, {
111
+ customerId: string;
112
+ listName: string;
113
+ productId: string;
114
+ quantity: number;
115
+ }>;
116
+
84
117
  type UseVariantChildrenOptions = QueryOpts & {
85
118
  pageSize?: number;
86
119
  };
@@ -579,4 +612,40 @@ interface UseAvailabilitiesOptions {
579
612
  */
580
613
  declare function useAvailabilities(productIds: string[], siteCode: string, options?: UseAvailabilitiesOptions): UseQueryResult<Availability[]>;
581
614
 
582
- export { type AddressMutationsApi, type CartMutationsApi, type CheckoutApi, type CompanySwitcherApi, type CustomerSessionApi, type PasswordResetApi, type UseAvailabilitiesOptions, type UseAvailabilityOptions, type UseCancelOrderVars, type UseMyOrdersInfiniteOptions, type UseMyOrdersOptions, type UseOrderOptions, type UseOrderTransitionVars, type UseReorderResult, type UseReorderVars, type UseUpdateSalesOrderVars, type UseVariantChildrenOptions, useActiveCart, useAddressMutations, useAssignContact, useAvailabilities, useAvailability, useCancelOrder, useCart, useCartMutations, useCategories, useCategoriesInfinite, useCategory, useCategoryTree, useChangePassword, useCheckout, useCompany, useCompanyContacts, useCompanyGroups, useCompanyLocations, useCompanySwitcher, useCreateCart, useCreateCompany, useCreateLocation, useCustomerAddresses, useCustomerSession, useDefaultSite, useDeleteCompany, useDeleteLocation, useMatchPrices, useMatchPricesChunked, useMyCompanies, useMyOrders, useMyOrdersInfinite, useMySegmentCategories, useMySegmentCategoriesInfinite, useMySegmentCategoryTree, useMySegmentItems, useMySegmentProducts, useMySegmentProductsInfinite, useMySegments, useOrder, useOrderTransition, usePasswordReset, usePaymentModes, useProduct, useProductByCode, useProductMedia, useProductSearch, useProducts, useProductsByCodes, useProductsInCategory, useProductsInCategoryInfinite, useProductsInfinite, useReorder, useSalesOrder, useSiteContext, useSites, useUnassignContact, useUpdateCompany, useUpdateContactAssignment, useUpdateCustomer, useUpdateLocation, useUpdateSalesOrder, useVariantChildren };
615
+ /** Variables for the coupon action hooks. */
616
+ interface CouponActionVars {
617
+ code: string;
618
+ redemption: RedemptionInput;
619
+ }
620
+ /**
621
+ * Check whether a coupon can be redeemed for the current shopper. Resolves on
622
+ * success (redeemable); the mutation enters `isError` when the coupon is not
623
+ * redeemable. Uses the browser auth context (customer if logged in, else
624
+ * anonymous) — never the service token.
625
+ */
626
+ declare function useValidateCoupon(): UseMutationResult<void, unknown, CouponActionVars>;
627
+ /**
628
+ * Redeem a coupon for the current shopper (creates a redemption). Invalidates
629
+ * the `["emporix", "coupons"]` cache on success.
630
+ */
631
+ declare function useRedeemCoupon(): UseMutationResult<RedemptionCreated, unknown, CouponActionVars>;
632
+
633
+ /** The signed-in customer's reward-points balance (customer-only). */
634
+ declare function useMyRewardPoints(): UseQueryResult<number>;
635
+ /** The signed-in customer's reward-points summary (customer-only). */
636
+ declare function useMyRewardPointsSummary(): UseQueryResult<PointsSummary>;
637
+ /** List redeem options (works for guests and customers). */
638
+ declare function useRedeemOptions(): UseQueryResult<RedeemOptionList>;
639
+ /** Redeem the signed-in customer's points for a coupon code. */
640
+ declare function useRedeemRewardPoints(): UseMutationResult<RedeemCouponResult, unknown, RedeemMyPointsInput>;
641
+
642
+ /** The signed-in customer's returns (customer-only). */
643
+ declare function useMyReturns(opts?: {
644
+ query?: Record<string, string | number>;
645
+ }): UseQueryResult<ReturnList>;
646
+ /** A single return by id (customer-only). */
647
+ declare function useReturn(returnId: string | undefined): UseQueryResult<Return>;
648
+ /** Create a return for the signed-in customer. Invalidates the returns list. */
649
+ declare function useCreateReturn(): UseMutationResult<ReturnCreated, unknown, ReturnInput>;
650
+
651
+ export { type AddressMutationsApi, type CartMutationsApi, type CheckoutApi, type CompanySwitcherApi, type CouponActionVars, type CustomerSessionApi, type PasswordResetApi, type UseAvailabilitiesOptions, type UseAvailabilityOptions, type UseCancelOrderVars, type UseMyOrdersInfiniteOptions, type UseMyOrdersOptions, type UseOrderOptions, type UseOrderTransitionVars, type UseReorderResult, type UseReorderVars, type UseUpdateSalesOrderVars, type UseVariantChildrenOptions, useActiveCart, useAddToShoppingList, useAddressMutations, useAssignContact, useAvailabilities, useAvailability, useCancelOrder, useCart, useCartMutations, useCategories, useCategoriesInfinite, useCategory, useCategoryTree, useChangePassword, useCheckout, useCompany, useCompanyContacts, useCompanyGroups, useCompanyLocations, useCompanySwitcher, useCreateCart, useCreateCompany, useCreateLocation, useCreateReturn, useCreateShoppingList, useCustomerAddresses, useCustomerSession, useDefaultSite, useDeleteCompany, useDeleteLocation, useDeleteShoppingList, useMatchPrices, useMatchPricesChunked, useMyCompanies, useMyOrders, useMyOrdersInfinite, useMyReturns, useMyRewardPoints, useMyRewardPointsSummary, useMySegmentCategories, useMySegmentCategoriesInfinite, useMySegmentCategoryTree, useMySegmentItems, useMySegmentProducts, useMySegmentProductsInfinite, useMySegments, useOrder, useOrderTransition, usePasswordReset, usePaymentModes, useProduct, useProductByCode, useProductMedia, useProductSearch, useProducts, useProductsByCodes, useProductsInCategory, useProductsInCategoryInfinite, useProductsInfinite, useRedeemCoupon, useRedeemOptions, useRedeemRewardPoints, useRemoveFromShoppingList, useReorder, useReturn, useSalesOrder, useSetShoppingListItemQuantity, useShoppingLists, useSiteContext, useSites, useUnassignContact, useUpdateCompany, useUpdateContactAssignment, useUpdateCustomer, useUpdateLocation, useUpdateSalesOrder, useValidateCoupon, useVariantChildren };
package/dist/hooks.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Customer, AuthContext, Product, PaginatedItems, Category, CategoryNode, Cart, CartItemInput, CartItemUpdate, CartAddress, CartCreated, CreateCartInput, CheckoutResult, CheckoutInput, QuoteCheckoutInput, PaymentMode, PriceMatchByContextInput, PriceMatch, Media, SegmentCategoryTree, SegmentItem, Segment, PasswordChangeInput, CustomerUpdateInput, Address, AddressCreateInput, AddressUpdateInput, PasswordResetRequestInput, PasswordResetConfirmInput, Site, LegalEntity, ContactAssignment, Location, IamGroup, ContactAssignmentCreate, LegalEntityCreate, LocationCreate, LegalEntityUpdate, ContactAssignmentUpdate, LocationUpdate, OrderStatus, Order, SalesOrderPatch, Availability } from '@viu/emporix-sdk';
1
+ import { Customer, AuthContext, Product, PaginatedItems, ShoppingListItem, ShoppingListDraft, ShoppingList, Category, CategoryNode, Cart, CartItemInput, CartItemUpdate, CartAddress, CartCreated, CreateCartInput, CheckoutResult, CheckoutInput, QuoteCheckoutInput, PaymentMode, PriceMatchByContextInput, PriceMatch, Media, SegmentCategoryTree, SegmentItem, Segment, PasswordChangeInput, CustomerUpdateInput, Address, AddressCreateInput, AddressUpdateInput, PasswordResetRequestInput, PasswordResetConfirmInput, Site, LegalEntity, ContactAssignment, Location, IamGroup, ContactAssignmentCreate, LegalEntityCreate, LocationCreate, LegalEntityUpdate, ContactAssignmentUpdate, LocationUpdate, OrderStatus, Order, SalesOrderPatch, Availability, RedemptionInput, RedemptionCreated, PointsSummary, RedeemOptionList, RedeemCouponResult, RedeemMyPointsInput, ReturnCreated, ReturnInput, ReturnList, Return } from '@viu/emporix-sdk';
2
2
  import * as _tanstack_react_query from '@tanstack/react-query';
3
3
  import { UseQueryResult, UseInfiniteQueryResult, UseMutationResult } from '@tanstack/react-query';
4
4
  import { S as SiteContextValue } from './provider-fvcYdqqX.js';
@@ -81,6 +81,39 @@ declare function useProductsByCodes(codes: string[], options?: {
81
81
  chunkSize?: number;
82
82
  } & QueryOpts): UseQueryResult<Product[]>;
83
83
 
84
+ /** The caller's shopping lists (customer-only). Optionally filtered by name. */
85
+ declare function useShoppingLists(opts?: {
86
+ name?: string;
87
+ }): UseQueryResult<ShoppingList[]>;
88
+ /** Create a shopping list. */
89
+ declare function useCreateShoppingList(): UseMutationResult<{
90
+ id: string;
91
+ }, unknown, ShoppingListDraft>;
92
+ /** Delete a named list (or all the customer's lists when `name` is omitted). */
93
+ declare function useDeleteShoppingList(): UseMutationResult<void, unknown, {
94
+ customerId: string;
95
+ name?: string;
96
+ }>;
97
+ /** Add/replace an item in a list. */
98
+ declare function useAddToShoppingList(): UseMutationResult<void, unknown, {
99
+ customerId: string;
100
+ listName: string;
101
+ item: ShoppingListItem;
102
+ }>;
103
+ /** Remove an item from a list by productId. */
104
+ declare function useRemoveFromShoppingList(): UseMutationResult<void, unknown, {
105
+ customerId: string;
106
+ listName: string;
107
+ productId: string;
108
+ }>;
109
+ /** Set an item's quantity (0 removes it). */
110
+ declare function useSetShoppingListItemQuantity(): UseMutationResult<void, unknown, {
111
+ customerId: string;
112
+ listName: string;
113
+ productId: string;
114
+ quantity: number;
115
+ }>;
116
+
84
117
  type UseVariantChildrenOptions = QueryOpts & {
85
118
  pageSize?: number;
86
119
  };
@@ -579,4 +612,40 @@ interface UseAvailabilitiesOptions {
579
612
  */
580
613
  declare function useAvailabilities(productIds: string[], siteCode: string, options?: UseAvailabilitiesOptions): UseQueryResult<Availability[]>;
581
614
 
582
- export { type AddressMutationsApi, type CartMutationsApi, type CheckoutApi, type CompanySwitcherApi, type CustomerSessionApi, type PasswordResetApi, type UseAvailabilitiesOptions, type UseAvailabilityOptions, type UseCancelOrderVars, type UseMyOrdersInfiniteOptions, type UseMyOrdersOptions, type UseOrderOptions, type UseOrderTransitionVars, type UseReorderResult, type UseReorderVars, type UseUpdateSalesOrderVars, type UseVariantChildrenOptions, useActiveCart, useAddressMutations, useAssignContact, useAvailabilities, useAvailability, useCancelOrder, useCart, useCartMutations, useCategories, useCategoriesInfinite, useCategory, useCategoryTree, useChangePassword, useCheckout, useCompany, useCompanyContacts, useCompanyGroups, useCompanyLocations, useCompanySwitcher, useCreateCart, useCreateCompany, useCreateLocation, useCustomerAddresses, useCustomerSession, useDefaultSite, useDeleteCompany, useDeleteLocation, useMatchPrices, useMatchPricesChunked, useMyCompanies, useMyOrders, useMyOrdersInfinite, useMySegmentCategories, useMySegmentCategoriesInfinite, useMySegmentCategoryTree, useMySegmentItems, useMySegmentProducts, useMySegmentProductsInfinite, useMySegments, useOrder, useOrderTransition, usePasswordReset, usePaymentModes, useProduct, useProductByCode, useProductMedia, useProductSearch, useProducts, useProductsByCodes, useProductsInCategory, useProductsInCategoryInfinite, useProductsInfinite, useReorder, useSalesOrder, useSiteContext, useSites, useUnassignContact, useUpdateCompany, useUpdateContactAssignment, useUpdateCustomer, useUpdateLocation, useUpdateSalesOrder, useVariantChildren };
615
+ /** Variables for the coupon action hooks. */
616
+ interface CouponActionVars {
617
+ code: string;
618
+ redemption: RedemptionInput;
619
+ }
620
+ /**
621
+ * Check whether a coupon can be redeemed for the current shopper. Resolves on
622
+ * success (redeemable); the mutation enters `isError` when the coupon is not
623
+ * redeemable. Uses the browser auth context (customer if logged in, else
624
+ * anonymous) — never the service token.
625
+ */
626
+ declare function useValidateCoupon(): UseMutationResult<void, unknown, CouponActionVars>;
627
+ /**
628
+ * Redeem a coupon for the current shopper (creates a redemption). Invalidates
629
+ * the `["emporix", "coupons"]` cache on success.
630
+ */
631
+ declare function useRedeemCoupon(): UseMutationResult<RedemptionCreated, unknown, CouponActionVars>;
632
+
633
+ /** The signed-in customer's reward-points balance (customer-only). */
634
+ declare function useMyRewardPoints(): UseQueryResult<number>;
635
+ /** The signed-in customer's reward-points summary (customer-only). */
636
+ declare function useMyRewardPointsSummary(): UseQueryResult<PointsSummary>;
637
+ /** List redeem options (works for guests and customers). */
638
+ declare function useRedeemOptions(): UseQueryResult<RedeemOptionList>;
639
+ /** Redeem the signed-in customer's points for a coupon code. */
640
+ declare function useRedeemRewardPoints(): UseMutationResult<RedeemCouponResult, unknown, RedeemMyPointsInput>;
641
+
642
+ /** The signed-in customer's returns (customer-only). */
643
+ declare function useMyReturns(opts?: {
644
+ query?: Record<string, string | number>;
645
+ }): UseQueryResult<ReturnList>;
646
+ /** A single return by id (customer-only). */
647
+ declare function useReturn(returnId: string | undefined): UseQueryResult<Return>;
648
+ /** Create a return for the signed-in customer. Invalidates the returns list. */
649
+ declare function useCreateReturn(): UseMutationResult<ReturnCreated, unknown, ReturnInput>;
650
+
651
+ export { type AddressMutationsApi, type CartMutationsApi, type CheckoutApi, type CompanySwitcherApi, type CouponActionVars, type CustomerSessionApi, type PasswordResetApi, type UseAvailabilitiesOptions, type UseAvailabilityOptions, type UseCancelOrderVars, type UseMyOrdersInfiniteOptions, type UseMyOrdersOptions, type UseOrderOptions, type UseOrderTransitionVars, type UseReorderResult, type UseReorderVars, type UseUpdateSalesOrderVars, type UseVariantChildrenOptions, useActiveCart, useAddToShoppingList, useAddressMutations, useAssignContact, useAvailabilities, useAvailability, useCancelOrder, useCart, useCartMutations, useCategories, useCategoriesInfinite, useCategory, useCategoryTree, useChangePassword, useCheckout, useCompany, useCompanyContacts, useCompanyGroups, useCompanyLocations, useCompanySwitcher, useCreateCart, useCreateCompany, useCreateLocation, useCreateReturn, useCreateShoppingList, useCustomerAddresses, useCustomerSession, useDefaultSite, useDeleteCompany, useDeleteLocation, useDeleteShoppingList, useMatchPrices, useMatchPricesChunked, useMyCompanies, useMyOrders, useMyOrdersInfinite, useMyReturns, useMyRewardPoints, useMyRewardPointsSummary, useMySegmentCategories, useMySegmentCategoriesInfinite, useMySegmentCategoryTree, useMySegmentItems, useMySegmentProducts, useMySegmentProductsInfinite, useMySegments, useOrder, useOrderTransition, usePasswordReset, usePaymentModes, useProduct, useProductByCode, useProductMedia, useProductSearch, useProducts, useProductsByCodes, useProductsInCategory, useProductsInCategoryInfinite, useProductsInfinite, useRedeemCoupon, useRedeemOptions, useRedeemRewardPoints, useRemoveFromShoppingList, useReorder, useReturn, useSalesOrder, useSetShoppingListItemQuantity, useShoppingLists, useSiteContext, useSites, useUnassignContact, useUpdateCompany, useUpdateContactAssignment, useUpdateCustomer, useUpdateLocation, useUpdateSalesOrder, useValidateCoupon, useVariantChildren };
package/dist/hooks.js CHANGED
@@ -1,4 +1,4 @@
1
- export { useActiveCart, useAddressMutations, useAssignContact, useAvailabilities, useAvailability, useCancelOrder, useCart, useCartMutations, useCategories, useCategoriesInfinite, useCategory, useCategoryTree, useChangePassword, useCheckout, useCompany, useCompanyContacts, useCompanyGroups, useCompanyLocations, useCompanySwitcher, useCreateCart, useCreateCompany, useCreateLocation, useCustomerAddresses, useCustomerSession, useDefaultSite, useDeleteCompany, useDeleteLocation, useMatchPrices, useMatchPricesChunked, useMyCompanies, useMyOrders, useMyOrdersInfinite, useMySegmentCategories, useMySegmentCategoriesInfinite, useMySegmentCategoryTree, useMySegmentItems, useMySegmentProducts, useMySegmentProductsInfinite, useMySegments, useOrder, useOrderTransition, usePasswordReset, usePaymentModes, useProduct, useProductByCode, useProductMedia, useProductSearch, useProducts, useProductsByCodes, useProductsInCategory, useProductsInCategoryInfinite, useProductsInfinite, useReorder, useSalesOrder, useSiteContext, useSites, useUnassignContact, useUpdateCompany, useUpdateContactAssignment, useUpdateCustomer, useUpdateLocation, useUpdateSalesOrder, useVariantChildren } from './chunk-P6QTUYBT.js';
1
+ export { useActiveCart, useAddToShoppingList, useAddressMutations, useAssignContact, useAvailabilities, useAvailability, useCancelOrder, useCart, useCartMutations, useCategories, useCategoriesInfinite, useCategory, useCategoryTree, useChangePassword, useCheckout, useCompany, useCompanyContacts, useCompanyGroups, useCompanyLocations, useCompanySwitcher, useCreateCart, useCreateCompany, useCreateLocation, useCreateReturn, useCreateShoppingList, useCustomerAddresses, useCustomerSession, useDefaultSite, useDeleteCompany, useDeleteLocation, useDeleteShoppingList, useMatchPrices, useMatchPricesChunked, useMyCompanies, useMyOrders, useMyOrdersInfinite, useMyReturns, useMyRewardPoints, useMyRewardPointsSummary, useMySegmentCategories, useMySegmentCategoriesInfinite, useMySegmentCategoryTree, useMySegmentItems, useMySegmentProducts, useMySegmentProductsInfinite, useMySegments, useOrder, useOrderTransition, usePasswordReset, usePaymentModes, useProduct, useProductByCode, useProductMedia, useProductSearch, useProducts, useProductsByCodes, useProductsInCategory, useProductsInCategoryInfinite, useProductsInfinite, useRedeemCoupon, useRedeemOptions, useRedeemRewardPoints, useRemoveFromShoppingList, useReorder, useReturn, useSalesOrder, useSetShoppingListItemQuantity, useShoppingLists, useSiteContext, useSites, useUnassignContact, useUpdateCompany, useUpdateContactAssignment, useUpdateCustomer, useUpdateLocation, useUpdateSalesOrder, useValidateCoupon, useVariantChildren } from './chunk-WXK2X7CM.js';
2
2
  import './chunk-D43CSHK3.js';
3
3
  import './chunk-FBQY2N7S.js';
4
4
  //# sourceMappingURL=hooks.js.map
package/dist/index.cjs CHANGED
@@ -950,6 +950,63 @@ function useProductsByCodes(codes, options = {}) {
950
950
  staleTime: 3e4
951
951
  });
952
952
  }
953
+ var SHOPPING_LIST_STALE_TIME = 3e4;
954
+ var INVALIDATE_KEY = ["emporix", "shopping-lists"];
955
+ function useShoppingLists(opts = {}) {
956
+ const { client } = useEmporix();
957
+ const ctx = useCustomerOnlyCtx();
958
+ const { siteCode } = useReadSite();
959
+ return reactQuery.useQuery({
960
+ queryKey: emporixKey("shopping-lists", [opts.name ?? null], { tenant: client.tenant, authKind: ctx.kind, siteCode }),
961
+ queryFn: () => client.shoppingLists.list(ctx, opts),
962
+ staleTime: SHOPPING_LIST_STALE_TIME
963
+ });
964
+ }
965
+ function useCreateShoppingList() {
966
+ const { client } = useEmporix();
967
+ const ctx = useCustomerOnlyCtx();
968
+ const qc = reactQuery.useQueryClient();
969
+ return reactQuery.useMutation({
970
+ mutationFn: (draft) => client.shoppingLists.create(draft, ctx),
971
+ onSuccess: () => void qc.invalidateQueries({ queryKey: INVALIDATE_KEY })
972
+ });
973
+ }
974
+ function useDeleteShoppingList() {
975
+ const { client } = useEmporix();
976
+ const ctx = useCustomerOnlyCtx();
977
+ const qc = reactQuery.useQueryClient();
978
+ return reactQuery.useMutation({
979
+ mutationFn: ({ customerId, name }) => client.shoppingLists.delete(customerId, ctx, name !== void 0 ? { name } : {}),
980
+ onSuccess: () => void qc.invalidateQueries({ queryKey: INVALIDATE_KEY })
981
+ });
982
+ }
983
+ function useAddToShoppingList() {
984
+ const { client } = useEmporix();
985
+ const ctx = useCustomerOnlyCtx();
986
+ const qc = reactQuery.useQueryClient();
987
+ return reactQuery.useMutation({
988
+ mutationFn: ({ customerId, listName, item }) => client.shoppingLists.addItem(customerId, listName, item, ctx),
989
+ onSuccess: () => void qc.invalidateQueries({ queryKey: INVALIDATE_KEY })
990
+ });
991
+ }
992
+ function useRemoveFromShoppingList() {
993
+ const { client } = useEmporix();
994
+ const ctx = useCustomerOnlyCtx();
995
+ const qc = reactQuery.useQueryClient();
996
+ return reactQuery.useMutation({
997
+ mutationFn: ({ customerId, listName, productId }) => client.shoppingLists.removeItem(customerId, listName, productId, ctx),
998
+ onSuccess: () => void qc.invalidateQueries({ queryKey: INVALIDATE_KEY })
999
+ });
1000
+ }
1001
+ function useSetShoppingListItemQuantity() {
1002
+ const { client } = useEmporix();
1003
+ const ctx = useCustomerOnlyCtx();
1004
+ const qc = reactQuery.useQueryClient();
1005
+ return reactQuery.useMutation({
1006
+ mutationFn: ({ customerId, listName, productId, quantity }) => client.shoppingLists.setItemQuantity(customerId, listName, productId, quantity, ctx),
1007
+ onSuccess: () => void qc.invalidateQueries({ queryKey: INVALIDATE_KEY })
1008
+ });
1009
+ }
953
1010
  var VARIANT_CHILDREN_STALE_TIME = 6e4;
954
1011
  function useVariantChildren(parentVariantId, options = {}) {
955
1012
  const { client } = useEmporix();
@@ -1850,6 +1907,91 @@ function useAvailabilities(productIds, siteCode, options = {}) {
1850
1907
  staleTime: AVAILABILITY_STALE_TIME2
1851
1908
  });
1852
1909
  }
1910
+ var INVALIDATE_KEY2 = ["emporix", "coupons"];
1911
+ function useValidateCoupon() {
1912
+ const { client } = useEmporix();
1913
+ const { ctx } = useReadAuth();
1914
+ return reactQuery.useMutation({
1915
+ mutationFn: ({ code, redemption }) => client.coupons.validateCoupon(code, redemption, ctx)
1916
+ });
1917
+ }
1918
+ function useRedeemCoupon() {
1919
+ const { client } = useEmporix();
1920
+ const { ctx } = useReadAuth();
1921
+ const qc = reactQuery.useQueryClient();
1922
+ return reactQuery.useMutation({
1923
+ mutationFn: ({ code, redemption }) => client.coupons.redeemCoupon(code, redemption, ctx),
1924
+ onSuccess: () => void qc.invalidateQueries({ queryKey: INVALIDATE_KEY2 })
1925
+ });
1926
+ }
1927
+ var STALE = 3e4;
1928
+ var INVALIDATE_KEY3 = ["emporix", "reward-points"];
1929
+ function useMyRewardPoints() {
1930
+ const { client } = useEmporix();
1931
+ const ctx = useCustomerOnlyCtx();
1932
+ return reactQuery.useQuery({
1933
+ queryKey: emporixKey("reward-points", ["mine"], { tenant: client.tenant, authKind: ctx.kind }),
1934
+ queryFn: () => client.rewardPoints.getMyPoints(ctx),
1935
+ staleTime: STALE
1936
+ });
1937
+ }
1938
+ function useMyRewardPointsSummary() {
1939
+ const { client } = useEmporix();
1940
+ const ctx = useCustomerOnlyCtx();
1941
+ return reactQuery.useQuery({
1942
+ queryKey: emporixKey("reward-points", ["mine", "summary"], { tenant: client.tenant, authKind: ctx.kind }),
1943
+ queryFn: () => client.rewardPoints.getMySummary(ctx),
1944
+ staleTime: STALE
1945
+ });
1946
+ }
1947
+ function useRedeemOptions() {
1948
+ const { client } = useEmporix();
1949
+ const { ctx } = useReadAuth();
1950
+ return reactQuery.useQuery({
1951
+ queryKey: emporixKey("reward-points", ["redeem-options"], { tenant: client.tenant, authKind: ctx.kind }),
1952
+ queryFn: () => client.rewardPoints.listRedeemOptions(ctx),
1953
+ staleTime: STALE
1954
+ });
1955
+ }
1956
+ function useRedeemRewardPoints() {
1957
+ const { client } = useEmporix();
1958
+ const ctx = useCustomerOnlyCtx();
1959
+ const qc = reactQuery.useQueryClient();
1960
+ return reactQuery.useMutation({
1961
+ mutationFn: (input) => client.rewardPoints.redeemMyPoints(input, ctx),
1962
+ onSuccess: () => void qc.invalidateQueries({ queryKey: INVALIDATE_KEY3 })
1963
+ });
1964
+ }
1965
+ var STALE2 = 3e4;
1966
+ var INVALIDATE_KEY4 = ["emporix", "returns"];
1967
+ function useMyReturns(opts = {}) {
1968
+ const { client } = useEmporix();
1969
+ const ctx = useCustomerOnlyCtx();
1970
+ return reactQuery.useQuery({
1971
+ queryKey: emporixKey("returns", [opts.query ?? null], { tenant: client.tenant, authKind: ctx.kind }),
1972
+ queryFn: () => client.returns.listReturns(opts.query ?? {}, ctx),
1973
+ staleTime: STALE2
1974
+ });
1975
+ }
1976
+ function useReturn(returnId) {
1977
+ const { client } = useEmporix();
1978
+ const ctx = useCustomerOnlyCtx();
1979
+ return reactQuery.useQuery({
1980
+ queryKey: emporixKey("returns", [returnId ?? null], { tenant: client.tenant, authKind: ctx.kind }),
1981
+ queryFn: () => client.returns.getReturn(returnId, ctx),
1982
+ enabled: Boolean(returnId),
1983
+ staleTime: STALE2
1984
+ });
1985
+ }
1986
+ function useCreateReturn() {
1987
+ const { client } = useEmporix();
1988
+ const ctx = useCustomerOnlyCtx();
1989
+ const qc = reactQuery.useQueryClient();
1990
+ return reactQuery.useMutation({
1991
+ mutationFn: (input) => client.returns.createReturn(input, ctx),
1992
+ onSuccess: () => void qc.invalidateQueries({ queryKey: INVALIDATE_KEY4 })
1993
+ });
1994
+ }
1853
1995
  var EmporixErrorBoundary = class extends react.Component {
1854
1996
  state = { error: null };
1855
1997
  static getDerivedStateFromError(error) {
@@ -1900,6 +2042,7 @@ exports.prefetchOrder = prefetchOrder;
1900
2042
  exports.prefetchProduct = prefetchProduct;
1901
2043
  exports.useActiveCart = useActiveCart;
1902
2044
  exports.useActiveCompany = useActiveCompany;
2045
+ exports.useAddToShoppingList = useAddToShoppingList;
1903
2046
  exports.useAddressMutations = useAddressMutations;
1904
2047
  exports.useAssignContact = useAssignContact;
1905
2048
  exports.useAvailabilities = useAvailabilities;
@@ -1921,11 +2064,14 @@ exports.useCompanySwitcher = useCompanySwitcher;
1921
2064
  exports.useCreateCart = useCreateCart;
1922
2065
  exports.useCreateCompany = useCreateCompany;
1923
2066
  exports.useCreateLocation = useCreateLocation;
2067
+ exports.useCreateReturn = useCreateReturn;
2068
+ exports.useCreateShoppingList = useCreateShoppingList;
1924
2069
  exports.useCustomerAddresses = useCustomerAddresses;
1925
2070
  exports.useCustomerSession = useCustomerSession;
1926
2071
  exports.useDefaultSite = useDefaultSite;
1927
2072
  exports.useDeleteCompany = useDeleteCompany;
1928
2073
  exports.useDeleteLocation = useDeleteLocation;
2074
+ exports.useDeleteShoppingList = useDeleteShoppingList;
1929
2075
  exports.useEmporix = useEmporix;
1930
2076
  exports.useEmporixErrorHandler = useEmporixErrorHandler;
1931
2077
  exports.useEmporixTelemetry = useEmporixTelemetry;
@@ -1934,6 +2080,9 @@ exports.useMatchPricesChunked = useMatchPricesChunked;
1934
2080
  exports.useMyCompanies = useMyCompanies;
1935
2081
  exports.useMyOrders = useMyOrders;
1936
2082
  exports.useMyOrdersInfinite = useMyOrdersInfinite;
2083
+ exports.useMyReturns = useMyReturns;
2084
+ exports.useMyRewardPoints = useMyRewardPoints;
2085
+ exports.useMyRewardPointsSummary = useMyRewardPointsSummary;
1937
2086
  exports.useMySegmentCategories = useMySegmentCategories;
1938
2087
  exports.useMySegmentCategoriesInfinite = useMySegmentCategoriesInfinite;
1939
2088
  exports.useMySegmentCategoryTree = useMySegmentCategoryTree;
@@ -1954,8 +2103,15 @@ exports.useProductsByCodes = useProductsByCodes;
1954
2103
  exports.useProductsInCategory = useProductsInCategory;
1955
2104
  exports.useProductsInCategoryInfinite = useProductsInCategoryInfinite;
1956
2105
  exports.useProductsInfinite = useProductsInfinite;
2106
+ exports.useRedeemCoupon = useRedeemCoupon;
2107
+ exports.useRedeemOptions = useRedeemOptions;
2108
+ exports.useRedeemRewardPoints = useRedeemRewardPoints;
2109
+ exports.useRemoveFromShoppingList = useRemoveFromShoppingList;
1957
2110
  exports.useReorder = useReorder;
2111
+ exports.useReturn = useReturn;
1958
2112
  exports.useSalesOrder = useSalesOrder;
2113
+ exports.useSetShoppingListItemQuantity = useSetShoppingListItemQuantity;
2114
+ exports.useShoppingLists = useShoppingLists;
1959
2115
  exports.useSiteContext = useSiteContext;
1960
2116
  exports.useSites = useSites;
1961
2117
  exports.useUnassignContact = useUnassignContact;
@@ -1964,6 +2120,7 @@ exports.useUpdateContactAssignment = useUpdateContactAssignment;
1964
2120
  exports.useUpdateCustomer = useUpdateCustomer;
1965
2121
  exports.useUpdateLocation = useUpdateLocation;
1966
2122
  exports.useUpdateSalesOrder = useUpdateSalesOrder;
2123
+ exports.useValidateCoupon = useValidateCoupon;
1967
2124
  exports.useVariantChildren = useVariantChildren;
1968
2125
  //# sourceMappingURL=index.cjs.map
1969
2126
  //# sourceMappingURL=index.cjs.map