@sonic-equipment/ui 121.0.0 → 123.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/checkout/adyen-payment.d.ts +21 -0
- package/dist/checkout/adyen-payment.js +165 -0
- package/dist/checkout/parse-amount.d.ts +2 -0
- package/dist/checkout/parse-amount.js +10 -0
- package/dist/checkout/payment-details.d.ts +5 -0
- package/dist/checkout/payment-details.js +21 -0
- package/dist/checkout/payment.d.ts +6 -0
- package/dist/checkout/payment.js +69 -0
- package/dist/collapsables/accordion/accordion-item.d.ts +2 -1
- package/dist/collapsables/accordion/accordion-item.js +6 -2
- package/dist/collapsables/accordion/accordion.module.css.js +1 -1
- package/dist/config.js +1 -1
- package/dist/exports.d.ts +18 -0
- package/dist/forms/field-error/field-error.d.ts +14 -1
- package/dist/forms/field-error/field-error.js +15 -1
- package/dist/forms/input/input.d.ts +1 -0
- package/dist/forms/input/input.js +2 -2
- package/dist/forms/number-field/number-field.d.ts +3 -1
- package/dist/forms/number-field/number-field.js +3 -3
- package/dist/forms/text-field/text-field.d.ts +4 -1
- package/dist/forms/text-field/text-field.js +3 -3
- package/dist/forms/textarea/textarea.d.ts +1 -0
- package/dist/forms/textarea/textarea.js +10 -10
- package/dist/icons/stroke/stroke-information-icon.js +7 -0
- package/dist/index.js +20 -2
- package/dist/intl/translation-id.d.ts +1 -1
- package/dist/pages/cart-page/cart-page.js +1 -0
- package/dist/shared/api/storefront/hooks/authentication/use-create-guest-account.d.ts +4 -0
- package/dist/shared/api/storefront/hooks/authentication/use-create-guest-account.js +21 -0
- package/dist/shared/api/storefront/hooks/authentication/use-patch-session.d.ts +4 -0
- package/dist/shared/api/storefront/hooks/authentication/use-patch-session.js +15 -0
- package/dist/shared/api/storefront/hooks/authentication/use-sign-in.js +14 -9
- package/dist/shared/api/storefront/hooks/authentication/use-sign-out.js +1 -2
- package/dist/shared/api/storefront/hooks/cart/use-add-product-to-current-cart.js +1 -7
- package/dist/shared/api/storefront/hooks/cart/use-delete-cart-line-by-id.js +1 -4
- package/dist/shared/api/storefront/hooks/cart/use-fetch-current-cart.js +3 -1
- package/dist/shared/api/storefront/hooks/cart/use-patch-cart.d.ts +3 -4
- package/dist/shared/api/storefront/hooks/cart/use-patch-cart.js +6 -8
- package/dist/shared/api/storefront/hooks/cart/use-place-order.d.ts +3 -3
- package/dist/shared/api/storefront/hooks/cart/use-place-order.js +7 -8
- package/dist/shared/api/storefront/hooks/cart/use-update-cart-line-by-id.js +1 -13
- package/dist/shared/api/storefront/hooks/customer/use-fetch-bill-to-addresses.d.ts +1 -0
- package/dist/shared/api/storefront/hooks/customer/use-fetch-bill-to-addresses.js +14 -0
- package/dist/shared/api/storefront/hooks/customer/use-fetch-ship-to-addresses.d.ts +3 -0
- package/dist/shared/api/storefront/hooks/customer/use-fetch-ship-to-addresses.js +15 -0
- package/dist/shared/api/storefront/hooks/customer/use-update-bill-to-address.d.ts +6 -0
- package/dist/shared/api/storefront/hooks/customer/use-update-bill-to-address.js +17 -0
- package/dist/shared/api/storefront/hooks/payment/use-create-adyen-session.d.ts +3 -0
- package/dist/shared/api/storefront/hooks/payment/use-create-adyen-session.js +10 -0
- package/dist/shared/api/storefront/hooks/payment/use-fetch-adyen-config.d.ts +1 -0
- package/dist/shared/api/storefront/hooks/payment/use-fetch-adyen-config.js +14 -0
- package/dist/shared/api/storefront/hooks/payment/use-invalidate-adyen.d.ts +1 -0
- package/dist/shared/api/storefront/hooks/payment/use-invalidate-adyen.js +9 -0
- package/dist/shared/api/storefront/model/shop.model.d.ts +17 -0
- package/dist/shared/api/storefront/services/cart-service.d.ts +15 -2
- package/dist/shared/api/storefront/services/cart-service.js +68 -3
- package/dist/shared/api/storefront/services/customer-service.d.ts +8 -0
- package/dist/shared/api/storefront/services/customer-service.js +31 -0
- package/dist/shared/api/storefront/services/payment-service.d.ts +8 -0
- package/dist/shared/api/storefront/services/payment-service.js +29 -0
- package/dist/shared/feature-flags/use-feature-flags.d.ts +1 -1
- package/dist/shared/feature-flags/use-feature-flags.js +1 -1
- package/dist/shared/model/address.d.ts +2 -0
- package/dist/shared/model/address.js +7 -0
- package/dist/shared/model/countries.d.ts +225 -0
- package/dist/shared/model/countries.js +260 -0
- package/dist/shared/utils/price.d.ts +38 -0
- package/dist/shared/utils/price.js +39 -1
- package/dist/shared/utils/random.d.ts +10 -0
- package/dist/shared/utils/random.js +16 -0
- package/dist/styles.css +169 -77
- package/dist/tooltip/tooltip.d.ts +9 -0
- package/dist/tooltip/tooltip.js +21 -0
- package/dist/tooltip/tooltip.module.css.js +3 -0
- package/package.json +2 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { jsx, Fragment } from 'react/jsx-runtime';
|
|
3
3
|
import { forwardRef, useRef, useCallback, useEffect } from 'react';
|
|
4
4
|
import { useContextProps, TextAreaContext, TextArea as TextArea$1 } from 'react-aria-components';
|
|
5
5
|
import styles from './textarea.module.css.js';
|
|
@@ -10,7 +10,7 @@ import styles from './textarea.module.css.js';
|
|
|
10
10
|
* The initial height is calculated based on the style of the textarea.
|
|
11
11
|
* The height is updated everytime the user types.
|
|
12
12
|
*/
|
|
13
|
-
const TextArea = forwardRef(({ autoGrow, size, ...textAreaProps }, _ref) => {
|
|
13
|
+
const TextArea = forwardRef(({ autoGrow, label, size, ...textAreaProps }, _ref) => {
|
|
14
14
|
const textAreaRef = useRef(null);
|
|
15
15
|
const [props, ref] = useContextProps(textAreaProps, textAreaRef, TextAreaContext);
|
|
16
16
|
const initialHeight = useRef(null);
|
|
@@ -40,14 +40,14 @@ const TextArea = forwardRef(({ autoGrow, size, ...textAreaProps }, _ref) => {
|
|
|
40
40
|
}
|
|
41
41
|
updateHeight();
|
|
42
42
|
}, [ref, autoGrow, updateHeight, size]);
|
|
43
|
-
return (jsx("div", { className: styles['input-container'], children: jsx(TextArea$1, { ...textAreaProps, ref: node => {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
43
|
+
return (jsx(Fragment, { children: jsx("div", { className: styles['input-container'], children: jsx(TextArea$1, { "aria-label": label, ...textAreaProps, ref: node => {
|
|
44
|
+
ref.current =
|
|
45
|
+
node;
|
|
46
|
+
return (textAreaRef.current = node);
|
|
47
|
+
}, onInput: e => {
|
|
48
|
+
updateHeight();
|
|
49
|
+
props.onInput?.(e);
|
|
50
|
+
} }) }) }));
|
|
51
51
|
});
|
|
52
52
|
TextArea.displayName = 'TextArea';
|
|
53
53
|
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
|
|
3
|
+
function StrokeInformationIcon(props) {
|
|
4
|
+
return (jsx("svg", { fill: "currentColor", height: "24", viewBox: "0 0 24 24", width: "24", xmlns: "http://www.w3.org/2000/svg", ...props, children: jsx("path", { d: "M11.9997748,2 C17.5138784,2 22,6.48597148 22,11.9997748 C22,17.5138784 17.5138784,22 11.9997748,22 C6.48597148,22 2,17.5138784 2,11.9997748 C2,6.48597148 6.48597148,2 11.9997748,2 Z M11.9997748,3.33025009 C7.21934336,3.33025009 3.33025009,7.21934336 3.33025009,11.9997748 C3.33025009,16.7803563 7.21934336,20.6697499 11.9997748,20.6697499 C16.7805065,20.6697499 20.6697499,16.7803563 20.6697499,11.9997748 C20.6697499,7.21934336 16.7805065,3.33025009 11.9997748,3.33025009 Z M12,10.0686973 C12.7347233,10.0686973 13.3300999,10.6642241 13.3300999,11.3989474 L13.3300999,16.8046369 C13.3300999,17.53921 12.7347233,18.1347368 12,18.1347368 C11.2652767,18.1347368 10.6699001,17.53921 10.6699001,16.8046369 L10.6699001,11.3989474 C10.6699001,10.6642241 11.2652767,10.0686973 12,10.0686973 Z M12.00003,5.9387205 C12.7337022,5.9387205 13.3305804,6.53559872 13.3305804,7.26927091 C13.3305804,8.0029431 12.7337022,8.59982131 12.00003,8.59982131 C11.2663578,8.59982131 10.6694796,8.0029431 10.6694796,7.26927091 C10.6694796,6.53559872 11.2663578,5.9387205 12.00003,5.9387205 Z", fillRule: "evenodd" }) }));
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export { StrokeInformationIcon };
|
package/dist/index.js
CHANGED
|
@@ -60,6 +60,10 @@ export { ProductUsp } from './carousel/usp-carousel/product-usp-carousel-slide.j
|
|
|
60
60
|
export { USPCarousel } from './carousel/usp-carousel/usp-carousel.js';
|
|
61
61
|
export { CartTotals } from './cart-totals/cart-totals.js';
|
|
62
62
|
export { CartTotalsSummary } from './cart-totals/cart-totals-summary.js';
|
|
63
|
+
export { AdyenPayment } from './checkout/adyen-payment.js';
|
|
64
|
+
export { parseAmount } from './checkout/parse-amount.js';
|
|
65
|
+
export { Payment } from './checkout/payment.js';
|
|
66
|
+
export { PaymentDetails } from './checkout/payment-details.js';
|
|
63
67
|
export { Accordion } from './collapsables/accordion/accordion.js';
|
|
64
68
|
export { AccordionItem } from './collapsables/accordion/accordion-item.js';
|
|
65
69
|
export { ShowAll } from './collapsables/show-all/show-all.js';
|
|
@@ -165,9 +169,11 @@ export { useFetchAnnouncements } from './shared/api/bff/hooks/use-fetch-announce
|
|
|
165
169
|
export { useFetchProductDetailsPageData } from './shared/api/bff/hooks/use-fetch-product-details-page-data.js';
|
|
166
170
|
export { useFetchProductListingPageData } from './shared/api/bff/hooks/use-fetch-product-listing-page-data.js';
|
|
167
171
|
export { fetchAnnouncements, fetchProductDetailsPageData, fetchProductListingPageData } from './shared/api/bff/services/bff-service.js';
|
|
172
|
+
export { useCreateGuestAccount } from './shared/api/storefront/hooks/authentication/use-create-guest-account.js';
|
|
168
173
|
export { useFetchSession } from './shared/api/storefront/hooks/authentication/use-fetch-session.js';
|
|
169
174
|
export { useInvalidateSession } from './shared/api/storefront/hooks/authentication/use-invalidate-session.js';
|
|
170
175
|
export { useIsAuthenticated } from './shared/api/storefront/hooks/authentication/use-is-authenticated.js';
|
|
176
|
+
export { usePatchSession } from './shared/api/storefront/hooks/authentication/use-patch-session.js';
|
|
171
177
|
export { useSignIn } from './shared/api/storefront/hooks/authentication/use-sign-in.js';
|
|
172
178
|
export { useSignOut } from './shared/api/storefront/hooks/authentication/use-sign-out.js';
|
|
173
179
|
export { useAddProductToCurrentCart } from './shared/api/storefront/hooks/cart/use-add-product-to-current-cart.js';
|
|
@@ -186,6 +192,12 @@ export { usePatchCart } from './shared/api/storefront/hooks/cart/use-patch-cart.
|
|
|
186
192
|
export { usePlaceOrder } from './shared/api/storefront/hooks/cart/use-place-order.js';
|
|
187
193
|
export { useSaveCartForLater } from './shared/api/storefront/hooks/cart/use-save-cart-for-later.js';
|
|
188
194
|
export { useUpdateCartLineById } from './shared/api/storefront/hooks/cart/use-update-cart-line-by-id.js';
|
|
195
|
+
export { useFetchBillToAddresses } from './shared/api/storefront/hooks/customer/use-fetch-bill-to-addresses.js';
|
|
196
|
+
export { useFetchShipToAddresses } from './shared/api/storefront/hooks/customer/use-fetch-ship-to-addresses.js';
|
|
197
|
+
export { useUpdateBillToAddress } from './shared/api/storefront/hooks/customer/use-update-bill-to-address.js';
|
|
198
|
+
export { useCreateAdyenSession } from './shared/api/storefront/hooks/payment/use-create-adyen-session.js';
|
|
199
|
+
export { useFetchAdyenConfig } from './shared/api/storefront/hooks/payment/use-fetch-adyen-config.js';
|
|
200
|
+
export { useInvalidateAdyen } from './shared/api/storefront/hooks/payment/use-invalidate-adyen.js';
|
|
189
201
|
export { useFetchTranslations } from './shared/api/storefront/hooks/translation/use-fetch-translations.js';
|
|
190
202
|
export { useFetchCountries } from './shared/api/storefront/hooks/website/use-fetch-countries.js';
|
|
191
203
|
export { useFetchCountriesLanguages } from './shared/api/storefront/hooks/website/use-fetch-countries-languages.js';
|
|
@@ -199,7 +211,9 @@ export { useDeleteWishListItemFromWishList } from './shared/api/storefront/hooks
|
|
|
199
211
|
export { useFetchAllWishListsItems } from './shared/api/storefront/hooks/wishlist/use-fetch-all-wishlists-items.js';
|
|
200
212
|
export { useFetchWishLists } from './shared/api/storefront/hooks/wishlist/use-fetch-wishlists.js';
|
|
201
213
|
export { createGuestAccount, createSession, fetchSession, patchSession, signIn, signOut } from './shared/api/storefront/services/authentication-service.js';
|
|
202
|
-
export { addProductToCurrentCart, deleteCartLineById, deleteCurrentCart, fetchCurrentCart, fetchCurrentCartLines, fetchCurrentCartProductAtp, fetchCurrentCartPromotions, fetchCurrentCheckoutAtp, patchCart, placeOrder, saveCartForLater, updateCartLineById } from './shared/api/storefront/services/cart-service.js';
|
|
214
|
+
export { addProductToCurrentCart, convertToMinorUnits, deleteCartLineById, deleteCurrentCart, fetchCurrentCart, fetchCurrentCartLines, fetchCurrentCartProductAtp, fetchCurrentCartPromotions, fetchCurrentCheckoutAtp, getAdyenPaymentDetails, patchCart, placeOrder, postAdyenPayment, saveCartForLater, updateCartLineById } from './shared/api/storefront/services/cart-service.js';
|
|
215
|
+
export { fetchBillToAddresses, fetchShipToAddresses, updateBillToAddress } from './shared/api/storefront/services/customer-service.js';
|
|
216
|
+
export { createAdyenSession, fetchAdyenConfig } from './shared/api/storefront/services/payment-service.js';
|
|
203
217
|
export { fetchTranslations } from './shared/api/storefront/services/translation-service.js';
|
|
204
218
|
export { fetchCountries, fetchCountriesLanguages, fetchCountriesWithLanguages, fetchSettings, updateLocale } from './shared/api/storefront/services/website-service.js';
|
|
205
219
|
export { WishListNameAlreadyExistsError, addWishListItemToWishList, createWishList, deleteWishList, deleteWishListItemFromWishList, getWishList, getWishListItemsByWishListId, getWishLists } from './shared/api/storefront/services/wishlist-service.js';
|
|
@@ -217,8 +231,10 @@ export { useScrollLock } from './shared/hooks/use-scroll-lock.js';
|
|
|
217
231
|
export { scrollToTop, useScrollTo } from './shared/hooks/use-scroll-to.js';
|
|
218
232
|
export { useSessionStorage } from './shared/hooks/use-session-storage.js';
|
|
219
233
|
export { useWatchCssProperty } from './shared/hooks/use-watch-css-property.js';
|
|
234
|
+
export { validateEmail, validatePhone } from './shared/model/address.js';
|
|
220
235
|
export { announcementSubTypes, announcementTypes, isAnnouncementSubtype, isAnnouncementType } from './shared/model/announcement.js';
|
|
221
236
|
export { transformAlgoliaCategoryData } from './shared/model/category.js';
|
|
237
|
+
export { countries } from './shared/model/countries.js';
|
|
222
238
|
export { currencySymbolToISO } from './shared/model/currency.js';
|
|
223
239
|
export { isProductHit, transformAlgoliaProductHitToProductHit, transformAlgoliaPromoHitToPromoHit } from './shared/model/hit.js';
|
|
224
240
|
export { isResponsiveImage } from './shared/model/image.js';
|
|
@@ -237,7 +253,8 @@ export { convertDateUnitToPluralOrSingle, getDateUnitObject } from './shared/uti
|
|
|
237
253
|
export { environment, environments } from './shared/utils/environment.js';
|
|
238
254
|
export { EventEmitter } from './shared/utils/event-emitter.js';
|
|
239
255
|
export { clone, deepMerge, isPlainObject, default as main, merge } from './shared/utils/merge.js';
|
|
240
|
-
export { formatPrice } from './shared/utils/price.js';
|
|
256
|
+
export { currencies, formatPrice, getCurrencyByCountryCode } from './shared/utils/price.js';
|
|
257
|
+
export { random, randomInt } from './shared/utils/random.js';
|
|
241
258
|
export { TIME } from './shared/utils/time.js';
|
|
242
259
|
export { createUUID } from './shared/utils/uuid.js';
|
|
243
260
|
export { wait } from './shared/utils/wait.js';
|
|
@@ -249,6 +266,7 @@ export { Toast } from './toast/toast.js';
|
|
|
249
266
|
export { ToastProvider } from './toast/toast-provider.js';
|
|
250
267
|
export { useToast } from './toast/use-toast.js';
|
|
251
268
|
export { getTokenKeyValue, getTokenValue } from './tokens/tokens.js';
|
|
269
|
+
export { Tooltip } from './tooltip/tooltip.js';
|
|
252
270
|
export { Heading, SIZES, TAGS } from './typography/heading/heading.js';
|
|
253
271
|
|
|
254
272
|
/* eslint-disable simple-import-sort/exports */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export type TranslationId = "'{0}' in all products" | "Try 'Search' and try to find the product you're looking for" | "Unfortnately, We found no articles for your search '{0}'" | ' to your account to manage your lists.' | 'Add to list' | 'Amount: {0}' | 'An unexpected error occured' | 'Are you looking for information about our service? Please visit our customer support page' | 'Are you sure you want to remove all items from your cart?' | 'Are you sure you want to remove this item from your cart?' | 'Cancel' | 'Chosen filters' | 'Clear filters' | 'Clear' | 'Click the button below to continue shopping.' | '
|
|
1
|
+
export type TranslationId = "'{0}' in all products" | "Try 'Search' and try to find the product you're looking for" | "Unfortnately, We found no articles for your search '{0}'" | ' to your account to manage your lists.' | 'Add to list' | 'Amount: {0}' | 'An unexpected error occured' | 'Are you looking for information about our service? Please visit our customer support page' | 'Are you sure you want to remove all items from your cart?' | 'Are you sure you want to remove this item from your cart?' | 'Cancel' | 'Cart' | 'Chosen filters' | 'Clear filters' | 'Clear' | 'Click the button below to continue shopping.' | 'Continue shopping' | 'Continue' | 'Cost overview' | 'Country' | 'Create new list' | 'Delivery expected in {0} {1}' | 'Double check your spelling' | 'Downloads' | 'Easily add your favorite products' | 'Excl. VAT' | 'Explore by categories' | 'Exploring our products by category' | 'Features' | 'Fulfillment method' | 'Hide filters' | 'Incl. VAT' | 'Includes' | 'Language' | 'List name already exists' | 'New list name' | 'Order number' | 'PO Number' | 'Please Sign In' | 'Popular searches' | 'Print' | 'Product Features' | 'Product' | 'Products' | 'Quick access' | 'Recent searches' | 'Recently viewed' | 'Remove all' | 'Save order' | 'Save' | 'Saved cart for later.' | 'Searching again using more general terms' | 'See all results' | 'Select a list' | 'Share your favorite list with others' | 'Shipping and handling' | 'Shop more efficiently and quicker with a favorites list' | 'Show all' | 'Show filters' | 'Show less' | 'Show' | 'Sorry, there are no products found' | 'Sorry, we could not find matches for' | 'Sort by' | 'Specifications' | 'Submit' | 'Subtotal' | 'Suggestions' | 'The product has been added to your cart.' | 'The product has been removed from your cart.' | 'The product has been updated in your cart.' | 'There are no products in your shopping cart.' | 'Total amount is' | 'Total' | 'Try another search' | 'Unable to add the product to your cart.' | 'Unable to empty your cart.' | 'Unable to remove the product from your cart.' | 'Unable to save cart for later.' | 'Unable to update the product in your cart.' | 'Use fewer keywords' | 'VAT Number' | 'VAT' | 'Welcome to Sonic Equipment. Please choose your country and language below.' | 'What are you searching for?' | 'You could try checking the spelling of your search query' | 'You could try exploring our products by category' | 'You could try' | 'You must ' | 'Your cart has been emptied.' | 'Your favorites are available on multiple devices' | 'Your shopping cart is still empty' | 'article' | 'articles' | 'create account' | 'facet.categories' | 'facet.height' | 'facet.weight' | 'of' | 'pc' | 'sign in' | 'sort.newest' | 'sort.price_asc' | 'sort.price_desc' | 'sort.relevance' | 'tag.limited' | 'tag.new' | 'validation.badInput' | 'validation.customError' | 'validation.invalid' | 'validation.patternMismatch' | 'validation.rangeOverflow' | 'validation.rangeUnderflow' | 'validation.stepMismatch' | 'validation.tooLong' | 'validation.tooShort' | 'validation.typeMismatch' | 'validation.valid' | 'validation.valueMissing';
|
|
@@ -85,6 +85,7 @@ function CartContent({ cartLines }) {
|
|
|
85
85
|
saveCartForLater.mutate({ cart: currentCart });
|
|
86
86
|
}, variant: "outline", children: jsx(FormattedMessage, { id: "Save order" }) })),
|
|
87
87
|
}, mobileSummary: jsx(CartTotalsSummary, { totalAmount: currentCart.orderGrandTotalDisplay }), overview: jsx(CartTotals, { shippingCost: currentCart.shippingAndHandlingDisplay, subtotal: currentCart.orderSubTotalDisplay, tax: currentCart.totalTaxDisplay, total: currentCart.orderGrandTotalDisplay, vatPercentage: cartLines[0]?.pricing?.vatRate || 0 }), children: jsx(OrderLineList, { onRemoveAll: () => deleteCurrentCart.mutate(), children: cartLines.map(cartLine => (jsx(ConnectedOrderLineCard, { deliveryDate: cartLine.atp?.date, href: cartLine.productUri, image: {
|
|
88
|
+
fit: 'contain',
|
|
88
89
|
image: {
|
|
89
90
|
'1': cartLine.smallImagePath,
|
|
90
91
|
'2': cartLine.smallImagePath,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { useQueryClient, useMutation } from '@tanstack/react-query';
|
|
2
|
+
import { createGuestAccount, createSession } from '../../services/authentication-service.js';
|
|
3
|
+
|
|
4
|
+
function useCreateGuestAccount() {
|
|
5
|
+
const queryClient = useQueryClient();
|
|
6
|
+
return useMutation({
|
|
7
|
+
mutationFn: async ({ defaultWarehouseId }) => {
|
|
8
|
+
const body = await createGuestAccount({ defaultWarehouseId });
|
|
9
|
+
await createSession({
|
|
10
|
+
accessToken: body.accessToken,
|
|
11
|
+
password: body.password,
|
|
12
|
+
userName: body.userName,
|
|
13
|
+
});
|
|
14
|
+
queryClient.resetQueries();
|
|
15
|
+
queryClient.clear();
|
|
16
|
+
return body;
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export { useCreateGuestAccount };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { useQueryClient, useMutation } from '@tanstack/react-query';
|
|
2
|
+
import { patchSession } from '../../services/authentication-service.js';
|
|
3
|
+
|
|
4
|
+
function usePatchSession() {
|
|
5
|
+
const queryClient = useQueryClient();
|
|
6
|
+
return useMutation({
|
|
7
|
+
mutationFn: async ({ session }) => {
|
|
8
|
+
const updatedSession = await patchSession({ session });
|
|
9
|
+
queryClient.setQueriesData({ queryKey: ['session'] }, updatedSession);
|
|
10
|
+
return updatedSession;
|
|
11
|
+
},
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export { usePatchSession };
|
|
@@ -5,15 +5,20 @@ function useSignIn() {
|
|
|
5
5
|
const queryClient = useQueryClient();
|
|
6
6
|
return useMutation({
|
|
7
7
|
mutationFn: async ({ password, userName }) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
8
|
+
try {
|
|
9
|
+
const body = await signIn({ password, userName });
|
|
10
|
+
await createSession({
|
|
11
|
+
accessToken: body.access_token,
|
|
12
|
+
password,
|
|
13
|
+
userName,
|
|
14
|
+
});
|
|
15
|
+
queryClient.resetQueries();
|
|
16
|
+
return body;
|
|
17
|
+
}
|
|
18
|
+
catch (error) {
|
|
19
|
+
queryClient.resetQueries();
|
|
20
|
+
throw error;
|
|
21
|
+
}
|
|
17
22
|
},
|
|
18
23
|
});
|
|
19
24
|
}
|
|
@@ -3,7 +3,6 @@ import { addProductToCurrentCart } from '../../services/cart-service.js';
|
|
|
3
3
|
|
|
4
4
|
function useAddProductToCurrentCart() {
|
|
5
5
|
const queryClient = useQueryClient();
|
|
6
|
-
const queryKey = ['carts', 'current', 'cartlines'];
|
|
7
6
|
return useMutation({
|
|
8
7
|
mutationFn: async ({ productId, qtyOrdered, unitOfMeasure, }) => {
|
|
9
8
|
const cartLine = await addProductToCurrentCart({
|
|
@@ -13,17 +12,12 @@ function useAddProductToCurrentCart() {
|
|
|
13
12
|
});
|
|
14
13
|
if (cartLine.productId !== productId)
|
|
15
14
|
throw new Error(`Product ${productId} has not been added to the current cart`);
|
|
16
|
-
const cartLines = queryClient.getQueryData(queryKey) ||
|
|
17
|
-
[];
|
|
18
|
-
queryClient.setQueryData(queryKey, cartLines.some(cl => cl.id === cartLine.id)
|
|
19
|
-
? cartLines.map(cl => (cl.id === cartLine.id ? cartLine : cl))
|
|
20
|
-
: [...cartLines, cartLine]);
|
|
21
15
|
// Invalidate the related current cart query cache
|
|
22
16
|
queryClient.invalidateQueries({ queryKey: ['carts', 'current'] });
|
|
23
17
|
return cartLine;
|
|
24
18
|
},
|
|
25
19
|
onError: () => {
|
|
26
|
-
queryClient.invalidateQueries({ queryKey });
|
|
20
|
+
queryClient.invalidateQueries({ queryKey: ['carts', 'current'] });
|
|
27
21
|
},
|
|
28
22
|
});
|
|
29
23
|
}
|
|
@@ -3,17 +3,14 @@ import { deleteCartLineById } from '../../services/cart-service.js';
|
|
|
3
3
|
|
|
4
4
|
function useDeleteCartLineById({ onError, onSuccess, } = {}) {
|
|
5
5
|
const queryClient = useQueryClient();
|
|
6
|
-
const queryKey = ['carts', 'current', 'cartlines'];
|
|
7
6
|
return useMutation({
|
|
8
7
|
mutationFn: async ({ cartLineId, }) => {
|
|
9
8
|
await deleteCartLineById({ cartLineId });
|
|
10
|
-
const cartLines = queryClient.getQueryData(queryKey);
|
|
11
|
-
queryClient.setQueryData(queryKey, cartLines?.filter(line => line.id !== cartLineId));
|
|
12
9
|
// Invalidate the related current cart query cache
|
|
13
10
|
queryClient.invalidateQueries({ queryKey: ['carts', 'current'] });
|
|
14
11
|
},
|
|
15
12
|
onError: () => {
|
|
16
|
-
queryClient.invalidateQueries({ queryKey });
|
|
13
|
+
queryClient.invalidateQueries({ queryKey: ['carts', 'current'] });
|
|
17
14
|
onError?.();
|
|
18
15
|
},
|
|
19
16
|
onSuccess,
|
|
@@ -6,7 +6,9 @@ function useFetchCurrentCart({ select, } = {}) {
|
|
|
6
6
|
return useQuery({
|
|
7
7
|
gcTime: 15 * TIME.MINUTE,
|
|
8
8
|
placeholderData: prev => prev,
|
|
9
|
-
queryFn:
|
|
9
|
+
queryFn: () => {
|
|
10
|
+
return fetchCurrentCart({ needFullCart: true });
|
|
11
|
+
},
|
|
10
12
|
queryKey: ['carts', 'current'],
|
|
11
13
|
retry: 3,
|
|
12
14
|
select: select || (cartModel => cartModel),
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
}, unknown>;
|
|
1
|
+
export declare function usePatchCart(): ({ cart }: {
|
|
2
|
+
cart: any;
|
|
3
|
+
}) => Promise<import("../../model/shop.model").CartModel>;
|
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
import { useQueryClient
|
|
1
|
+
import { useQueryClient } from '@tanstack/react-query';
|
|
2
2
|
import { patchCart } from '../../services/cart-service.js';
|
|
3
3
|
|
|
4
4
|
function usePatchCart() {
|
|
5
5
|
const queryClient = useQueryClient();
|
|
6
|
-
return
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
},
|
|
12
|
-
});
|
|
6
|
+
return async ({ cart }) => {
|
|
7
|
+
const updatedCart = await patchCart({ cart });
|
|
8
|
+
queryClient.setQueriesData({ queryKey: ['carts', updatedCart.id] }, { ...updatedCart, cartLines: cart.cartLines });
|
|
9
|
+
return updatedCart;
|
|
10
|
+
};
|
|
13
11
|
}
|
|
14
12
|
|
|
15
13
|
export { usePatchCart };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { CartModel } from '../../model/shop.model';
|
|
2
|
-
export declare const usePlaceOrder: () =>
|
|
3
|
-
cart:
|
|
4
|
-
}
|
|
2
|
+
export declare const usePlaceOrder: () => ({ cart }: {
|
|
3
|
+
cart: any;
|
|
4
|
+
}) => Promise<CartModel>;
|
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import { useQueryClient
|
|
1
|
+
import { useQueryClient } from '@tanstack/react-query';
|
|
2
2
|
import { placeOrder } from '../../services/cart-service.js';
|
|
3
3
|
|
|
4
4
|
const usePlaceOrder = () => {
|
|
5
5
|
const queryClient = useQueryClient();
|
|
6
|
-
return
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
});
|
|
6
|
+
return async ({ cart }) => {
|
|
7
|
+
const updatedCart = await placeOrder({ cart });
|
|
8
|
+
queryClient.invalidateQueries({ queryKey: ['carts', cart.id] });
|
|
9
|
+
queryClient.setQueryData(['carts', updatedCart.id], updatedCart);
|
|
10
|
+
return updatedCart;
|
|
11
|
+
};
|
|
13
12
|
};
|
|
14
13
|
|
|
15
14
|
export { usePlaceOrder };
|
|
@@ -3,7 +3,6 @@ import { updateCartLineById } from '../../services/cart-service.js';
|
|
|
3
3
|
|
|
4
4
|
function useUpdateCartLineById() {
|
|
5
5
|
const queryClient = useQueryClient();
|
|
6
|
-
const queryKey = ['carts', 'current', 'cartlines'];
|
|
7
6
|
return useMutation({
|
|
8
7
|
mutationFn: async ({ cartLine: _cartLine, cartLineId }) => {
|
|
9
8
|
await updateCartLineById({ cartLine: _cartLine, cartLineId });
|
|
@@ -11,18 +10,7 @@ function useUpdateCartLineById() {
|
|
|
11
10
|
queryClient.invalidateQueries({ queryKey: ['carts', 'current'] });
|
|
12
11
|
},
|
|
13
12
|
onError: () => {
|
|
14
|
-
queryClient.invalidateQueries({ queryKey });
|
|
15
|
-
},
|
|
16
|
-
onMutate: async ({ cartLine }) => {
|
|
17
|
-
await queryClient.cancelQueries({ queryKey });
|
|
18
|
-
const cartLines = (queryClient.getQueryData(queryKey) ||
|
|
19
|
-
[]);
|
|
20
|
-
const previousCartLine = cartLines.find(line => line.id === cartLine.id);
|
|
21
|
-
queryClient.setQueryData(queryKey, cartLines.some(cl => cl.id === cartLine.id)
|
|
22
|
-
? cartLines.map(cl => (cl.id === cartLine.id ? cartLine : cl))
|
|
23
|
-
: [...cartLines, cartLine]);
|
|
24
|
-
// Return a context with the previous and new todo
|
|
25
|
-
return { newCartLine: cartLine, previousCartLine };
|
|
13
|
+
queryClient.invalidateQueries({ queryKey: ['carts', 'current'] });
|
|
26
14
|
},
|
|
27
15
|
});
|
|
28
16
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useFetchBillToAddresses(): import("@tanstack/react-query").UseQueryResult<import("../../model/shop.model").BillToModel[] | null, Error>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { useQuery } from '@tanstack/react-query';
|
|
2
|
+
import { fetchBillToAddresses } from '../../services/customer-service.js';
|
|
3
|
+
|
|
4
|
+
function useFetchBillToAddresses() {
|
|
5
|
+
return useQuery({
|
|
6
|
+
queryFn: fetchBillToAddresses,
|
|
7
|
+
queryKey: ['customer', 'bill-to-addresses'],
|
|
8
|
+
select(body) {
|
|
9
|
+
return body.billTos;
|
|
10
|
+
},
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export { useFetchBillToAddresses };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { useQuery } from '@tanstack/react-query';
|
|
2
|
+
import { fetchShipToAddresses } from '../../services/customer-service.js';
|
|
3
|
+
|
|
4
|
+
function useFetchShipToAddresses({ shipToId }) {
|
|
5
|
+
return useQuery({
|
|
6
|
+
enabled: Boolean(shipToId),
|
|
7
|
+
queryFn: () => fetchShipToAddresses({ shipToId }),
|
|
8
|
+
queryKey: ['customer', 'ship-to-addresses'],
|
|
9
|
+
select(body) {
|
|
10
|
+
return body.shipTos;
|
|
11
|
+
},
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export { useFetchShipToAddresses };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { useQueryClient } from '@tanstack/react-query';
|
|
2
|
+
import { updateBillToAddress } from '../../services/customer-service.js';
|
|
3
|
+
|
|
4
|
+
function useUpdateBillToAddress() {
|
|
5
|
+
const queryClient = useQueryClient();
|
|
6
|
+
return {
|
|
7
|
+
async mutate({ billTo }) {
|
|
8
|
+
const billToAddress = await updateBillToAddress({ billTo });
|
|
9
|
+
queryClient.invalidateQueries({ queryKey: ['customer'] });
|
|
10
|
+
queryClient.invalidateQueries({ queryKey: ['carts'] });
|
|
11
|
+
queryClient.invalidateQueries({ queryKey: ['session'] });
|
|
12
|
+
return billToAddress;
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export { useUpdateBillToAddress };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { PaymentAuthenticationModel } from 'shared/api/storefront/model/shop.model';
|
|
2
|
+
import { CreateAdyenSessionParameters } from 'shared/api/storefront/services/payment-service';
|
|
3
|
+
export declare function useCreateAdyenSession(): import("@tanstack/react-query").UseMutationResult<PaymentAuthenticationModel, Error, CreateAdyenSessionParameters, unknown>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { useMutation } from '@tanstack/react-query';
|
|
2
|
+
import { createAdyenSession } from '../../services/payment-service.js';
|
|
3
|
+
|
|
4
|
+
function useCreateAdyenSession() {
|
|
5
|
+
return useMutation({
|
|
6
|
+
mutationFn: createAdyenSession,
|
|
7
|
+
});
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export { useCreateAdyenSession };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useFetchAdyenConfig(): import("@tanstack/react-query").UseQueryResult<import("../../model/shop.model").AdyenSettings, Error>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { useQuery } from '@tanstack/react-query';
|
|
2
|
+
import { useIsAuthenticated } from '../authentication/use-is-authenticated.js';
|
|
3
|
+
import { fetchAdyenConfig } from '../../services/payment-service.js';
|
|
4
|
+
|
|
5
|
+
function useFetchAdyenConfig() {
|
|
6
|
+
const isAuthenticated = useIsAuthenticated();
|
|
7
|
+
return useQuery({
|
|
8
|
+
enabled: Boolean(isAuthenticated),
|
|
9
|
+
queryFn: fetchAdyenConfig,
|
|
10
|
+
queryKey: ['adyen', 'config'],
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export { useFetchAdyenConfig };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useInvalidateAdyen(): () => Promise<void>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { useCallback } from 'react';
|
|
2
|
+
import { useQueryClient } from '@tanstack/react-query';
|
|
3
|
+
|
|
4
|
+
function useInvalidateAdyen() {
|
|
5
|
+
const queryClient = useQueryClient();
|
|
6
|
+
return useCallback(() => queryClient.invalidateQueries({ queryKey: ['adyen'] }), [queryClient]);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export { useInvalidateAdyen };
|
|
@@ -3018,3 +3018,20 @@ export interface PaymentAuthenticationModel {
|
|
|
3018
3018
|
transactionId: string;
|
|
3019
3019
|
webOrderNumber: string;
|
|
3020
3020
|
}
|
|
3021
|
+
export interface PaymetricResponseApiResult {
|
|
3022
|
+
creditCard: CreditCardDto;
|
|
3023
|
+
message: string;
|
|
3024
|
+
success: boolean;
|
|
3025
|
+
}
|
|
3026
|
+
export type AdyenResultCode = 'AuthenticationFinished' | 'AuthenticationNotRequired' | 'Authorised' | 'Cancelled' | 'ChallengeShopper' | 'Error' | 'IdentifyShopper' | 'PartiallyAuthorised' | 'Pending' | 'PresentToShopper' | 'Received' | 'RedirectShopper' | 'Refused';
|
|
3027
|
+
export interface AdyenPaymentModel {
|
|
3028
|
+
action?: any;
|
|
3029
|
+
amount: {
|
|
3030
|
+
currency: string;
|
|
3031
|
+
value: number | null;
|
|
3032
|
+
} | null;
|
|
3033
|
+
merchantReference: string;
|
|
3034
|
+
paymentMethod: string;
|
|
3035
|
+
pspReference: string;
|
|
3036
|
+
resultCode: AdyenResultCode;
|
|
3037
|
+
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { CartLineModel, CartLineModel as ShopCartLineModel, CartModel, CheckoutAtpEntry, PatchCartModel, ProductAtp, PromotionModel } from '../model/shop.model';
|
|
2
|
-
export declare function fetchCurrentCart(
|
|
1
|
+
import { AdyenPaymentModel, CartLineModel, CartLineModel as ShopCartLineModel, CartModel, CheckoutAtpEntry, PatchCartModel, ProductAtp, PromotionModel } from '../model/shop.model';
|
|
2
|
+
export declare function fetchCurrentCart({ needFullCart, }?: {
|
|
3
|
+
needFullCart?: boolean;
|
|
4
|
+
}): Promise<CartModel>;
|
|
3
5
|
export declare function fetchCurrentCartPromotions(): Promise<PromotionModel[]>;
|
|
4
6
|
export declare function fetchCurrentCartLines(): Promise<CartLineModel[] | null>;
|
|
5
7
|
export declare function updateCartLineById({ cartLine, cartLineId, }: {
|
|
@@ -28,3 +30,14 @@ export declare function placeOrder({ cart, isPending, }: {
|
|
|
28
30
|
export declare function saveCartForLater({ cart }: {
|
|
29
31
|
cart: CartModel;
|
|
30
32
|
}): Promise<CartModel>;
|
|
33
|
+
export declare function postAdyenPayment({ currencyCode, data, orderAmount, returnUrl, webOrderNumber, }: {
|
|
34
|
+
currencyCode: string;
|
|
35
|
+
data: any;
|
|
36
|
+
orderAmount: number;
|
|
37
|
+
returnUrl: string;
|
|
38
|
+
webOrderNumber: string;
|
|
39
|
+
}): Promise<AdyenPaymentModel>;
|
|
40
|
+
export declare function getAdyenPaymentDetails({ redirectResult, }: {
|
|
41
|
+
redirectResult: string;
|
|
42
|
+
}): Promise<AdyenPaymentModel>;
|
|
43
|
+
export declare function convertToMinorUnits(value: number, currencyCode: string): number;
|