@afosto/checkout-ui 0.0.12 → 0.0.14

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