@afosto/checkout-ui 0.0.14 → 0.0.15

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.
Files changed (61) hide show
  1. package/dist/CheckoutAddressFields/CheckoutAddressFields.d.ts.map +1 -1
  2. package/dist/CheckoutAddressFields/CheckoutAddressFields.js +59 -57
  3. package/dist/CheckoutAgreementOptionCondition/CheckoutAgreementOptionCondition.d.ts +1 -1
  4. package/dist/CheckoutAgreementOptionCondition/CheckoutAgreementOptionCondition.js +23 -23
  5. package/dist/CheckoutAgreementsTimeline/CheckoutAgreementsTimeline.js +10 -10
  6. package/dist/CheckoutShippingMethodSection/CheckoutShippingMethodSection.d.ts +1 -1
  7. package/dist/CheckoutShippingMethodSection/CheckoutShippingMethodSection.d.ts.map +1 -1
  8. package/dist/CheckoutShippingMethodsField/CheckoutShippingMethodsField.d.ts +1 -1
  9. package/dist/CheckoutShippingMethodsField/CheckoutShippingMethodsField.d.ts.map +1 -1
  10. package/dist/CheckoutShippingMethodsField/CheckoutShippingMethodsField.js +78 -77
  11. package/dist/constants/paymentMethodIconMapping.d.ts +9 -0
  12. package/dist/constants/paymentMethodIconMapping.d.ts.map +1 -1
  13. package/dist/constants/paymentMethodIconMapping.js +76 -58
  14. package/dist/hooks/useCheckoutShippingMethods.d.ts +2 -1
  15. package/dist/hooks/useCheckoutShippingMethods.d.ts.map +1 -1
  16. package/dist/hooks/useCheckoutShippingMethods.js +110 -67
  17. package/dist/icons/index.js +178 -160
  18. package/dist/icons/paymentMethods/Alma.d.ts +3 -0
  19. package/dist/icons/paymentMethods/Alma.d.ts.map +1 -0
  20. package/dist/icons/paymentMethods/Alma.js +15 -0
  21. package/dist/icons/paymentMethods/Bancomat.d.ts +3 -0
  22. package/dist/icons/paymentMethods/Bancomat.d.ts.map +1 -0
  23. package/dist/icons/paymentMethods/Bancomat.js +15 -0
  24. package/dist/icons/paymentMethods/Bizum.d.ts +3 -0
  25. package/dist/icons/paymentMethods/Bizum.d.ts.map +1 -0
  26. package/dist/icons/paymentMethods/Bizum.js +28 -0
  27. package/dist/icons/paymentMethods/Blik.d.ts +3 -0
  28. package/dist/icons/paymentMethods/Blik.d.ts.map +1 -0
  29. package/dist/icons/paymentMethods/Blik.js +59 -0
  30. package/dist/icons/paymentMethods/ClickToPay.d.ts +3 -0
  31. package/dist/icons/paymentMethods/ClickToPay.d.ts.map +1 -0
  32. package/dist/icons/paymentMethods/ClickToPay.js +35 -0
  33. package/dist/icons/paymentMethods/MBWay.d.ts +3 -0
  34. package/dist/icons/paymentMethods/MBWay.d.ts.map +1 -0
  35. package/dist/icons/paymentMethods/MBWay.js +65 -0
  36. package/dist/icons/paymentMethods/MobilePay.d.ts +3 -0
  37. package/dist/icons/paymentMethods/MobilePay.d.ts.map +1 -0
  38. package/dist/icons/paymentMethods/MobilePay.js +103 -0
  39. package/dist/icons/paymentMethods/Satispay.d.ts +3 -0
  40. package/dist/icons/paymentMethods/Satispay.d.ts.map +1 -0
  41. package/dist/icons/paymentMethods/Satispay.js +15 -0
  42. package/dist/icons/paymentMethods/Vipps.d.ts +3 -0
  43. package/dist/icons/paymentMethods/Vipps.d.ts.map +1 -0
  44. package/dist/icons/paymentMethods/Vipps.js +15 -0
  45. package/dist/icons/paymentMethods/index.d.ts +9 -0
  46. package/dist/icons/paymentMethods/index.d.ts.map +1 -1
  47. package/dist/icons/paymentMethods/index.js +124 -106
  48. package/dist/index.js +356 -338
  49. package/dist/operations/cartOperations.d.ts.map +1 -1
  50. package/dist/operations/cartOperations.js +4 -6
  51. package/dist/operations/orderOperations.d.ts.map +1 -1
  52. package/dist/operations/orderOperations.js +4 -6
  53. package/dist/queries/getCartShippingMethodsQuery.d.ts +0 -1
  54. package/dist/queries/getCartShippingMethodsQuery.d.ts.map +1 -1
  55. package/dist/queries/getCartShippingMethodsQuery.js +6 -29
  56. package/dist/queries/getOrderShippingMethodsQuery.d.ts +0 -1
  57. package/dist/queries/getOrderShippingMethodsQuery.d.ts.map +1 -1
  58. package/dist/queries/getOrderShippingMethodsQuery.js +4 -27
  59. package/dist/types.d.ts +1 -1
  60. package/dist/types.d.ts.map +1 -1
  61. package/package.json +2 -2
@@ -1,103 +1,104 @@
1
- import { jsx as b } from "react/jsx-runtime";
2
- import { useFormContext as j } from "@afosto/components";
3
- import { CheckoutCardRadioField as D } from "../CheckoutCardRadioField/CheckoutCardRadioField.js";
4
- import { CheckoutShippingMethodOption as L } from "../CheckoutShippingMethodOption/CheckoutShippingMethodOption.js";
5
- import { useCheckoutShippingMethods as q } from "../hooks/useCheckoutShippingMethods.js";
6
- import { useCheckout as A } from "../CheckoutStateProvider/CheckoutStateProvider.js";
7
- import { getErrorMessage as B } from "../utils/getErrorMessage.js";
8
- import { capitalize as G } from "@afosto/utils";
9
- import { CheckoutMethodRadioSkeleton as H } from "../CheckoutMethodRadioSkeleton/CheckoutMethodRadioSkeleton.js";
10
- const J = {
1
+ import { jsx as j } from "react/jsx-runtime";
2
+ import { useFormContext as D } from "@afosto/components";
3
+ import { CheckoutCardRadioField as L } from "../CheckoutCardRadioField/CheckoutCardRadioField.js";
4
+ import { CheckoutShippingMethodOption as q } from "../CheckoutShippingMethodOption/CheckoutShippingMethodOption.js";
5
+ import { useCheckoutShippingMethods as A } from "../hooks/useCheckoutShippingMethods.js";
6
+ import { useCheckout as B } from "../CheckoutStateProvider/CheckoutStateProvider.js";
7
+ import { getErrorMessage as G } from "../utils/getErrorMessage.js";
8
+ import { capitalize as H } from "@afosto/utils";
9
+ import { CheckoutMethodRadioSkeleton as J } from "../CheckoutMethodRadioSkeleton/CheckoutMethodRadioSkeleton.js";
10
+ const K = {
11
11
  failedToSearchPickupPoints: "Pickup points search failed. Please try again.",
12
12
  failedToSelectShippingMethodTitle: "Shipping method not selected",
13
13
  failedToSelectShippingMethodDescription: "Something went wrong while selecting the shipping method. Choose another shipping method or try again."
14
- }, ii = (k) => {
14
+ }, oi = (S) => {
15
15
  const {
16
- countryCode: S,
17
- currency: C,
16
+ countryCode: f,
17
+ currency: k,
18
18
  locale: M,
19
- name: r = "methodId",
20
- postalCode: a,
21
- translations: T = {}
22
- } = k || {}, {
23
- activeStep: c,
24
- addShippingMethod: w,
25
- isProcessing: y,
26
- setErrorMessage: d,
19
+ name: p = "methodId",
20
+ postalCode: r,
21
+ translations: C = {}
22
+ } = S || {}, {
23
+ activeStep: a,
24
+ addShippingMethod: T,
25
+ isProcessing: w,
26
+ setErrorMessage: c,
27
27
  setIsProcessing: n,
28
- translations: h
29
- } = A(), {
30
- hasSearchPickupPointsError: I,
31
- isInitializingShippingMethods: v,
32
- isSearchingPickupPoints: E,
33
- pickupPoints: l,
34
- searchPickupPoints: V,
35
- setPickupPoints: s,
36
- shippingMethods: u
37
- } = q({
38
- countryCode: S,
39
- postalCode: a
40
- }), { formProps: x, getValues: F, reset: g, watch: O } = j(), { setData: z } = x || {}, [P] = O([r]), p = {
41
- ...J,
42
- ...h?.shippingMethodsField || {},
43
- ...h?.feedback || {},
44
- ...T || {}
28
+ translations: d
29
+ } = B(), {
30
+ hasSearchPickupPointsError: y,
31
+ isInitializingShippingMethods: I,
32
+ isSearchingPickupPoints: v,
33
+ loadPickupPointsForShippingMethod: E,
34
+ pickupPoints: h,
35
+ searchPickupPoints: F,
36
+ setPickupPoints: V,
37
+ shippingMethods: l
38
+ } = A({
39
+ countryCode: f,
40
+ postalCode: r
41
+ }), { formProps: x, getValues: O, reset: u, watch: z } = D(), { setData: R } = x || {}, [g] = z([p]), s = {
42
+ ...K,
43
+ ...d?.shippingMethodsField || {},
44
+ ...d?.feedback || {},
45
+ ...C || {}
45
46
  };
46
- return /* @__PURE__ */ b(
47
- D,
47
+ return /* @__PURE__ */ j(
48
+ L,
48
49
  {
49
50
  id: "field-radio-shipping-method",
50
- name: r,
51
- isLoading: v,
52
- onChange: async (o) => {
53
- const m = F(), R = [...l];
51
+ name: p,
52
+ isLoading: I,
53
+ onChange: async (i) => {
54
+ const P = O(), b = [...h];
54
55
  try {
55
- d(null), n(!0);
56
- const { value: e } = o.target, i = u.find(
57
- (t) => t.id === e
56
+ c(null), n(!0);
57
+ const { value: o } = i.target, e = l.find(
58
+ (t) => t.id === o
58
59
  );
59
- await w({ methodId: e }), i && (i?.pickupPoints || []).length > 0 ? s(i.pickupPoints) : s([]);
60
- const f = {
61
- methodId: e,
62
- isPickupPoint: i?.isPickupPoint,
60
+ await T({ methodId: o }), E(e);
61
+ const m = {
62
+ methodId: o,
63
+ isPickupPoint: e?.isPickupPoint,
63
64
  pickupPointId: ""
64
65
  };
65
- g({
66
- ...m,
67
- ...f
68
- }), z((t) => (t?.splice(c, 1, {
69
- ...t[c],
70
- ...f
66
+ u({
67
+ ...P,
68
+ ...m
69
+ }), R((t) => (t?.splice(a, 1, {
70
+ ...t[a],
71
+ ...m
71
72
  }), t)), n(!1);
72
- } catch (e) {
73
- const i = B(e);
74
- d({
75
- title: p.failedToSelectShippingMethodTitle,
76
- description: i ? G(i) : p.failedToSelectShippingMethodDescription
77
- }), g(m), s(R), n(!1), window && typeof window < "u" && window.scrollTo(0, 0);
73
+ } catch (o) {
74
+ const e = G(o);
75
+ c({
76
+ title: s.failedToSelectShippingMethodTitle,
77
+ description: e ? H(e) : s.failedToSelectShippingMethodDescription
78
+ }), u(P), V(b), n(!1), window && typeof window < "u" && window.scrollTo(0, 0);
78
79
  }
79
80
  },
80
- OptionComponent: L,
81
- OptionSkeletonComponent: H,
82
- options: u.map((o) => ({
83
- ...o,
84
- value: o.id,
85
- ...P === o.id ? {
86
- pickupPoints: l
81
+ OptionComponent: q,
82
+ OptionSkeletonComponent: J,
83
+ options: l.map((i) => ({
84
+ ...i,
85
+ value: i.id,
86
+ ...g === i.id ? {
87
+ pickupPoints: h
87
88
  } : {}
88
89
  })),
89
90
  optionProps: {
90
- currency: C,
91
- defaultPickupPointSearchValue: a,
92
- isSearchingPickupPoints: y || E,
91
+ currency: k,
92
+ defaultPickupPointSearchValue: r,
93
+ isSearchingPickupPoints: w || v,
93
94
  locale: M,
94
- onSearchPickupPoint: V,
95
- searchPickupPointsErrorMessage: I ? p.failedToSearchPickupPoints : void 0
95
+ onSearchPickupPoint: F,
96
+ searchPickupPointsErrorMessage: y ? s.failedToSearchPickupPoints : void 0
96
97
  },
97
- value: P
98
+ value: g
98
99
  }
99
100
  );
100
101
  };
101
102
  export {
102
- ii as CheckoutShippingMethodsField
103
+ oi as CheckoutShippingMethodsField
103
104
  };
@@ -47,5 +47,14 @@ export declare const CHECKOUT_PAYMENT_METHOD_ICON_MAPPING: {
47
47
  twint: (props: import('@afosto/components').SvgIconProps) => import("@emotion/react/jsx-runtime").JSX.Element;
48
48
  walley: (props: import('@afosto/components').SvgIconProps) => import("@emotion/react/jsx-runtime").JSX.Element;
49
49
  zip: (props: import('@afosto/components').SvgIconProps) => import("@emotion/react/jsx-runtime").JSX.Element;
50
+ alma: (props: import('@afosto/components').SvgIconProps) => import("@emotion/react/jsx-runtime").JSX.Element;
51
+ bancomatPay: (props: import('@afosto/components').SvgIconProps) => import("@emotion/react/jsx-runtime").JSX.Element;
52
+ bizum: (props: import('@afosto/components').SvgIconProps) => import("@emotion/react/jsx-runtime").JSX.Element;
53
+ blik: (props: import('@afosto/components').SvgIconProps) => import("@emotion/react/jsx-runtime").JSX.Element;
54
+ clickToPay: (props: import('@afosto/components').SvgIconProps) => import("@emotion/react/jsx-runtime").JSX.Element;
55
+ mbWay: (props: import('@afosto/components').SvgIconProps) => import("@emotion/react/jsx-runtime").JSX.Element;
56
+ mobilepay: (props: import('@afosto/components').SvgIconProps) => import("@emotion/react/jsx-runtime").JSX.Element;
57
+ satispay: (props: import('@afosto/components').SvgIconProps) => import("@emotion/react/jsx-runtime").JSX.Element;
58
+ vipps: (props: import('@afosto/components').SvgIconProps) => import("@emotion/react/jsx-runtime").JSX.Element;
50
59
  };
51
60
  //# sourceMappingURL=paymentMethodIconMapping.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"paymentMethodIconMapping.d.ts","sourceRoot":"","sources":["../../src/constants/paymentMethodIconMapping.ts"],"names":[],"mappings":"AA6CA,eAAO,MAAM,oCAAoC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiDhD,CAAC"}
1
+ {"version":3,"file":"paymentMethodIconMapping.d.ts","sourceRoot":"","sources":["../../src/constants/paymentMethodIconMapping.ts"],"names":[],"mappings":"AAsDA,eAAO,MAAM,oCAAoC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0DhD,CAAC"}
@@ -7,91 +7,109 @@ import { CashOnDelivery as f } from "../icons/paymentMethods/CashOnDelivery.js";
7
7
  import { Spraypay as e } from "../icons/paymentMethods/Spraypay.js";
8
8
  import { Klarna as r } from "../icons/paymentMethods/Klarna.js";
9
9
  import { PayPal as o } from "../icons/paymentMethods/PayPal.js";
10
- import { Bancontact as n } from "../icons/paymentMethods/Bancontact.js";
11
- import { Paysafe as l } from "../icons/paymentMethods/Paysafe.js";
12
- import { Giropay as c } from "../icons/paymentMethods/Giropay.js";
13
- import { Postepay as y } from "../icons/paymentMethods/Postepay.js";
10
+ import { Bancontact as l } from "../icons/paymentMethods/Bancontact.js";
11
+ import { Paysafe as n } from "../icons/paymentMethods/Paysafe.js";
12
+ import { Giropay as y } from "../icons/paymentMethods/Giropay.js";
13
+ import { Postepay as c } from "../icons/paymentMethods/Postepay.js";
14
14
  import { CarteBleue as s } from "../icons/paymentMethods/CarteBleue.js";
15
15
  import { Afterpay as u } from "../icons/paymentMethods/Afterpay.js";
16
16
  import { WebshopGiftcard as d } from "../icons/paymentMethods/WebshopGiftcard.js";
17
- import { Fashioncheque as C } from "../icons/paymentMethods/Fashioncheque.js";
18
- import { PodiumCadeaukaart as P } from "../icons/paymentMethods/PodiumCadeaukaart.js";
19
- import { YourGift as k } from "../icons/paymentMethods/YourGift.js";
20
- import { Giftcard as b } from "../icons/paymentMethods/Giftcard.js";
21
- import { GivaCard as h } from "../icons/paymentMethods/GivaCard.js";
22
- import { VVVCadeaukaart as B } from "../icons/paymentMethods/VVVCadeaukaart.js";
17
+ import { Fashioncheque as P } from "../icons/paymentMethods/Fashioncheque.js";
18
+ import { PodiumCadeaukaart as b } from "../icons/paymentMethods/PodiumCadeaukaart.js";
19
+ import { YourGift as C } from "../icons/paymentMethods/YourGift.js";
20
+ import { Giftcard as k } from "../icons/paymentMethods/Giftcard.js";
21
+ import { GivaCard as B } from "../icons/paymentMethods/GivaCard.js";
22
+ import { VVVCadeaukaart as h } from "../icons/paymentMethods/VVVCadeaukaart.js";
23
23
  import { WeChat as g } from "../icons/paymentMethods/WeChat.js";
24
- import { Alipay as w } from "../icons/paymentMethods/Alipay.js";
25
- import { Payconiq as v } from "../icons/paymentMethods/Payconiq.js";
24
+ import { Alipay as v } from "../icons/paymentMethods/Alipay.js";
25
+ import { Payconiq as w } from "../icons/paymentMethods/Payconiq.js";
26
26
  import { Multibanco as G } from "../icons/paymentMethods/Multibanco.js";
27
- import { EPSUberweisung as A } from "../icons/paymentMethods/EPSUberweisung.js";
28
- import { Przelewy24 as T } from "../icons/paymentMethods/Przelewy24.js";
27
+ import { EPSUberweisung as T } from "../icons/paymentMethods/EPSUberweisung.js";
28
+ import { Przelewy24 as A } from "../icons/paymentMethods/Przelewy24.js";
29
29
  import { Billink as M } from "../icons/paymentMethods/Billink.js";
30
30
  import { In3 as O } from "../icons/paymentMethods/In3.js";
31
- import { Interac as E } from "../icons/paymentMethods/Interac.js";
32
- import { Cash as I } from "../icons/paymentMethods/Cash.js";
33
- import { ManualGiftCard as q } from "../icons/paymentMethods/ManualGiftCard.js";
34
- import { ManualCard as D } from "../icons/paymentMethods/ManualCard.js";
35
- import { Pin as N } from "../icons/paymentMethods/Pin.js";
36
- import { ApplePay as W } from "../icons/paymentMethods/ApplePay.js";
37
- import { GooglePay as _ } from "../icons/paymentMethods/GooglePay.js";
38
- import { Bank as z } from "../icons/paymentMethods/Bank.js";
39
- import { Riverty as K } from "../icons/paymentMethods/Riverty.js";
40
- import { Twint as U } from "../icons/paymentMethods/Twint.js";
41
- import { Walley as V } from "../icons/paymentMethods/Walley.js";
42
- import { Zip as x } from "../icons/paymentMethods/Zip.js";
43
- import { Belfius as H } from "../icons/paymentMethods/Belfius.js";
44
- import { Kbc as S } from "../icons/paymentMethods/Kbc.js";
45
- const Nr = {
31
+ import { Interac as W } from "../icons/paymentMethods/Interac.js";
32
+ import { Cash as z } from "../icons/paymentMethods/Cash.js";
33
+ import { ManualGiftCard as E } from "../icons/paymentMethods/ManualGiftCard.js";
34
+ import { ManualCard as I } from "../icons/paymentMethods/ManualCard.js";
35
+ import { Pin as q } from "../icons/paymentMethods/Pin.js";
36
+ import { ApplePay as D } from "../icons/paymentMethods/ApplePay.js";
37
+ import { GooglePay as N } from "../icons/paymentMethods/GooglePay.js";
38
+ import { Bank as V } from "../icons/paymentMethods/Bank.js";
39
+ import { Riverty as _ } from "../icons/paymentMethods/Riverty.js";
40
+ import { Twint as K } from "../icons/paymentMethods/Twint.js";
41
+ import { Walley as S } from "../icons/paymentMethods/Walley.js";
42
+ import { Zip as U } from "../icons/paymentMethods/Zip.js";
43
+ import { Belfius as x } from "../icons/paymentMethods/Belfius.js";
44
+ import { Kbc as H } from "../icons/paymentMethods/Kbc.js";
45
+ import { Alma as Y } from "../icons/paymentMethods/Alma.js";
46
+ import { Bancomat as F } from "../icons/paymentMethods/Bancomat.js";
47
+ import { Bizum as R } from "../icons/paymentMethods/Bizum.js";
48
+ import { Blik as Z } from "../icons/paymentMethods/Blik.js";
49
+ import { ClickToPay as j } from "../icons/paymentMethods/ClickToPay.js";
50
+ import { MBWay as J } from "../icons/paymentMethods/MBWay.js";
51
+ import { MobilePay as L } from "../icons/paymentMethods/MobilePay.js";
52
+ import { Satispay as Q } from "../icons/paymentMethods/Satispay.js";
53
+ import { Vipps as X } from "../icons/paymentMethods/Vipps.js";
54
+ const Xr = {
46
55
  ideal: m,
47
56
  card: i,
48
57
  bacsDirectDebit: a,
49
58
  bankTransfer: t,
50
- belfius: H,
51
- kbc: S,
59
+ belfius: x,
60
+ kbc: H,
52
61
  onAccount: p,
53
62
  cod: f,
54
63
  spraypay: e,
55
64
  sofort: r,
56
65
  paypalExpress: o,
57
66
  paypal: o,
58
- mistercashBancontact: n,
59
- paysafecard: l,
60
- giftCard: b,
61
- giropay: c,
62
- postepay: y,
67
+ mistercashBancontact: l,
68
+ paysafecard: n,
69
+ giftCard: k,
70
+ giropay: y,
71
+ postepay: c,
63
72
  carteBleue: s,
64
73
  afterpay: u,
65
74
  webshopgiftcard: d,
66
- fashioncheque: C,
67
- podiumcadeaukaart: P,
68
- yourgift: k,
69
- givacard: h,
70
- vvvCadeaukaart: B,
75
+ fashioncheque: P,
76
+ podiumcadeaukaart: b,
77
+ yourgift: C,
78
+ givacard: B,
79
+ vvvCadeaukaart: h,
71
80
  wechatPay: g,
72
- alipay: w,
73
- payconiq: v,
81
+ alipay: v,
82
+ payconiq: w,
74
83
  multibanco: G,
75
- epsUberweisung: A,
76
- przelewy24: T,
84
+ epsUberweisung: T,
85
+ przelewy24: A,
77
86
  billink: M,
78
87
  klarna: r,
79
88
  klarnaNow: r,
80
89
  klarnaOverTime: r,
81
90
  in3: O,
82
- interac: E,
83
- cash: I,
84
- manualGiftCard: q,
85
- manualCard: D,
86
- pin: N,
87
- applePay: W,
88
- googleWallet: _,
89
- payByBank: z,
90
- riverty: K,
91
- twint: U,
92
- walley: V,
93
- zip: x
91
+ interac: W,
92
+ cash: z,
93
+ manualGiftCard: E,
94
+ manualCard: I,
95
+ pin: q,
96
+ applePay: D,
97
+ googleWallet: N,
98
+ payByBank: V,
99
+ riverty: _,
100
+ twint: K,
101
+ walley: S,
102
+ zip: U,
103
+ alma: Y,
104
+ bancomatPay: F,
105
+ bizum: R,
106
+ blik: Z,
107
+ clickToPay: j,
108
+ mbWay: J,
109
+ mobilepay: L,
110
+ satispay: Q,
111
+ vipps: X
94
112
  };
95
113
  export {
96
- Nr as CHECKOUT_PAYMENT_METHOD_ICON_MAPPING
114
+ Xr as CHECKOUT_PAYMENT_METHOD_ICON_MAPPING
97
115
  };
@@ -1,11 +1,12 @@
1
1
  import { CheckoutShippingMethodOptionType, CheckoutShippingMethodPickupPoint } from '../types';
2
2
  export declare const useCheckoutShippingMethods: ({ countryCode, postalCode }: {
3
3
  countryCode: string;
4
- postalCode: string;
4
+ postalCode?: string;
5
5
  }) => {
6
6
  hasSearchPickupPointsError: boolean;
7
7
  isInitializingShippingMethods: boolean;
8
8
  isSearchingPickupPoints: boolean;
9
+ loadPickupPointsForShippingMethod: (shippingMethod?: CheckoutShippingMethodOptionType) => void;
9
10
  pickupPoints: CheckoutShippingMethodPickupPoint[];
10
11
  searchPickupPoints: (...args: unknown[]) => Promise<void>;
11
12
  setPickupPoints: import('react').Dispatch<import('react').SetStateAction<CheckoutShippingMethodPickupPoint[]>>;
@@ -1 +1 @@
1
- {"version":3,"file":"useCheckoutShippingMethods.d.ts","sourceRoot":"","sources":["../../src/hooks/useCheckoutShippingMethods.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACV,gCAAgC,EAChC,iCAAiC,EAClC,MAAM,UAAU,CAAC;AAGlB,eAAO,MAAM,0BAA0B,GAAI,6BAGxC;IACD,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;CACpB;;;;;;;;CAgKA,CAAC"}
1
+ {"version":3,"file":"useCheckoutShippingMethods.d.ts","sourceRoot":"","sources":["../../src/hooks/useCheckoutShippingMethods.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EACV,gCAAgC,EAChC,iCAAiC,EAClC,MAAM,UAAU,CAAC;AAGlB,eAAO,MAAM,0BAA0B,GAAI,6BAGxC;IACD,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;;;;yDA0FqB,gCAAgC;;;;;CAkIrD,CAAC"}
@@ -1,95 +1,138 @@
1
- import { useState as n, useEffect as K } from "react";
2
- import { useCheckout as N } from "../CheckoutStateProvider/CheckoutStateProvider.js";
3
- import { useGetLatest as x, useAsyncDebounce as O } from "@afosto/hooks";
4
- import { isDefined as P } from "@afosto/utils";
5
- import { useFormContext as Q } from "@afosto/components";
6
- const Y = ({
7
- countryCode: p,
8
- postalCode: c
1
+ import { useState as p, useRef as O, useCallback as z, useEffect as Q } from "react";
2
+ import { useCheckout as T } from "../CheckoutStateProvider/CheckoutStateProvider.js";
3
+ import { useGetLatest as B, useAsyncDebounce as W } from "@afosto/hooks";
4
+ import { isDefined as x } from "@afosto/utils";
5
+ import { useFormContext as X } from "@afosto/components";
6
+ const et = ({
7
+ countryCode: o,
8
+ postalCode: u
9
9
  }) => {
10
- const [D, f] = n(!1), [z, r] = n(!0), [B, g] = n(!1), [V, t] = n([]), [w, k] = n([]), {
10
+ const [C, f] = p(!1), [L, k] = p(!0), [R, a] = p(!1), [V, n] = p([]), [q, D] = p([]), S = O(0), {
11
11
  activeStep: y,
12
12
  addShippingMethod: A,
13
- getPickupPoints: C,
14
- getShippingMethods: E,
15
- setSubmitButtonDisabled: L
16
- } = N(), m = x({
13
+ getPickupPoints: E,
14
+ getShippingMethods: G,
15
+ setSubmitButtonDisabled: F
16
+ } = T(), h = B({
17
17
  activeStep: y,
18
18
  addShippingMethod: A,
19
- getShippingMethods: E,
20
- setSubmitButtonDisabled: L
21
- }), M = Q(), b = x(M);
22
- K(() => {
23
- p && c && (async () => {
19
+ getPickupPoints: E,
20
+ getShippingMethods: G,
21
+ setSubmitButtonDisabled: F
22
+ }), H = X(), r = B(H), M = z(
23
+ async ({
24
+ searchValue: e,
25
+ clearUnavailablePickupPoint: i = !1
26
+ } = {}) => {
27
+ const b = ++S.current, d = () => b === S.current;
28
+ try {
29
+ f(!1), a(!0);
30
+ const { getPickupPoints: P } = h(), g = await P({
31
+ countryCode: o,
32
+ postalCode: x(e) ? e : u ?? ""
33
+ }), { pickupPoints: l } = g || {};
34
+ if (!d())
35
+ return;
36
+ if (i) {
37
+ const { getValues: s, setValue: c } = r() || {}, { pickupPointId: t } = s() || {};
38
+ x(t) && !(l ?? []).some(
39
+ (I) => I.id === t
40
+ ) && c("pickupPointId", "");
41
+ }
42
+ n(l ?? []), a(!1);
43
+ } catch {
44
+ if (!d())
45
+ return;
46
+ f(!0), n([]), a(!1);
47
+ }
48
+ },
49
+ [o, h, r, u]
50
+ ), m = z(
51
+ (e) => {
52
+ if (n([]), e?.isPickupPoint) {
53
+ M();
54
+ return;
55
+ }
56
+ S.current++, f(!1), a(!1);
57
+ },
58
+ [M]
59
+ );
60
+ Q(() => {
61
+ o && (async () => {
24
62
  const {
25
- activeStep: s,
26
- addShippingMethod: S,
27
- getShippingMethods: h,
28
- setSubmitButtonDisabled: a
29
- } = m();
63
+ activeStep: i,
64
+ addShippingMethod: b,
65
+ getShippingMethods: d,
66
+ setSubmitButtonDisabled: P
67
+ } = h();
30
68
  try {
31
- const u = await h({ countryCode: p, postalCode: c }), {
32
- currentShippingMethod: d,
33
- shippingMethods: i
34
- } = u || {};
35
- if (k(i), !i.length) {
36
- a(!0), r(!1);
69
+ const g = await d({
70
+ countryCode: o,
71
+ postalCode: u ?? ""
72
+ }), {
73
+ currentShippingMethod: l,
74
+ shippingMethods: s
75
+ } = g || {};
76
+ if (D(s), !s.length) {
77
+ P(!0), k(!1);
37
78
  return;
38
79
  }
39
- let o = i.find(
40
- (e) => e.id === d?.id
80
+ let c = s.find(
81
+ (t) => t.id === l?.id
41
82
  );
42
- if (!P(o)) {
43
- const [e] = i;
83
+ if (!x(c)) {
84
+ const [t] = s;
44
85
  try {
45
- const F = b(), { formProps: H, getValues: j, reset: q } = F || {}, { setData: J } = H || {};
46
- await S({ methodId: e.id }), o = e;
47
- const v = {
48
- methodId: e.id,
49
- isPickupPoint: e.isPickupPoint,
86
+ const I = r(), { formProps: j, getValues: J, reset: K } = I || {}, { setData: N } = j || {};
87
+ await b({ methodId: t.id }), c = t;
88
+ const w = {
89
+ methodId: t.id,
90
+ isPickupPoint: t.isPickupPoint,
50
91
  pickupPointId: ""
51
92
  };
52
- q({
53
- ...j(),
54
- ...v
55
- }), J((l) => (l.splice(s, 1, {
56
- ...l[s],
57
- ...v
58
- }), l));
93
+ K({
94
+ ...J(),
95
+ ...w
96
+ }), N((v) => (v.splice(i, 1, {
97
+ ...v[i],
98
+ ...w
99
+ }), v));
59
100
  } catch {
60
101
  }
61
102
  }
62
- o && (o?.pickupPoints || []).length > 0 ? t(o.pickupPoints) : t([]), r(!1);
103
+ m(c), k(!1);
63
104
  } catch {
64
- a(!0), t([]), k([]), r(!1);
105
+ P(!0), n([]), D([]), k(!1);
65
106
  }
66
107
  })();
67
- }, [p, m, b, c]);
68
- const G = O(
69
- async (I) => {
70
- try {
71
- f(!1), g(!0);
72
- const { value: s } = I?.target || {}, S = await C({
73
- countryCode: p,
74
- postalCode: P(s) ? s : c
75
- }), { pickupPoints: h } = S || {}, { getValues: a, setValue: u } = M || {}, { pickupPointId: d } = a() || {};
76
- P(d) && !h.some((i) => i.id === d) && u("pickupPointId", ""), t(h ?? []), g(!1);
77
- } catch {
78
- f(!0), t([]), g(!1);
79
- }
108
+ }, [
109
+ o,
110
+ h,
111
+ r,
112
+ m,
113
+ u
114
+ ]);
115
+ const U = W(
116
+ async (e) => {
117
+ const { value: i } = e?.target || {};
118
+ await M({
119
+ searchValue: i,
120
+ clearUnavailablePickupPoint: !0
121
+ });
80
122
  },
81
123
  250
82
124
  );
83
125
  return {
84
- hasSearchPickupPointsError: D,
85
- isInitializingShippingMethods: z,
86
- isSearchingPickupPoints: B,
126
+ hasSearchPickupPointsError: C,
127
+ isInitializingShippingMethods: L,
128
+ isSearchingPickupPoints: R,
129
+ loadPickupPointsForShippingMethod: m,
87
130
  pickupPoints: V,
88
- searchPickupPoints: G,
89
- setPickupPoints: t,
90
- shippingMethods: w
131
+ searchPickupPoints: U,
132
+ setPickupPoints: n,
133
+ shippingMethods: q
91
134
  };
92
135
  };
93
136
  export {
94
- Y as useCheckoutShippingMethods
137
+ et as useCheckoutShippingMethods
95
138
  };