@afosto/checkout-ui 0.0.16 → 0.0.18

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 (98) hide show
  1. package/dist/CheckoutAgreementOptionsField/CheckoutAgreementOptionsField.d.ts.map +1 -1
  2. package/dist/CheckoutAgreementOptionsField/CheckoutAgreementOptionsField.js +18 -17
  3. package/dist/CheckoutContactInformationSection/CheckoutContactInformationSection.d.ts.map +1 -1
  4. package/dist/CheckoutContactInformationSection/CheckoutContactInformationSection.js +0 -1
  5. package/dist/CheckoutContainer/CheckoutContainer.styles.d.ts +1 -1
  6. package/dist/CheckoutIssuersField/CheckoutIssuersField.js +15 -14
  7. package/dist/CheckoutNotFoundFeedback/CheckoutNotFoundFeedback.d.ts +2 -2
  8. package/dist/CheckoutNotFoundFeedback/CheckoutNotFoundFeedback.d.ts.map +1 -1
  9. package/dist/CheckoutPaymentMethodsField/CheckoutPaymentMethodsField.js +6 -6
  10. package/dist/CheckoutPickupPointsField/CheckoutPickupPointsField.d.ts.map +1 -1
  11. package/dist/CheckoutPickupPointsField/CheckoutPickupPointsField.js +13 -12
  12. package/dist/CheckoutShippingMethodsField/CheckoutShippingMethodsField.js +12 -12
  13. package/dist/CheckoutShippingStep/CheckoutShippingStep.d.ts.map +1 -1
  14. package/dist/CheckoutShippingStep/CheckoutShippingStep.js +11 -11
  15. package/dist/CheckoutSubmitButton/CheckoutSubmitButton.d.ts.map +1 -1
  16. package/dist/CheckoutSubmitButton/CheckoutSubmitButton.js +11 -10
  17. package/dist/CheckoutSummary/CheckoutSummary.d.ts.map +1 -1
  18. package/dist/CheckoutSummary/CheckoutSummary.js +6 -7
  19. package/dist/CheckoutSummary/components/CheckoutSummarySubtotal/CheckoutSummarySubtotal.d.ts +0 -2
  20. package/dist/CheckoutSummary/components/CheckoutSummarySubtotal/CheckoutSummarySubtotal.d.ts.map +1 -1
  21. package/dist/CheckoutSummary/components/CheckoutSummarySubtotal/CheckoutSummarySubtotal.js +16 -18
  22. package/dist/CheckoutSummary/components/CheckoutSummaryVat/CheckoutSummaryVat.d.ts +1 -1
  23. package/dist/CheckoutSummary/components/CheckoutSummaryVat/CheckoutSummaryVat.d.ts.map +1 -1
  24. package/dist/CheckoutSummary/components/CheckoutSummaryVat/CheckoutSummaryVat.js +49 -35
  25. package/dist/CheckoutTerminalsField/CheckoutTerminalsField.js +15 -14
  26. package/dist/constants/analyticsEvents.d.ts +79 -11
  27. package/dist/constants/analyticsEvents.d.ts.map +1 -1
  28. package/dist/constants/analyticsEvents.js +30 -30
  29. package/dist/constants/paymentMethodIconMapping.d.ts +4 -0
  30. package/dist/constants/paymentMethodIconMapping.d.ts.map +1 -1
  31. package/dist/constants/paymentMethodIconMapping.js +55 -47
  32. package/dist/fragments/CoreCartInitialCheckoutFields.d.ts +4 -0
  33. package/dist/fragments/CoreCartInitialCheckoutFields.d.ts.map +1 -1
  34. package/dist/hooks/useCheckoutAnalytics.d.ts.map +1 -1
  35. package/dist/hooks/useCheckoutAnalytics.js +13 -17
  36. package/dist/hooks/useCheckoutCart.d.ts +2 -2
  37. package/dist/hooks/useCheckoutCart.d.ts.map +1 -1
  38. package/dist/hooks/useCheckoutForm.d.ts +3 -3
  39. package/dist/hooks/useCheckoutForm.d.ts.map +1 -1
  40. package/dist/hooks/useCheckoutFormContext.d.ts +3 -0
  41. package/dist/hooks/useCheckoutFormContext.d.ts.map +1 -0
  42. package/dist/hooks/useCheckoutFormContext.js +5 -0
  43. package/dist/hooks/useCheckoutOrder.d.ts +2 -2
  44. package/dist/hooks/useCheckoutOrder.d.ts.map +1 -1
  45. package/dist/hooks/useCheckoutPaymentMethods.js +8 -8
  46. package/dist/hooks/useCheckoutPaymentStep.js +6 -6
  47. package/dist/hooks/useCheckoutShippingMethods.d.ts +2 -1
  48. package/dist/hooks/useCheckoutShippingMethods.d.ts.map +1 -1
  49. package/dist/hooks/useCheckoutShippingMethods.js +14 -14
  50. package/dist/icons/index.js +160 -152
  51. package/dist/icons/paymentMethods/Dankort.d.ts +3 -0
  52. package/dist/icons/paymentMethods/Dankort.d.ts.map +1 -0
  53. package/dist/icons/paymentMethods/Dankort.js +18 -0
  54. package/dist/icons/paymentMethods/Nexi.d.ts +3 -0
  55. package/dist/icons/paymentMethods/Nexi.d.ts.map +1 -0
  56. package/dist/icons/paymentMethods/Nexi.js +17 -0
  57. package/dist/icons/paymentMethods/Swish.d.ts +3 -0
  58. package/dist/icons/paymentMethods/Swish.d.ts.map +1 -0
  59. package/dist/icons/paymentMethods/Swish.js +127 -0
  60. package/dist/icons/paymentMethods/Wero.d.ts +3 -0
  61. package/dist/icons/paymentMethods/Wero.d.ts.map +1 -0
  62. package/dist/icons/paymentMethods/Wero.js +15 -0
  63. package/dist/icons/paymentMethods/index.d.ts +4 -0
  64. package/dist/icons/paymentMethods/index.d.ts.map +1 -1
  65. package/dist/icons/paymentMethods/index.js +112 -104
  66. package/dist/index.js +412 -404
  67. package/dist/mutations/addInformationToCart.d.ts +2 -5
  68. package/dist/mutations/addInformationToCart.d.ts.map +1 -1
  69. package/dist/mutations/addInformationToOrder.d.ts +2 -5
  70. package/dist/mutations/addInformationToOrder.d.ts.map +1 -1
  71. package/dist/steps/informationStep.d.ts +1 -0
  72. package/dist/steps/informationStep.d.ts.map +1 -1
  73. package/dist/steps/informationStep.js +271 -245
  74. package/dist/steps/paymentStep.d.ts.map +1 -1
  75. package/dist/steps/paymentStep.js +23 -23
  76. package/dist/steps/reviewStep.d.ts.map +1 -1
  77. package/dist/steps/reviewStep.js +13 -12
  78. package/dist/steps/shippingStep.d.ts.map +1 -1
  79. package/dist/steps/shippingStep.js +19 -19
  80. package/dist/types.d.ts +39 -11
  81. package/dist/types.d.ts.map +1 -1
  82. package/dist/utils/formatAddressPayload.d.ts +5 -2
  83. package/dist/utils/formatAddressPayload.d.ts.map +1 -1
  84. package/dist/utils/formatAddressPayload.js +24 -24
  85. package/dist/utils/formatAddressResponse.d.ts +1 -0
  86. package/dist/utils/formatAddressResponse.d.ts.map +1 -1
  87. package/dist/utils/formatInformationStepPayload.d.ts +2 -2
  88. package/dist/utils/formatInformationStepPayload.d.ts.map +1 -1
  89. package/dist/utils/formatUpdateAccountInformationPayload.d.ts +7 -2
  90. package/dist/utils/formatUpdateAccountInformationPayload.d.ts.map +1 -1
  91. package/dist/utils/formatUpdateAccountInformationPayload.js +3 -1
  92. package/dist/utils/formatUpdateOrganisationOnAccountPayload.d.ts +16 -3
  93. package/dist/utils/formatUpdateOrganisationOnAccountPayload.d.ts.map +1 -1
  94. package/dist/utils/formatUpdateOrganisationOnAccountPayload.js +7 -5
  95. package/dist/utils/setupCustomValidationRules.d.ts.map +1 -1
  96. package/dist/utils/setupCustomValidationRules.js +15 -15
  97. package/package.json +6 -6
  98. package/dist/modules.d.js +0 -1
@@ -1,34 +1,34 @@
1
- import { CheckoutInformationStep as ni } from "../CheckoutInformationStep/CheckoutInformationStep.js";
1
+ import { CheckoutInformationStep as si } from "../CheckoutInformationStep/CheckoutInformationStep.js";
2
2
  import { addressDefaultValues as q } from "../constants/addressDefaultValues.js";
3
- import { formatAddressResponse as j } from "../utils/formatAddressResponse.js";
4
- import { getErrorMessage as W } from "../utils/getErrorMessage.js";
5
- import { capitalize as X, isDefined as D } from "@afosto/utils";
3
+ import { formatAddressResponse as F } from "../utils/formatAddressResponse.js";
4
+ import { getErrorMessage as X } from "../utils/getErrorMessage.js";
5
+ import { capitalize as Y, isDefined as D } from "@afosto/utils";
6
6
  import * as u from "yup";
7
- import { formatUpdateAccountInformationPayload as si } from "../utils/formatUpdateAccountInformationPayload.js";
8
- import { formatUpdateOrganisationOnAccountPayload as ri } from "../utils/formatUpdateOrganisationOnAccountPayload.js";
9
- import { setupCustomValidationRules as ti } from "../utils/setupCustomValidationRules.js";
10
- import { formatInformationStepPayload as oi } from "../utils/formatInformationStepPayload.js";
11
- ti();
12
- const ai = {
7
+ import { formatUpdateAccountInformationPayload as ri } from "../utils/formatUpdateAccountInformationPayload.js";
8
+ import { formatUpdateOrganisationOnAccountPayload as ti } from "../utils/formatUpdateOrganisationOnAccountPayload.js";
9
+ import { setupCustomValidationRules as oi } from "../utils/setupCustomValidationRules.js";
10
+ import { formatInformationStepPayload as ai } from "../utils/formatInformationStepPayload.js";
11
+ oi();
12
+ const P = (y, r) => r ? y(r) : null, di = {
13
13
  signUpFailedTitle: "Sign up failed",
14
14
  signUpFailedDescription: "Failed to create an account. Try again or continue as guest.",
15
15
  signUpFailedActionLabel: "Continue as guest",
16
16
  informationStepErrorTitle: "Could not process information",
17
17
  informationStepErrorDescription: "Something went wrong while processing the contact and address information. Please check your input and try again."
18
- }, yi = {
18
+ }, fi = {
19
19
  key: "information",
20
20
  label: "Information",
21
- component: ni,
21
+ component: si,
22
22
  reviewTargets: [
23
23
  "contactDetails",
24
24
  "businessDetails",
25
25
  "shippingAddress",
26
26
  "billingAddress"
27
27
  ],
28
- defaultValues: (S) => {
29
- const { defaultCountry: a, formatCountryAsOption: v, settings: O } = S || {}, { isB2cExcluded: y, isSharedOrganisationRequired: s } = O || {};
28
+ defaultValues: (y) => {
29
+ const { defaultCountry: r, formatCountryAsOption: v, settings: O } = y || {}, { isB2cExcluded: f, isSharedOrganisationRequired: s } = O || {};
30
30
  return {
31
- type: y ? "business" : "private",
31
+ type: f ? "business" : "private",
32
32
  contact: null,
33
33
  email: "",
34
34
  emailOptIn: !1,
@@ -38,115 +38,122 @@ const ai = {
38
38
  cocNumber: "",
39
39
  type: s ? "SHARED" : "DEFAULT",
40
40
  vatNumber: "",
41
- vatNumberCountry: y && a ? v(a) : null
41
+ vatNumberCountry: f && r ? v(r) : null
42
42
  },
43
43
  password: "",
44
44
  passwordConfirm: "",
45
45
  phoneNumber: "",
46
- phoneNumberCountry: a ? v(a) : null,
46
+ phoneNumberCountry: r ? v(r) : null,
47
47
  phoneNumberId: "",
48
48
  phoneNumberIsDirty: !1,
49
49
  sameBillingAsShippingAddress: !0,
50
50
  shipping: {
51
51
  ...q,
52
- country: a ? v(a) : null,
53
- countryCode: a ? a.alpha2Code : ""
52
+ country: r ? v(r) : null,
53
+ countryCode: r ? r.alpha2Code : ""
54
54
  },
55
55
  shippingAddressId: "",
56
56
  billing: {
57
57
  ...q,
58
- country: a ? v(a) : null,
59
- countryCode: a ? a.alpha2Code : ""
58
+ country: r ? v(r) : null,
59
+ countryCode: r ? r.alpha2Code : ""
60
60
  },
61
61
  billingAddressId: "",
62
62
  shouldCreateAccount: !1
63
63
  };
64
64
  },
65
- initialize: (S, a, v) => {
65
+ initialize: (y, r, v) => {
66
66
  const {
67
67
  defaultCountry: O,
68
- formatCountryAsOption: y,
68
+ formatCountryAsOption: f,
69
69
  getCountryByCode: s,
70
- settings: f,
70
+ settings: C,
71
71
  step: g
72
- } = v || {}, { defaultValues: C } = g || {}, { addressOptions: B } = a || {}, { countryCode: N } = B || {}, { isB2bExcluded: U, isB2cExcluded: $ } = f || {}, n = typeof C == "function" ? C(v) : C, {
73
- billing: M,
72
+ } = v || {}, { defaultValues: N } = g || {}, { addressOptions: B } = r || {}, { countryCode: A } = B || {}, { isB2bExcluded: T, isB2cExcluded: z } = C || {}, n = typeof N == "function" ? N(v) : N, {
73
+ billing: H,
74
74
  customer: e,
75
75
  delivery: m,
76
76
  expressPayment: b,
77
77
  options: i,
78
- phoneNumber: o
79
- } = S || {}, {
80
- contact: t,
78
+ phoneNumber: a
79
+ } = y || {}, {
80
+ contact: o,
81
81
  countryCode: d,
82
- organisation: r
83
- } = e || {}, { address: A } = M || {}, { address: P } = m || {}, { address: E, customer: p } = b?.details?.express || {}, { shipping: x } = i || {}, { countries: V } = x || {}, I = s(N) || O, R = s(d), c = !!r?.id && !U || $, _ = c ? r?.phoneNumbers?.primary : t?.phoneNumbers?.primary, w = s(
84
- o?.countryCode || _?.countryCode
85
- ) || R || I || null, [L] = w?.callingCodes || [], k = (D(o?.number) ? o.number : _?.number || n.phoneNumber).replace(`+${L}`, ""), T = c ? r?.addressing?.shipping?.primary : t?.addressing?.shipping?.primary, l = j(
86
- P?.addressLine1 ? P : E || T || {}
82
+ organisation: t
83
+ } = e || {}, { address: I } = H || {}, { address: _ } = m || {}, { address: x, customer: p } = b?.details?.express || {}, { shipping: U } = i || {}, { countries: V } = U || {}, S = s(A) || O, R = s(d), c = !!t?.id && !T || z, w = c ? t?.phoneNumbers?.primary : o?.phoneNumbers?.primary, L = s(
84
+ a?.countryCode || w?.countryCode
85
+ ) || R || S || null, [E] = L?.callingCodes || [], j = (D(a?.number) ? a.number : w?.number || n.phoneNumber).replace(`+${E}`, ""), k = c ? t?.addressing?.shipping?.primary : o?.addressing?.shipping?.primary, l = F(
86
+ _?.addressLine1 ? _ : x || k || {}
87
87
  );
88
- let G = null;
88
+ let M = null;
89
89
  if (R && V?.includes(R?.alpha2Code))
90
- G = R;
91
- else if (I && V?.includes(I?.alpha2Code))
92
- G = I;
90
+ M = R;
91
+ else if (S && V?.includes(S?.alpha2Code))
92
+ M = S;
93
93
  else {
94
- const [ei] = V || [];
95
- G = s(ei);
94
+ const [ni] = V || [];
95
+ M = s(ni);
96
96
  }
97
- const J = s(l?.countryCode) || G, F = D(J) ? y(J) : n.shipping.country, z = l?.administrativeArea || n.shipping.administrativeArea, Y = z && typeof z == "string" ? {
98
- code: z,
99
- label: z,
100
- value: z
101
- } : z, Z = c ? r?.addressing?.billing?.primary : t?.addressing?.billing?.primary, h = j(
102
- A?.addressLine1 ? A : Z || {}
103
- ), K = s(h?.countryCode) || I, Q = D(K) ? y(K) : n.billing.country, H = h?.administrativeArea || n.billing.administrativeArea, ii = H && typeof H == "string" ? {
104
- code: H,
105
- label: H,
106
- value: H
107
- } : H;
97
+ const G = s(l?.countryCode ?? "") || M, $ = D(G) ? f(G) : n.shipping.country, J = l?.administrativeArea || n.shipping.administrativeArea, Z = typeof J == "string" ? {
98
+ code: J,
99
+ label: J,
100
+ value: J
101
+ } : J, ii = c ? t?.addressing?.billing?.primary : o?.addressing?.billing?.primary, h = F(
102
+ I?.addressLine1 ? I : ii || {}
103
+ ), Q = s(h?.countryCode ?? "") || S, W = D(Q) ? f(Q) : n.billing.country, K = h?.administrativeArea || n.billing.administrativeArea, ei = typeof K == "string" ? {
104
+ code: K,
105
+ label: K,
106
+ value: K
107
+ } : K;
108
108
  return {
109
109
  ...n,
110
- defaultCountry: y(I),
110
+ defaultCountry: P(
111
+ f,
112
+ S
113
+ ),
111
114
  type: c ? "business" : "private",
112
- contact: t || null,
113
- email: c ? r?.administration?.email || t?.email || p?.email || n.email : t?.email || p?.email || n.email,
115
+ contact: o || null,
116
+ email: c ? t?.administration?.email || o?.email || p?.email || n.email : o?.email || p?.email || n.email,
114
117
  organisation: {
115
118
  ...n.organisation,
116
119
  ...c ? {
117
- id: r?.id || n.organisation.id,
118
- name: r?.name || n.organisation.name,
119
- cocNumber: r?.cocNumber || n.organisation.cocNumber,
120
- type: r?.type || n.organisation.type,
121
- vatNumber: r?.vatNumber || n.organisation.vatNumber,
122
- vatNumberCountry: y(
123
- s(r?.registration?.countryCode) || I
120
+ id: t?.id || n.organisation.id,
121
+ name: t?.name || n.organisation.name,
122
+ cocNumber: t?.cocNumber || n.organisation.cocNumber,
123
+ type: t?.type || n.organisation.type,
124
+ vatNumber: t?.vatNumber || n.organisation.vatNumber,
125
+ vatNumberCountry: P(
126
+ f,
127
+ s(t?.registration?.countryCode) || S
124
128
  )
125
129
  } : {
126
- vatNumberCountry: y(I)
130
+ vatNumberCountry: P(
131
+ f,
132
+ S
133
+ )
127
134
  }
128
135
  },
129
- phoneNumber: k,
130
- phoneNumberCountry: D(w) ? y(w) : n.phoneNumberCountry,
131
- phoneNumberId: o?.id || _?.id || n.phoneNumberId,
136
+ phoneNumber: j,
137
+ phoneNumberCountry: D(L) ? f(L) : n.phoneNumberCountry,
138
+ phoneNumberId: a?.id || w?.id || n.phoneNumberId,
132
139
  shipping: {
133
140
  ...n.shipping,
134
- givenName: l?.givenName || (c ? void 0 : t?.givenName) || n.shipping.givenName,
135
- additionalName: l?.additionalName || (c ? void 0 : t?.additionalName) || n.shipping.additionalName,
136
- familyName: l?.familyName || (c ? void 0 : t?.familyName) || n.shipping.familyName,
141
+ givenName: l?.givenName || (c ? void 0 : o?.givenName) || n.shipping.givenName,
142
+ additionalName: l?.additionalName || (c ? void 0 : o?.additionalName) || n.shipping.additionalName,
143
+ familyName: l?.familyName || (c ? void 0 : o?.familyName) || n.shipping.familyName,
137
144
  address_line_1: l?.address_line_1 || n.shipping.address_line_1,
138
145
  address_line_2: l?.address_line_2 || n.shipping.address_line_2,
139
146
  addressLine1: l?.addressLine1 || n.shipping.addressLine1,
140
147
  addressLine2: l?.addressLine2 || n.shipping.addressLine2,
141
- country: F,
142
- countryCode: F?.value || n.shipping.countryCode,
148
+ country: $,
149
+ countryCode: $?.value || n.shipping.countryCode,
143
150
  organisation: l?.organisation || n.shipping.organisation,
144
151
  postalCode: l?.postalCode || n.shipping.postalCode,
145
152
  premiseNumber: l?.premiseNumber || n.shipping.premiseNumber,
146
153
  premiseNumberSuffix: l?.premiseNumberSuffix || n.shipping.premiseNumberSuffix,
147
154
  thoroughfare: l?.thoroughfare || n.shipping.thoroughfare,
148
155
  locality: l?.locality || n.shipping.locality,
149
- administrativeArea: Y
156
+ administrativeArea: Z
150
157
  },
151
158
  shippingAddressId: l?.id || n.shippingAddressId,
152
159
  billing: {
@@ -158,78 +165,85 @@ const ai = {
158
165
  address_line_2: h?.address_line_2 || n.billing.address_line_2,
159
166
  addressLine1: h?.addressLine1 || n.billing.addressLine1,
160
167
  addressLine2: h?.addressLine2 || n.billing.addressLine2,
161
- country: Q,
162
- countryCode: Q?.value || n.billing.countryCode,
168
+ country: W,
169
+ countryCode: W?.value || n.billing.countryCode,
163
170
  organisation: h?.organisation || n.billing.organisation,
164
171
  postalCode: h?.postalCode || n.billing.postalCode,
165
172
  premiseNumber: h?.premiseNumber || n.billing.premiseNumber,
166
173
  premiseNumberSuffix: h?.premiseNumberSuffix || n.billing.premiseNumberSuffix,
167
174
  thoroughfare: h?.thoroughfare || n.billing.thoroughfare,
168
175
  locality: h?.locality || n.billing.locality,
169
- administrativeArea: ii
176
+ administrativeArea: ei
170
177
  },
171
178
  billingAddressId: h?.id || n.billingAddressId,
172
179
  sameBillingAsShippingAddress: D(h?.id) && D(l?.id) ? h?.id === l?.id : n.sameBillingAsShippingAddress
173
180
  };
174
181
  },
175
- isComplete: (S, a) => {
176
- const { step: v } = a || {};
177
- return v.validationSchema(a).isValidSync(S);
182
+ isComplete: (y, r) => {
183
+ const { step: v } = r || {};
184
+ return v.validationSchema(r).isValidSync(y);
178
185
  },
179
- onEvent: async (S, a, v, O) => {
180
- const { step: y, stepIndex: s } = v || {}, {
181
- activeStep: f,
186
+ onEvent: async (y, r, v, O) => {
187
+ const { step: f, stepIndex: s } = v || {}, {
188
+ activeStep: C,
182
189
  addCustomer: g,
183
- formRef: C,
190
+ formRef: N,
184
191
  formatCountryAsOption: B,
185
- getCountryByCode: N,
186
- settings: U
187
- } = O || {}, { isB2bExcluded: $, isB2cExcluded: n } = U || {}, M = C.current?.formProps?.data || [], e = f === s ? C.current?.getValues() : M[s] ?? {}, m = typeof y.defaultValues == "function" ? y.defaultValues(O) : y.defaultValues;
188
- if (S === "signedIn") {
189
- const { user: b, account: i } = a || {};
190
- let o = e?.contact;
191
- b?.id && e?.contact?.id !== b?.id && (o = (await g({
192
+ getCountryByCode: A,
193
+ settings: T
194
+ } = O || {}, { isB2bExcluded: z, isB2cExcluded: n } = T || {}, H = N.current?.formProps?.data || [], e = (C === s ? N.current?.getValues() : H[s]) ?? {}, m = typeof f.defaultValues == "function" ? f.defaultValues(O) : f.defaultValues;
195
+ if (y === "signedIn") {
196
+ const { user: b, account: i } = r;
197
+ let a = e?.contact;
198
+ b?.id && e?.contact?.id !== b?.id && (a = (await g({
192
199
  customer: {
193
200
  contactId: b.id
194
201
  }
195
202
  }))?.customer?.contact);
196
- const [t] = i?.billing || [], [d] = i?.shipping || [], [r] = i?.organisations || [], [A] = i?.phoneNumbers || [], P = N(A?.countryCode) || e?.defaultCountry, [E] = P?.callingCodes || [], p = d ? j(d) : null, {
197
- id: x,
203
+ const [o] = i?.billing || [], [d] = i?.shipping || [], [t] = i?.organisations || [], [I] = i?.phoneNumbers || [], _ = A(I?.countryCode) || e?.defaultCountry, [x] = _?.callingCodes || [], p = d ? F(d) : {}, {
204
+ id: U,
198
205
  isValid: V,
199
- ...I
200
- } = p || {}, R = I?.countryCode ? B(N(I.countryCode)) : e?.defaultCountry, c = t ? j(t) : null, {
201
- id: _,
202
- isValid: w,
203
- ...L
204
- } = c || {}, k = L?.countryCode ? B(N(L.countryCode)) : e?.defaultCountry, T = !$ && r?.id || n, l = T && r?.administration?.email || i?.email, J = {
206
+ ...S
207
+ } = p, R = S?.countryCode ? P(
208
+ B,
209
+ A(S.countryCode)
210
+ ) : e?.defaultCountry, c = o ? F(o) : {}, {
211
+ id: w,
212
+ isValid: L,
213
+ ...E
214
+ } = c, j = E?.countryCode ? P(
215
+ B,
216
+ A(E.countryCode)
217
+ ) : e?.defaultCountry, k = !z && t?.id || n, l = k && t?.administration?.email || i?.email, G = {
205
218
  ...e,
206
219
  ...m || {},
207
- contact: o,
220
+ contact: a,
208
221
  email: l,
209
- type: T ? "business" : "private",
210
- ...A ? {
211
- phoneNumber: A.number?.replace(
212
- `+${E}`,
222
+ type: k ? "business" : "private",
223
+ ...I ? {
224
+ phoneNumber: I.number?.replace(
225
+ `+${x}`,
213
226
  ""
214
227
  ),
215
- phoneNumberCountry: P,
216
- phoneNumberId: A?.id || ""
228
+ phoneNumberCountry: _,
229
+ phoneNumberId: I?.id || ""
217
230
  } : {
218
231
  phoneNumberCountry: e.defaultCountry
219
232
  },
220
- organisation: T ? {
233
+ organisation: k ? {
221
234
  ...e?.organisation || {},
222
235
  ...m?.organisation || {},
223
- id: r?.id || "",
224
- name: r?.name || "",
225
- cocNumber: r?.cocNumber || "",
236
+ id: t?.id || "",
237
+ name: t?.name || "",
238
+ cocNumber: t?.cocNumber || "",
226
239
  isCocNumberRequired: e?.organisation?.isCocNumberRequired ?? !1,
227
240
  isVatNumberRequired: e?.organisation?.isVatNumberRequired ?? !1,
228
- type: r?.type || "DEFAULT",
229
- vatNumber: r?.registration?.number || "",
230
- vatNumberCountry: B(
231
- N(
232
- r?.registration?.countryCode
241
+ type: t?.type || "DEFAULT",
242
+ vatNumber: t?.registration?.number || "",
243
+ vatNumberCountry: P(
244
+ B,
245
+ A(
246
+ t?.registration?.countryCode
233
247
  ) || e?.defaultCountry
234
248
  )
235
249
  } : {
@@ -239,85 +253,91 @@ const ai = {
239
253
  isVatNumberRequired: e?.organisation?.isVatNumberRequired ?? !1,
240
254
  vatNumberCountry: e.defaultCountry
241
255
  },
242
- billing: t ? {
256
+ billing: o ? {
243
257
  ...e.billing,
244
258
  ...q,
245
- ...L,
246
- country: k
259
+ ...E,
260
+ country: j
247
261
  } : {
248
262
  ...e.billing,
249
263
  ...q,
250
264
  country: e.defaultCountry
251
265
  },
252
- billingAddressId: _ || "",
266
+ billingAddressId: w || "",
253
267
  shipping: d ? {
254
268
  ...e.shipping,
255
269
  ...q,
256
- ...I,
270
+ ...S,
257
271
  country: R
258
272
  } : {
259
273
  ...e.shipping,
260
274
  ...q,
261
275
  country: e.defaultCountry
262
276
  },
263
- shippingAddressId: x || "",
264
- sameBillingAsShippingAddress: D(_) || D(_) && _ === x
277
+ shippingAddressId: U || "",
278
+ sameBillingAsShippingAddress: D(w) || D(w) && w === U
265
279
  };
266
- i && (f === s && C.current?.reset({
280
+ i && (C === s && N.current?.reset({
267
281
  ...e,
268
- ...J
269
- }), C.current?.formProps?.setData((F) => (F.splice(s, 1, {
270
- ...F[s],
271
- ...J
272
- }), F)));
282
+ ...G
283
+ }), N.current?.formProps?.setData(($) => ($.splice(s, 1, {
284
+ ...$[s],
285
+ ...G
286
+ }), $)));
273
287
  }
274
- if (S === "clearSession") {
275
- const { sessionExpired: b, shouldCreateAccount: i } = a || {}, o = {
288
+ if (y === "clearSession") {
289
+ const { sessionExpired: b, shouldCreateAccount: i } = r, a = {
276
290
  ...e,
277
291
  ...b ? m || {} : {},
278
292
  shouldCreateAccount: i ?? !1
279
293
  };
280
- f === s && C.current?.reset({
294
+ C === s && N.current?.reset({
281
295
  ...e,
282
- ...o
283
- }), C.current?.formProps?.setData((t) => (t.splice(s, 1, {
284
- ...t[s],
285
- ...o
286
- }), t));
296
+ ...a
297
+ }), N.current?.formProps?.setData((o) => (o.splice(s, 1, {
298
+ ...o[s],
299
+ ...a
300
+ }), o));
287
301
  }
288
- if (S === "accountSelected") {
289
- const { account: b, user: i } = a || {}, [o] = b?.billing || [], [t] = b?.shipping || [], [d] = b?.organisations || [], [r] = b?.phoneNumbers || [], A = N(r?.countryCode) || e?.defaultCountry, [P] = A?.callingCodes || [], E = t ? j(t) : null, {
302
+ if (y === "accountSelected") {
303
+ const { account: b, user: i } = r, [a] = b?.billing || [], [o] = b?.shipping || [], [d] = b?.organisations || [], [t] = b?.phoneNumbers || [], I = A(t?.countryCode) || e?.defaultCountry, [_] = I?.callingCodes || [], x = o ? F(o) : {}, {
290
304
  id: p,
291
- isValid: x,
305
+ isValid: U,
292
306
  ...V
293
- } = E || {}, I = V?.countryCode ? B(N(V.countryCode)) : e?.defaultCountry, R = o ? j(o) : null, {
307
+ } = x, S = V?.countryCode ? P(
308
+ B,
309
+ A(V.countryCode)
310
+ ) : e?.defaultCountry, R = a ? F(a) : {}, {
294
311
  id: c,
295
- isValid: _,
296
- ...w
297
- } = R || {}, L = w?.countryCode ? B(N(w.countryCode)) : e?.defaultCountry, k = !$ && d?.id || n;
312
+ isValid: w,
313
+ ...L
314
+ } = R, E = L?.countryCode ? P(
315
+ B,
316
+ A(L.countryCode)
317
+ ) : e?.defaultCountry, j = !z && d?.id || n;
298
318
  await g({
299
319
  customer: {
300
320
  contactId: i.id,
301
- ...k && d?.id ? { organisationId: d?.id } : {}
321
+ ...j && d?.id ? { organisationId: d?.id } : {}
302
322
  }
303
323
  });
304
- const T = {
324
+ const k = {
305
325
  ...e,
306
326
  ...m || {},
307
327
  contact: e?.contact,
308
- email: k && d?.administration?.email || b?.email,
309
- type: k ? "business" : "private",
310
- ...r ? {
311
- phoneNumber: r.number?.replace(
312
- `+${P}`,
328
+ email: j && d?.administration?.email || b?.email,
329
+ type: j ? "business" : "private",
330
+ ...t ? {
331
+ phoneNumber: t.number?.replace(
332
+ `+${_}`,
313
333
  ""
314
334
  ),
315
- phoneNumberCountry: A,
316
- phoneNumberId: r?.id || ""
335
+ phoneNumberCountry: I,
336
+ phoneNumberId: t?.id || ""
317
337
  } : {
318
338
  phoneNumberCountry: e.defaultCountry
319
339
  },
320
- organisation: k ? {
340
+ organisation: j ? {
321
341
  ...e?.organisation || {},
322
342
  ...m?.organisation || {},
323
343
  id: d?.id || "",
@@ -327,8 +347,9 @@ const ai = {
327
347
  isVatNumberRequired: e?.organisation?.isVatNumberRequired ?? !1,
328
348
  type: d?.type || "DEFAULT",
329
349
  vatNumber: d?.registration?.number || "",
330
- vatNumberCountry: B(
331
- N(
350
+ vatNumberCountry: P(
351
+ B,
352
+ A(
332
353
  d?.registration?.countryCode
333
354
  ) || e?.defaultCountry
334
355
  )
@@ -339,22 +360,22 @@ const ai = {
339
360
  isVatNumberRequired: e?.organisation?.isVatNumberRequired ?? !1,
340
361
  vatNumberCountry: e.defaultCountry
341
362
  },
342
- billing: o ? {
363
+ billing: a ? {
343
364
  ...e.billing,
344
365
  ...q,
345
- ...w,
346
- country: L
366
+ ...L,
367
+ country: E
347
368
  } : {
348
369
  ...e.billing,
349
370
  ...q,
350
371
  country: e.defaultCountry
351
372
  },
352
373
  billingAddressId: c || "",
353
- shipping: t ? {
374
+ shipping: o ? {
354
375
  ...e.shipping,
355
376
  ...q,
356
377
  ...V,
357
- country: I
378
+ country: S
358
379
  } : {
359
380
  ...e.shipping,
360
381
  ...q,
@@ -363,47 +384,49 @@ const ai = {
363
384
  shippingAddressId: p || "",
364
385
  sameBillingAsShippingAddress: !D(c) || D(c) && c === p
365
386
  };
366
- f === s && C.current?.reset({
387
+ C === s && N.current?.reset({
367
388
  ...e,
368
- ...T
369
- }), C.current?.formProps?.setData((l) => (l.splice(s, 1, {
389
+ ...k
390
+ }), N.current?.formProps?.setData((l) => (l.splice(s, 1, {
370
391
  ...l[s],
371
- ...T
392
+ ...k
372
393
  }), l));
373
394
  }
374
- if (S === "businessAccountSelected") {
375
- const { account: b, organisation: i, user: o } = a || {};
395
+ if (y === "businessAccountSelected") {
396
+ const { account: b, organisation: i, user: a } = r;
376
397
  await g({
377
398
  customer: {
378
- contactId: o.id,
399
+ contactId: a.id,
379
400
  organisationId: i?.id
380
401
  }
381
402
  });
382
- const t = i?.addressing?.billing?.primary ? j(i?.addressing?.billing?.primary) : null, {
403
+ const o = i?.addressing?.billing?.primary ? F(i?.addressing?.billing?.primary) : {}, {
383
404
  id: d,
384
- isValid: r,
385
- ...A
386
- } = t || {}, P = A?.countryCode ? B(
387
- N(A.countryCode)
388
- ) : e?.defaultCountry, E = i?.addressing?.shipping?.primary ? j(i?.addressing?.shipping?.primary) : null, {
405
+ isValid: t,
406
+ ...I
407
+ } = o, _ = I?.countryCode ? P(
408
+ B,
409
+ A(I.countryCode)
410
+ ) : e?.defaultCountry, x = i?.addressing?.shipping?.primary ? F(i?.addressing?.shipping?.primary) : {}, {
389
411
  id: p,
390
- isValid: x,
412
+ isValid: U,
391
413
  ...V
392
- } = E || {}, I = V?.countryCode ? B(
393
- N(V.countryCode)
394
- ) : e?.defaultCountry, R = i?.phoneNumbers?.primary, c = N(R?.countryCode) || e?.defaultCountry, [_] = c?.callingCodes || [], w = {
414
+ } = x, S = V?.countryCode ? P(
415
+ B,
416
+ A(V.countryCode)
417
+ ) : e?.defaultCountry, R = i?.phoneNumbers?.primary, c = A(R?.countryCode) || e?.defaultCountry, [w] = c?.callingCodes || [], L = {
395
418
  ...e,
396
419
  ...m || {}
397
420
  };
398
- f === s && C.current?.reset({
421
+ C === s && N.current?.reset({
399
422
  ...e,
400
- ...w,
423
+ ...L,
401
424
  contact: e?.contact,
402
425
  email: i?.administration?.email || b?.email || "",
403
426
  type: "business",
404
427
  ...R ? {
405
428
  phoneNumber: R?.number?.replace(
406
- `+${_}`,
429
+ `+${w}`,
407
430
  ""
408
431
  ),
409
432
  phoneNumberCountry: c,
@@ -421,8 +444,9 @@ const ai = {
421
444
  isVatNumberRequired: e?.organisation?.isVatNumberRequired ?? !1,
422
445
  type: i?.type || "SHARED",
423
446
  vatNumber: i?.registration?.number || "",
424
- vatNumberCountry: B(
425
- N(i?.registration?.countryCode) || e?.defaultCountry
447
+ vatNumberCountry: P(
448
+ B,
449
+ A(i?.registration?.countryCode) || e?.defaultCountry
426
450
  )
427
451
  } : {
428
452
  ...e?.organisation || {},
@@ -431,22 +455,22 @@ const ai = {
431
455
  isVatNumberRequired: e?.organisation?.isVatNumberRequired ?? !1,
432
456
  vatNumberCountry: e.defaultCountry
433
457
  },
434
- billing: t ? {
458
+ billing: o ? {
435
459
  ...e.billing,
436
460
  ...q,
437
- ...A,
438
- country: P
461
+ ...I,
462
+ country: _
439
463
  } : {
440
464
  ...e.billing,
441
465
  ...q,
442
466
  country: e.defaultCountry
443
467
  },
444
468
  billingAddressId: d || "",
445
- shipping: E ? {
469
+ shipping: x ? {
446
470
  ...e.shipping,
447
471
  ...q,
448
472
  ...V,
449
- country: I
473
+ country: S
450
474
  } : {
451
475
  ...e.shipping,
452
476
  ...q,
@@ -454,39 +478,39 @@ const ai = {
454
478
  },
455
479
  shippingAddressId: p || "",
456
480
  sameBillingAsShippingAddress: !D(d) || D(d) && d === p
457
- }), C.current?.formProps?.setData((L) => (L.splice(s, 1, {
458
- ...L[s],
459
- ...w
460
- }), L));
481
+ }), N.current?.formProps?.setData((E) => (E.splice(s, 1, {
482
+ ...E[s],
483
+ ...L
484
+ }), E));
461
485
  }
462
486
  },
463
- submit: async (S, a, v) => {
487
+ submit: async (y, r, v) => {
464
488
  const {
465
489
  activeStep: O,
466
- addInformation: y,
490
+ addInformation: f,
467
491
  currentOrganisation: s,
468
- formRef: f,
492
+ formRef: C,
469
493
  getCountryByCode: g,
470
- getUser: C,
494
+ getUser: N,
471
495
  isSignedIn: B,
472
- setCurrentOrganisation: N,
473
- setErrorMessage: U,
474
- signUp: $,
496
+ setCurrentOrganisation: A,
497
+ setErrorMessage: T,
498
+ signUp: z,
475
499
  translations: n = {},
476
- updateAccountInformation: M,
500
+ updateAccountInformation: H,
477
501
  updateOrganisationOnAccount: e
478
502
  } = v || {}, m = {
479
- ...ai,
503
+ ...di,
480
504
  ...n.feedback || {}
481
- }, { shouldCreateAccount: b } = S || {};
505
+ }, { shouldCreateAccount: b } = y || {};
482
506
  try {
483
- U(null);
484
- const i = oi(S, {
507
+ T(null);
508
+ const i = ai(y, {
485
509
  currentOrganisation: s,
486
510
  isSignedIn: B
487
- }), o = C();
511
+ }), a = N();
488
512
  if (b) {
489
- const p = await $({
513
+ const p = await z({
490
514
  givenName: i?.shipping?.givenName,
491
515
  additionalName: i?.shipping?.additionalName,
492
516
  familyName: i?.shipping?.familyName,
@@ -497,28 +521,28 @@ const ai = {
497
521
  shipping: i?.shippingAddress ? [i.shippingAddress] : []
498
522
  },
499
523
  ...i?.phoneNumber ? { phoneNumber: i?.phoneNumber } : {}
500
- }).catch((x) => {
501
- const V = W(x);
502
- return U({
503
- title: m.feedback?.signUpFailedTitle,
504
- description: V ? X(V) : m.feedback?.signUpFailedDescription,
524
+ }).catch((U) => {
525
+ const V = X(U);
526
+ return T({
527
+ title: m.signUpFailedTitle,
528
+ description: V ? Y(V) : m.signUpFailedDescription,
505
529
  action: {
506
- label: m.feedback?.signUpFailedActionLabel,
530
+ label: m.signUpFailedActionLabel,
507
531
  onClick: () => {
508
- U(null), f.current?.reset({
509
- ...f.current?.getValues() || {},
532
+ T(null), C.current?.reset({
533
+ ...C.current?.getValues() || {},
510
534
  shouldCreateAccount: !1
511
- }), f.current?.submitForm();
535
+ }), C.current?.submitForm();
512
536
  }
513
537
  }
514
- }), Promise.reject(x);
538
+ }), Promise.reject(U);
515
539
  });
516
540
  if (!p)
517
541
  return Promise.reject();
518
- delete i.customer.contact, i.customer.contactId = p.id, f.current?.setValue("shouldCreateAccount", !1);
542
+ delete i.customer.contact, i.customer.contactId = p.id, C.current?.setValue("shouldCreateAccount", !1);
519
543
  }
520
- if (o && !o?.organisation?.id) {
521
- const p = si(
544
+ if (a && !a?.organisation?.id) {
545
+ const p = ri(
522
546
  {
523
547
  billingAddress: i.billingAddress,
524
548
  billingAddressId: i.billingAddressId,
@@ -532,17 +556,19 @@ const ai = {
532
556
  shippingAddress: i.shippingAddress,
533
557
  shippingAddressId: i.shippingAddressId,
534
558
  type: i.type,
535
- user: o
559
+ user: a
536
560
  },
537
561
  {
538
562
  getCountryByCode: g
539
563
  }
540
564
  );
541
- p && await M(p).catch(() => {
565
+ p && await H(
566
+ p
567
+ ).catch(() => {
542
568
  });
543
569
  }
544
- if (o?.organisation?.id && o?.organisation?.role?.toLowerCase() === "admin") {
545
- const p = ri(
570
+ if (a?.organisation?.id && a?.organisation?.role?.toLowerCase() === "admin") {
571
+ const p = ti(
546
572
  {
547
573
  billingAddress: i.billingAddress,
548
574
  billingAddressId: i.billingAddressId,
@@ -556,48 +582,48 @@ const ai = {
556
582
  shippingAddress: i.shippingAddress,
557
583
  shippingAddressId: i.shippingAddressId,
558
584
  type: i.type,
559
- user: o
585
+ user: a
560
586
  },
561
587
  {
562
588
  getCountryByCode: g
563
589
  }
564
590
  );
565
- p && await e(p).catch(
566
- () => {
567
- }
568
- );
591
+ p && await e(
592
+ p
593
+ ).catch(() => {
594
+ });
569
595
  }
570
- const t = await y({
596
+ const o = await f({
571
597
  billingAddress: i.billingAddress,
572
598
  customer: i.customer,
573
599
  phoneNumber: i.phoneNumber,
574
600
  shippingAddress: i.shippingAddress
575
- }), { customer: d, billing: r, delivery: A, phoneNumber: P } = t || {}, { organisation: E } = d || {};
576
- return f.current?.formProps?.setData((p) => (p.splice(O, 1, {
601
+ }), { customer: d, billing: t, delivery: I, phoneNumber: _ } = o || {}, { organisation: x } = d || {};
602
+ return C.current?.formProps?.setData((p) => (p.splice(O, 1, {
577
603
  ...p[O],
578
604
  contact: d?.contact,
579
- billingAddressId: r?.address?.id,
580
- shippingAddressId: A?.address?.id,
581
- phoneNumberId: P?.id,
605
+ billingAddressId: t?.address?.id,
606
+ shippingAddressId: I?.address?.id,
607
+ phoneNumberId: _?.id,
582
608
  phoneNumberIsDirty: !1
583
- }), p)), N(E), t;
609
+ }), p)), A(x), o;
584
610
  } catch (i) {
585
- const o = W(i);
586
- return U({
587
- title: m.feedback?.informationStepErrorTitle,
588
- description: o ? X(o) : m.feedback?.informationStepErrorDescription
611
+ const a = X(i);
612
+ return T({
613
+ title: m.informationStepErrorTitle,
614
+ description: a ? Y(a) : m.informationStepErrorDescription
589
615
  }), Promise.reject(i);
590
616
  }
591
617
  },
592
- validationSchema: (S) => {
618
+ validationSchema: (y) => {
593
619
  const {
594
- billingAddressValidationSchema: a,
620
+ billingAddressValidationSchema: r,
595
621
  shippingAddressValidationSchema: v,
596
622
  settings: O
597
- } = S || {}, {
598
- isCocNumberRequired: y,
623
+ } = y || {}, {
624
+ isCocNumberRequired: f,
599
625
  isPhoneNumberRequired: s,
600
- isVatNumberRequired: f
626
+ isVatNumberRequired: C
601
627
  } = O || {};
602
628
  return u.object().shape({
603
629
  type: u.string().oneOf(["business", "private"]).required(),
@@ -620,20 +646,20 @@ const ai = {
620
646
  then: (g) => g.shape({
621
647
  id: u.string().nullable(),
622
648
  name: u.string().required(),
623
- cocNumber: y ? u.string().trim().required() : u.string().trim().nullable(),
624
- vatNumber: f ? u.string().trim().required() : u.string().trim().nullable(),
625
- vatNumberCountry: f ? u.object().nullable().required() : u.object().nullable()
649
+ cocNumber: f ? u.string().trim().required() : u.string().trim().nullable(),
650
+ vatNumber: C ? u.string().trim().required() : u.string().trim().nullable(),
651
+ vatNumberCountry: C ? u.object().nullable().required() : u.object().nullable()
626
652
  })
627
653
  }),
628
654
  sameBillingAsShippingAddress: u.boolean().nullable(),
629
655
  shipping: u.object().nullable().shape(v),
630
656
  billing: u.object().nullable().when("sameBillingAsShippingAddress", {
631
657
  is: !1,
632
- then: (g) => g.shape(a)
658
+ then: (g) => g.shape(r)
633
659
  })
634
660
  });
635
661
  }
636
662
  };
637
663
  export {
638
- yi as informationStep
664
+ fi as informationStep
639
665
  };