@alma/widgets 2.3.4 → 2.5.1

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 (36) hide show
  1. package/dist/raw/widgets.js +166 -75
  2. package/dist/raw/widgets.js.map +1 -1
  3. package/dist/raw/widgets.m.js +166 -75
  4. package/dist/raw/widgets.m.js.map +1 -1
  5. package/dist/raw/widgets.modern.js +163 -71
  6. package/dist/raw/widgets.modern.js.map +1 -1
  7. package/dist/raw/widgets.umd.js +166 -75
  8. package/dist/raw/widgets.umd.js.map +1 -1
  9. package/dist/types/Widgets/EligibilityModal/DesktopModal/index.d.ts +3 -1
  10. package/dist/types/Widgets/EligibilityModal/MobileModal/index.d.ts +3 -1
  11. package/dist/types/Widgets/EligibilityModal/ModalContainer.test.d.ts +1 -0
  12. package/dist/types/Widgets/EligibilityModal/classNames.const.d.ts +18 -0
  13. package/dist/types/Widgets/EligibilityModal/components/Title/index.d.ts +3 -1
  14. package/dist/types/Widgets/EligibilityModal/modal.test.d.ts +1 -0
  15. package/dist/types/Widgets/PaymentPlans/__tests__/Basics.test.d.ts +1 -0
  16. package/dist/types/Widgets/PaymentPlans/__tests__/Credit.test.d.ts +1 -0
  17. package/dist/types/Widgets/PaymentPlans/__tests__/CustomTransitionDelay.test.d.ts +1 -0
  18. package/dist/types/Widgets/PaymentPlans/__tests__/HideWidget.test.d.ts +1 -0
  19. package/dist/types/Widgets/PaymentPlans/__tests__/IneligibleOptions.test.d.ts +1 -0
  20. package/dist/types/Widgets/PaymentPlans/__tests__/LanguageCheck.test.d.ts +1 -0
  21. package/dist/types/Widgets/PaymentPlans/__tests__/LaunchModal.test.d.ts +1 -0
  22. package/dist/types/Widgets/PaymentPlans/__tests__/SuggestedPaymentPlan.test.d.ts +1 -0
  23. package/dist/types/Widgets/PaymentPlans/__tests__/WithoutPlans.test.d.ts +1 -0
  24. package/dist/types/Widgets/PaymentPlans/classNames.const.d.ts +13 -0
  25. package/dist/types/test/fixtures.d.ts +41 -0
  26. package/dist/types/types.d.ts +7 -1
  27. package/dist/types/utils/index.test.d.ts +1 -0
  28. package/dist/widgets.js +1 -1
  29. package/dist/widgets.js.map +1 -1
  30. package/dist/widgets.m.js +1 -1
  31. package/dist/widgets.m.js.map +1 -1
  32. package/dist/widgets.modern.js +1 -1
  33. package/dist/widgets.modern.js.map +1 -1
  34. package/dist/widgets.umd.js +1 -1
  35. package/dist/widgets.umd.js.map +1 -1
  36. package/package.json +1 -1
@@ -1815,8 +1815,9 @@ var messagesDE = {
1815
1815
  "eligibility-modal.credit-commitment": "Ein Kredit verpflichtet Sie und muss zurückgezahlt werden. Prüfen Sie Ihre Rückzahlungsfähigkeit, bevor Sie sich verpflichten.",
1816
1816
  "eligibility-modal.credit-cost": "Davon Kreditkosten",
1817
1817
  "eligibility-modal.credit-cost-amount": "{creditCost} (APR {TAEG})",
1818
- "eligibility-modal.no-eligibility": "Ups, die Simulation scheint nicht funktioniert zu haben.",
1819
- "eligibility-modal.title": "<highlighted>Bezahlen Sie in Raten</highlighted> oder später per Kreditkarte mit Alma.",
1818
+ "eligibility-modal.no-eligibility": "Ups, die Simulation hat anscheinend nicht funktioniert.",
1819
+ "eligibility-modal.title": "<highlighted>Bezahlen Sie in Raten</highlighted> per Kreditkarte mit Alma.",
1820
+ "eligibility-modal.title-deferred": "<highlighted>Bezahlen Sie in Raten</highlighted> oder später per Kreditkarte mit Alma.",
1820
1821
  "eligibility-modal.total": "Insgesamt",
1821
1822
  "installments.today": "Heutzutage",
1822
1823
  "payment-plan-strings.day-abbreviation": "J{numberOfDeferredDays}",
@@ -1838,7 +1839,8 @@ var messagesEN = {
1838
1839
  "eligibility-modal.credit-cost": "Of which cost of credit",
1839
1840
  "eligibility-modal.credit-cost-amount": "{creditCost} (APR {TAEG})",
1840
1841
  "eligibility-modal.no-eligibility": "Oops, looks like the simulation didn't work.",
1841
- "eligibility-modal.title": "<highlighted>Pay in installments</highlighted> or later by credit card with Alma.",
1842
+ "eligibility-modal.title": "<highlighted>Pay in installments</highlighted> by credit card with Alma.",
1843
+ "eligibility-modal.title-deferred": "<highlighted>Pay in installments</highlighted> or later by credit card with Alma.",
1842
1844
  "eligibility-modal.total": "Total",
1843
1845
  "installments.today": "Today",
1844
1846
  "payment-plan-strings.day-abbreviation": "T{numberOfDeferredDays}",
@@ -1860,7 +1862,8 @@ var messagesES = {
1860
1862
  "eligibility-modal.credit-cost": "Coste de crédito (incl. en el total)",
1861
1863
  "eligibility-modal.credit-cost-amount": "{creditCost} (TAE {TAEG})",
1862
1864
  "eligibility-modal.no-eligibility": "Uy, parece que la simulación no ha funcionado.",
1863
- "eligibility-modal.title": "<highlighted>Paga a plazos</highlighted> o más adelante con tu tarjeta, a través de Alma.",
1865
+ "eligibility-modal.title": "<highlighted>Paga a plazos</highlighted> con tarjeta de crédito con Alma.",
1866
+ "eligibility-modal.title-deferred": "<highlighted>Paga a plazos</highlighted> o más adelante con tu tarjeta, a través de Alma.",
1864
1867
  "eligibility-modal.total": "Total",
1865
1868
  "installments.today": "Hoy",
1866
1869
  "payment-plan-strings.day-abbreviation": "D{numberOfDeferredDays}",
@@ -1881,8 +1884,9 @@ var messagesFR = {
1881
1884
  "eligibility-modal.credit-commitment": "Un crédit vous engage et doit être remboursé. Vérifiez vos capacités de remboursement avant de vous engager.",
1882
1885
  "eligibility-modal.credit-cost": "Dont coût du crédit",
1883
1886
  "eligibility-modal.credit-cost-amount": "{creditCost} (TAEG {TAEG})",
1884
- "eligibility-modal.no-eligibility": "Oups, il semblerait que la simulation n'aie pas fonctionné.",
1885
- "eligibility-modal.title": "<highlighted>Payez en plusieurs fois</highlighted> ou plus tard par carte bancaire avec Alma.",
1887
+ "eligibility-modal.no-eligibility": "Oups, il semblerait que la simulation n'ait pas fonctionné.",
1888
+ "eligibility-modal.title": "<highlighted>Payez en plusieurs fois</highlighted> par carte bancaire avec Alma.",
1889
+ "eligibility-modal.title-deferred": "<highlighted>Payez en plusieurs fois</highlighted> ou plus tard par carte bancaire avec Alma.",
1886
1890
  "eligibility-modal.total": "Total",
1887
1891
  "installments.today": "Aujourd'hui",
1888
1892
  "payment-plan-strings.day-abbreviation": "J{numberOfDeferredDays}",
@@ -1904,7 +1908,8 @@ var messagesIT = {
1904
1908
  "eligibility-modal.credit-cost": "Di cui commissioni",
1905
1909
  "eligibility-modal.credit-cost-amount": "{creditCost} (TAEG {TAEG})",
1906
1910
  "eligibility-modal.no-eligibility": "Ops, sembra che la simulazione non abbia funzionato.",
1907
- "eligibility-modal.title": "<highlighted>Paga a rate</highlighted> e posticipa il pagamento con Alma, senza interessi.",
1911
+ "eligibility-modal.title": "<highlighted>Paga a rate</highlighted> con carta di credito con Alma.",
1912
+ "eligibility-modal.title-deferred": "<highlighted>Paga a rate</highlighted> e posticipa il pagamento con Alma, senza interessi.",
1908
1913
  "eligibility-modal.total": "Totale",
1909
1914
  "installments.today": "Oggi",
1910
1915
  "payment-plan-strings.day-abbreviation": "G{numberOfDeferredDays}",
@@ -1926,7 +1931,8 @@ var messagesNL = {
1926
1931
  "eligibility-modal.credit-cost": "Waarvan kosten van krediet",
1927
1932
  "eligibility-modal.credit-cost-amount": "{creditCost} (APR {TAEG})",
1928
1933
  "eligibility-modal.no-eligibility": "Oeps, het lijkt erop dat de simulatie niet werkte.",
1929
- "eligibility-modal.title": "<highlighted>Betaal in termijnen</highlighted> of later per credit card met Alma.",
1934
+ "eligibility-modal.title": "<highlighted>Betaal in termijnen</highlighted> met kredietkaart bij Alma.",
1935
+ "eligibility-modal.title-deferred": "<highlighted>Betaal in termijnen</highlighted> of later per credit card met Alma.",
1930
1936
  "eligibility-modal.total": "Totaal",
1931
1937
  "installments.today": "Tegenwoordig",
1932
1938
  "payment-plan-strings.day-abbreviation": "J{numberOfDeferredDays}",
@@ -2019,11 +2025,33 @@ async function fetchFromApi(url = '', data, headers) {
2019
2025
  return response.json();
2020
2026
  }
2021
2027
 
2028
+ const isPlanEligible = (plan, configPlan) => {
2029
+ if (!plan.eligible) {
2030
+ return false;
2031
+ }
2032
+
2033
+ return configPlan ? plan.purchase_amount >= (configPlan == null ? void 0 : configPlan.minAmount) && plan.purchase_amount <= (configPlan == null ? void 0 : configPlan.maxAmount) : false;
2034
+ };
2035
+
2036
+ const getPaymentPlanBoundaries = (plan, configPlan) => {
2037
+ var _plan$constraints;
2038
+
2039
+ // When the plan is not eligible, the purchase amount constraints is given from the merchant config
2040
+ const purchaseAmountConstraints = (_plan$constraints = plan.constraints) == null ? void 0 : _plan$constraints.purchase_amount;
2041
+
2042
+ if (purchaseAmountConstraints && configPlan) {
2043
+ return {
2044
+ minAmount: Math.max(configPlan.minAmount, purchaseAmountConstraints == null ? void 0 : purchaseAmountConstraints.minimum),
2045
+ maxAmount: Math.min(configPlan.maxAmount, purchaseAmountConstraints == null ? void 0 : purchaseAmountConstraints.maximum)
2046
+ };
2047
+ }
2048
+
2049
+ return configPlan != null ? configPlan : {};
2050
+ };
2051
+
2022
2052
  const filterELigibility = (eligibilities, configPlans) => {
2023
2053
  // Remove p1x
2024
- const filteredEligibilityPlans = eligibilities.filter(plan => !(plan.installments_count === 1 && plan.deferred_days === 0 && plan.deferred_months === 0)) // Keeps the plans that have a payment_plan property
2025
- .filter(plan => plan.payment_plan) // Remove plans that have a reasons property
2026
- .filter(plan => !plan.reasons); // If no configPlans was provided, return eligibility response
2054
+ const filteredEligibilityPlans = eligibilities.filter(plan => !(plan.installments_count === 1 && plan.deferred_days === 0 && plan.deferred_months === 0)); // If no configPlans was provided, return eligibility response
2027
2055
 
2028
2056
  if (!configPlans) {
2029
2057
  return filteredEligibilityPlans;
@@ -2038,10 +2066,8 @@ const filterELigibility = (eligibilities, configPlans) => {
2038
2066
  return plan.installments_count === configPlan.installmentsCount && eligibilityDeferredDays === configPlanDeferredDays;
2039
2067
  });
2040
2068
  return _extends({}, plan, {
2041
- eligible: relatedConfigPlan ? plan.purchase_amount >= (relatedConfigPlan == null ? void 0 : relatedConfigPlan.minAmount) && plan.purchase_amount <= (relatedConfigPlan == null ? void 0 : relatedConfigPlan.maxAmount) : false,
2042
- minAmount: relatedConfigPlan == null ? void 0 : relatedConfigPlan.minAmount,
2043
- maxAmount: relatedConfigPlan == null ? void 0 : relatedConfigPlan.maxAmount
2044
- });
2069
+ eligible: isPlanEligible(plan, relatedConfigPlan)
2070
+ }, getPaymentPlanBoundaries(plan, relatedConfigPlan));
2045
2071
  });
2046
2072
  };
2047
2073
 
@@ -2108,6 +2134,29 @@ function CrossIcon({
2108
2134
  }));
2109
2135
  }
2110
2136
 
2137
+ /**
2138
+ * Prefix classes to avoid name collisions.
2139
+ */
2140
+ const prefix = 'alma-eligibility-modal';
2141
+ /**
2142
+ * Class names for the **eligibility modale** widget.
2143
+ * Those classes are intended to be used by the **merchant developer**.
2144
+ */
2145
+
2146
+ const STATIC_CUSTOMISATION_CLASSES = {
2147
+ leftSide: prefix + '-left-side',
2148
+ rightSide: prefix + '-right-side',
2149
+ title: prefix + '-title',
2150
+ info: prefix + '-info',
2151
+ infoMessage: prefix + '-info-message',
2152
+ eligibilityOptions: prefix + '-eligibility-options',
2153
+ activeOption: prefix + '-active-option',
2154
+ closeButton: prefix + '-close-button',
2155
+ scheduleDetails: prefix + '-schedule-details',
2156
+ scheduleTotal: prefix + '-schedule-total',
2157
+ scheduleCredit: prefix + '-schedule-credit'
2158
+ };
2159
+
2111
2160
  const _excluded = ["children", "isOpen", "onClose", "className", "contentClassName", "scrollable"];
2112
2161
 
2113
2162
  const ControlledModal = _ref => {
@@ -2139,7 +2188,7 @@ const ControlledModal = _ref => {
2139
2188
  className: s$1.header
2140
2189
  }, /*#__PURE__*/React.createElement("button", {
2141
2190
  onClick: onClose,
2142
- className: s$1.closeButton,
2191
+ className: cx(s$1.closeButton, STATIC_CUSTOMISATION_CLASSES.closeButton),
2143
2192
  "data-testid": "modal-close-button"
2144
2193
  }, /*#__PURE__*/React.createElement(CrossIcon, null))), /*#__PURE__*/React.createElement("div", {
2145
2194
  className: cx(s$1.content, contentClassName, {
@@ -2168,6 +2217,18 @@ const paymentPlanShorthandName = payment => {
2168
2217
  return `${installmentsCount}x`;
2169
2218
  }
2170
2219
  };
2220
+
2221
+ const withNoFee = payment => {
2222
+ var _payment$payment_plan;
2223
+
2224
+ if ((_payment$payment_plan = payment.payment_plan) != null && _payment$payment_plan.every(plan => plan.customer_fee === 0 && plan.customer_interest === 0)) {
2225
+ return /*#__PURE__*/React.createElement(React.Fragment, null, ' ', /*#__PURE__*/React.createElement(FormattedMessage, {
2226
+ id: "payment-plan-strings.no-fee",
2227
+ defaultMessage: '(sans frais)'
2228
+ }));
2229
+ }
2230
+ };
2231
+
2171
2232
  const paymentPlanInfoText = payment => {
2172
2233
  const {
2173
2234
  deferred_days,
@@ -2176,19 +2237,11 @@ const paymentPlanInfoText = payment => {
2176
2237
  eligible,
2177
2238
  purchase_amount: purchaseAmount,
2178
2239
  minAmount = 0,
2179
- maxAmount = 0
2240
+ maxAmount = 0,
2241
+ payment_plan
2180
2242
  } = payment;
2181
2243
  const deferredDaysCount = deferred_days + deferred_months * 30;
2182
2244
 
2183
- const withNoFee = () => {
2184
- if (payment.payment_plan.every(plan => plan.customer_fee === 0 && plan.customer_interest === 0)) {
2185
- return /*#__PURE__*/React.createElement(React.Fragment, null, ' ', /*#__PURE__*/React.createElement(FormattedMessage, {
2186
- id: "payment-plan-strings.no-fee",
2187
- defaultMessage: '(sans frais)'
2188
- }));
2189
- }
2190
- };
2191
-
2192
2245
  if (!eligible) {
2193
2246
  return purchaseAmount > maxAmount ? /*#__PURE__*/React.createElement(FormattedMessage, {
2194
2247
  id: "payment-plan-strings.ineligible-greater-than-max",
@@ -2211,26 +2264,31 @@ const paymentPlanInfoText = payment => {
2211
2264
  })
2212
2265
  }
2213
2266
  });
2267
+ } else if (!payment_plan) {
2268
+ /* This error should never happen. We added this condition to avoid a typescript warning on
2269
+ payment_plan possibly undefined. As far as we know, it only happens when the plan is not
2270
+ eligible, which is checked above. */
2271
+ throw Error(`No payment plan provided for payment in ${installmentsCount} installments. Please contact us if you see this error.`);
2214
2272
  } else if (deferredDaysCount !== 0 && installmentsCount === 1) {
2215
2273
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(FormattedMessage, {
2216
2274
  id: "payment-plan-strings.deferred",
2217
2275
  defaultMessage: "{totalAmount} \u00E0 payer le {dueDate}",
2218
2276
  values: {
2219
2277
  totalAmount: /*#__PURE__*/React.createElement(FormattedNumber, {
2220
- value: priceFromCents(payment.payment_plan[0].total_amount),
2278
+ value: priceFromCents(payment_plan[0].total_amount),
2221
2279
  style: "currency",
2222
2280
  currency: "EUR"
2223
2281
  }),
2224
2282
  dueDate: /*#__PURE__*/React.createElement(FormattedDate, {
2225
- value: secondsToMilliseconds(payment.payment_plan[0].due_date),
2283
+ value: secondsToMilliseconds(payment_plan[0].due_date),
2226
2284
  day: "numeric",
2227
2285
  month: "long",
2228
2286
  year: "numeric"
2229
2287
  })
2230
2288
  }
2231
- }), withNoFee());
2289
+ }), withNoFee(payment));
2232
2290
  } else if (installmentsCount > 0) {
2233
- const areInstallmentsOfSameAmount = payment.payment_plan.every((installment, index) => index === 0 || installment.total_amount === payment.payment_plan[0].total_amount);
2291
+ const areInstallmentsOfSameAmount = payment_plan == null ? void 0 : payment_plan.every((installment, index) => index === 0 || installment.total_amount === payment_plan[0].total_amount);
2234
2292
 
2235
2293
  if (areInstallmentsOfSameAmount) {
2236
2294
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(FormattedMessage, {
@@ -2238,13 +2296,13 @@ const paymentPlanInfoText = payment => {
2238
2296
  defaultMessage: "{installmentsCount} x {totalAmount}",
2239
2297
  values: {
2240
2298
  totalAmount: /*#__PURE__*/React.createElement(FormattedNumber, {
2241
- value: priceFromCents(payment.payment_plan[0].total_amount),
2299
+ value: priceFromCents(payment_plan[0].total_amount),
2242
2300
  style: "currency",
2243
2301
  currency: "EUR"
2244
2302
  }),
2245
2303
  installmentsCount
2246
2304
  }
2247
- }), withNoFee());
2305
+ }), withNoFee(payment));
2248
2306
  }
2249
2307
 
2250
2308
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(FormattedMessage, {
@@ -2252,18 +2310,18 @@ const paymentPlanInfoText = payment => {
2252
2310
  defaultMessage: "{numberOfRemainingInstallments, plural, one {{firstInstallmentAmount} puis {numberOfRemainingInstallments} x {othersInstallmentAmount}} other {{firstInstallmentAmount} puis {numberOfRemainingInstallments} x {othersInstallmentAmount}}}",
2253
2311
  values: {
2254
2312
  firstInstallmentAmount: /*#__PURE__*/React.createElement(FormattedNumber, {
2255
- value: priceFromCents(payment.payment_plan[0].total_amount),
2313
+ value: priceFromCents(payment_plan[0].total_amount),
2256
2314
  style: "currency",
2257
2315
  currency: "EUR"
2258
2316
  }),
2259
2317
  numberOfRemainingInstallments: installmentsCount - 1,
2260
2318
  othersInstallmentAmount: /*#__PURE__*/React.createElement(FormattedNumber, {
2261
- value: priceFromCents(payment.payment_plan[1].total_amount),
2319
+ value: priceFromCents(payment_plan[1].total_amount),
2262
2320
  style: "currency",
2263
2321
  currency: "EUR"
2264
2322
  })
2265
2323
  }
2266
- }), withNoFee());
2324
+ }), withNoFee(payment));
2267
2325
  }
2268
2326
 
2269
2327
  return /*#__PURE__*/React.createElement(FormattedMessage, {
@@ -2279,11 +2337,11 @@ const EligibilityPlansButtons = ({
2279
2337
  currentPlanIndex,
2280
2338
  setCurrentPlanIndex
2281
2339
  }) => /*#__PURE__*/React.createElement("div", {
2282
- className: s$2.buttons
2340
+ className: cx(s$2.buttons, STATIC_CUSTOMISATION_CLASSES.eligibilityOptions)
2283
2341
  }, eligibilityPlans.map((eligibilityPlan, index) => /*#__PURE__*/React.createElement("button", {
2284
2342
  key: index,
2285
2343
  className: cx({
2286
- [s$2.active]: index === currentPlanIndex
2344
+ [cx(s$2.active, STATIC_CUSTOMISATION_CLASSES.activeOption)]: index === currentPlanIndex
2287
2345
  }),
2288
2346
  onClick: () => setCurrentPlanIndex(index)
2289
2347
  }, paymentPlanShorthandName(eligibilityPlan))));
@@ -2300,10 +2358,10 @@ const Schedule = ({
2300
2358
  const isCredit = currentPlan && currentPlan.installments_count > 4;
2301
2359
  const intl = useIntl();
2302
2360
  return /*#__PURE__*/React.createElement("div", {
2303
- className: s$3.schedule,
2361
+ className: cx(s$3.schedule, STATIC_CUSTOMISATION_CLASSES.scheduleDetails),
2304
2362
  "data-testid": "modal-installments-element"
2305
2363
  }, /*#__PURE__*/React.createElement("div", {
2306
- className: cx(s$3.scheduleLine, s$3.total)
2364
+ className: cx(s$3.scheduleLine, s$3.total, STATIC_CUSTOMISATION_CLASSES.scheduleTotal)
2307
2365
  }, /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement(FormattedMessage, {
2308
2366
  id: "eligibility-modal.total",
2309
2367
  defaultMessage: "Total"
@@ -2312,7 +2370,7 @@ const Schedule = ({
2312
2370
  style: "currency",
2313
2371
  currency: "EUR"
2314
2372
  }))), /*#__PURE__*/React.createElement("div", {
2315
- className: cx(s$3.scheduleLine, s$3.creditCost)
2373
+ className: cx(s$3.scheduleLine, s$3.creditCost, STATIC_CUSTOMISATION_CLASSES.scheduleCredit)
2316
2374
  }, isCredit ? /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement(FormattedMessage, {
2317
2375
  id: "eligibility-modal.credit-cost",
2318
2376
  defaultMessage: "Dont co\u00FBt du cr\u00E9dit"
@@ -2362,13 +2420,15 @@ const Schedule = ({
2362
2420
  var s$4 = {"list":"_180ro","listItem":"_1HqCO","bullet":"_3B8wx"};
2363
2421
 
2364
2422
  const Info = () => /*#__PURE__*/React.createElement("div", {
2365
- className: s$4.list,
2423
+ className: cx(s$4.list, STATIC_CUSTOMISATION_CLASSES.info),
2366
2424
  "data-testid": "modal-info-element"
2367
2425
  }, /*#__PURE__*/React.createElement("div", {
2368
2426
  className: s$4.listItem
2369
2427
  }, /*#__PURE__*/React.createElement("div", {
2370
2428
  className: s$4.bullet
2371
- }, "1"), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(FormattedMessage, {
2429
+ }, "1"), /*#__PURE__*/React.createElement("div", {
2430
+ className: STATIC_CUSTOMISATION_CLASSES.infoMessage
2431
+ }, /*#__PURE__*/React.createElement(FormattedMessage, {
2372
2432
  id: "eligibility-modal.bullet-1",
2373
2433
  defaultMessage: "Choisissez <strong>Alma</strong> au moment du paiement.",
2374
2434
  values: {
@@ -2378,7 +2438,9 @@ const Info = () => /*#__PURE__*/React.createElement("div", {
2378
2438
  className: s$4.listItem
2379
2439
  }, /*#__PURE__*/React.createElement("div", {
2380
2440
  className: s$4.bullet
2381
- }, "2"), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(FormattedMessage, {
2441
+ }, "2"), /*#__PURE__*/React.createElement("div", {
2442
+ className: STATIC_CUSTOMISATION_CLASSES.infoMessage
2443
+ }, /*#__PURE__*/React.createElement(FormattedMessage, {
2382
2444
  id: "eligibility-modal.bullet-2",
2383
2445
  defaultMessage: "Renseignez les <strong>informations</strong> demand\u00E9es.",
2384
2446
  values: {
@@ -2388,7 +2450,9 @@ const Info = () => /*#__PURE__*/React.createElement("div", {
2388
2450
  className: s$4.listItem
2389
2451
  }, /*#__PURE__*/React.createElement("div", {
2390
2452
  className: s$4.bullet
2391
- }, "3"), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(FormattedMessage, {
2453
+ }, "3"), /*#__PURE__*/React.createElement("div", {
2454
+ className: STATIC_CUSTOMISATION_CLASSES.infoMessage
2455
+ }, /*#__PURE__*/React.createElement(FormattedMessage, {
2392
2456
  id: "eligibility-modal.bullet-3",
2393
2457
  defaultMessage: "La validation de votre paiement <strong>instantan\u00E9e</strong> !",
2394
2458
  values: {
@@ -2438,28 +2502,39 @@ const Logo = () => /*#__PURE__*/React.createElement("div", {
2438
2502
 
2439
2503
  var s$6 = {"title":"_3ERx-"};
2440
2504
 
2441
- const Title = () => /*#__PURE__*/React.createElement("div", {
2442
- className: s$6.title,
2505
+ const Title = ({
2506
+ isSomePlanDeferred
2507
+ }) => /*#__PURE__*/React.createElement("div", {
2508
+ className: cx(s$6.title, STATIC_CUSTOMISATION_CLASSES.title),
2443
2509
  "data-testid": "modal-title-element"
2444
- }, /*#__PURE__*/React.createElement(FormattedMessage, {
2445
- id: "eligibility-modal.title",
2510
+ }, isSomePlanDeferred ? /*#__PURE__*/React.createElement(FormattedMessage, {
2511
+ id: 'eligibility-modal.title-deferred',
2446
2512
  defaultMessage: "<highlighted>Payez en plusieurs fois</highlighted> ou plus tard par carte bancaire avec Alma.",
2447
2513
  values: {
2448
2514
  highlighted: (...chunks) => /*#__PURE__*/React.createElement("span", null, chunks)
2449
2515
  }
2516
+ }) : /*#__PURE__*/React.createElement(FormattedMessage, {
2517
+ id: 'eligibility-modal.title',
2518
+ defaultMessage: "<highlighted>Payez en plusieurs fois</highlighted> par carte bancaire avec Alma.",
2519
+ values: {
2520
+ highlighted: (...chunks) => /*#__PURE__*/React.createElement("span", null, chunks)
2521
+ }
2450
2522
  }));
2451
2523
 
2452
2524
  var s$7 = {"container":"_21g6u","block":"_3zaP5","left":"_2SBRC"};
2453
2525
 
2454
2526
  const DesktopModal = ({
2455
- children
2527
+ children,
2528
+ isSomePlanDeferred
2456
2529
  }) => /*#__PURE__*/React.createElement("div", {
2457
2530
  className: s$7.container,
2458
2531
  "data-testid": "modal-container"
2459
2532
  }, /*#__PURE__*/React.createElement("div", {
2460
- className: cx([s$7.block, s$7.left])
2461
- }, /*#__PURE__*/React.createElement(Title, null), /*#__PURE__*/React.createElement(Info, null), /*#__PURE__*/React.createElement(Logo, null)), /*#__PURE__*/React.createElement("div", {
2462
- className: s$7.block
2533
+ className: cx([s$7.block, s$7.left, STATIC_CUSTOMISATION_CLASSES.leftSide])
2534
+ }, /*#__PURE__*/React.createElement(Title, {
2535
+ isSomePlanDeferred: isSomePlanDeferred
2536
+ }), /*#__PURE__*/React.createElement(Info, null), /*#__PURE__*/React.createElement(Logo, null)), /*#__PURE__*/React.createElement("div", {
2537
+ className: cx(s$7.block, STATIC_CUSTOMISATION_CLASSES.rightSide)
2463
2538
  }, children));
2464
2539
 
2465
2540
  var s$8 = {"noEligibility":"_17qNJ","loader":"_2oTJq"};
@@ -2467,11 +2542,14 @@ var s$8 = {"noEligibility":"_17qNJ","loader":"_2oTJq"};
2467
2542
  var s$9 = {"container":"_2G7Ch"};
2468
2543
 
2469
2544
  const MobileModal = ({
2470
- children
2545
+ children,
2546
+ isSomePlanDeferred
2471
2547
  }) => /*#__PURE__*/React.createElement("div", {
2472
2548
  className: s$9.container,
2473
2549
  "data-testid": "modal-container"
2474
- }, /*#__PURE__*/React.createElement(Title, null), children, /*#__PURE__*/React.createElement(Info, null), /*#__PURE__*/React.createElement(Logo, null));
2550
+ }, /*#__PURE__*/React.createElement(Title, {
2551
+ isSomePlanDeferred: isSomePlanDeferred
2552
+ }), children, /*#__PURE__*/React.createElement(Info, null), /*#__PURE__*/React.createElement(Logo, null));
2475
2553
 
2476
2554
  const EligibilityModal = ({
2477
2555
  initialPlanIndex,
@@ -2486,25 +2564,21 @@ const EligibilityModal = ({
2486
2564
  const ModalComponent = isBigScreen ? DesktopModal : MobileModal;
2487
2565
  const eligiblePlans = eligibilityPlans.filter(plan => plan.eligible);
2488
2566
  const currentPlan = eligiblePlans[currentPlanIndex];
2489
- const modalProps = {
2490
- eligibilityPlans: eligiblePlans,
2491
- currentPlanIndex,
2492
- setCurrentPlanIndex,
2493
- currentPlan,
2494
- status
2495
- };
2567
+ const isSomePlanDeferred = eligibilityPlans.some(plan => plan.deferred_days > 0 || plan.deferred_months > 0);
2496
2568
  return /*#__PURE__*/React.createElement(ControlledModal, {
2497
2569
  onClose: onClose,
2498
2570
  ariaHideApp: false,
2499
2571
  scrollable: true,
2500
2572
  isOpen: true
2501
- }, /*#__PURE__*/React.createElement(ModalComponent, Object.assign({}, modalProps), status === apiStatus.PENDING && /*#__PURE__*/React.createElement("div", {
2573
+ }, /*#__PURE__*/React.createElement(ModalComponent, {
2574
+ isSomePlanDeferred: isSomePlanDeferred
2575
+ }, status === apiStatus.PENDING && /*#__PURE__*/React.createElement("div", {
2502
2576
  className: s$8.loader
2503
2577
  }, /*#__PURE__*/React.createElement(LoadingIndicator, null)), status === apiStatus.SUCCESS && eligiblePlans.length === 0 && /*#__PURE__*/React.createElement("div", {
2504
2578
  className: s$8.noEligibility
2505
2579
  }, /*#__PURE__*/React.createElement(FormattedMessage, {
2506
2580
  id: "eligibility-modal.no-eligibility",
2507
- defaultMessage: "Oups, il semblerait que la simulation n'aie pas fonctionn\u00E9."
2581
+ defaultMessage: "Oups, il semblerait que la simulation n'ait pas fonctionn\u00E9."
2508
2582
  })), status === apiStatus.SUCCESS && eligiblePlans.length >= 1 && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(EligibilityPlansButtons, {
2509
2583
  eligibilityPlans: eligiblePlans,
2510
2584
  currentPlanIndex: currentPlanIndex,
@@ -2606,6 +2680,24 @@ const getIndexOfActivePlan = ({
2606
2680
  return 0;
2607
2681
  };
2608
2682
 
2683
+ /**
2684
+ * Prefix classes to avoid name collisions.
2685
+ */
2686
+ const prefix$1 = 'alma-payment-plans';
2687
+ /**
2688
+ * Class names for the **payment plans** widget.
2689
+ * Those classes are intended to be used by the **merchant developer**.
2690
+ */
2691
+
2692
+ const STATIC_CUSTOMISATION_CLASSES$1 = {
2693
+ container: prefix$1 + '-container',
2694
+ eligibilityLine: prefix$1 + '-eligibility-line',
2695
+ eligibilityOptions: prefix$1 + '-eligibility-options',
2696
+ notEligibleOption: prefix$1 + '-not-eligible-option',
2697
+ paymentInfo: prefix$1 + '-payment-info',
2698
+ activeOption: prefix$1 + '-active-option'
2699
+ };
2700
+
2609
2701
  var s$b = {"widgetButton":"_TSkFv","logo":"_LJ4nZ","primaryContainer":"_bMClc","paymentPlans":"_17c_S","plan":"_2Kqjn","active":"_3dG_J","notEligible":"_3O1bg","info":"_25GrF","loader":"_30j1O","error":"_R0YlN","errorText":"_2kGhu","errorButton":"_73d_Y","pending":"_1ZDMS","clickable":"_UksZa","unClickable":"_1lr-q"};
2610
2702
 
2611
2703
  const VERY_LONG_TIME_IN_MS = 1000 * 3600 * 24 * 365;
@@ -2625,7 +2717,7 @@ const PaymentPlanWidget = ({
2625
2717
  eligibilityPlans,
2626
2718
  suggestedPaymentPlan: suggestedPaymentPlan != null ? suggestedPaymentPlan : 0
2627
2719
  });
2628
- const isSuggestedPaymentPlanSpecified = suggestedPaymentPlan !== undefined; // 👈 The merchant decided to focus a tab and remove animated transition.
2720
+ const isSuggestedPaymentPlanSpecified = suggestedPaymentPlan !== undefined; // 👈 The merchant decided to focus a tab
2629
2721
 
2630
2722
  const isTransitionSpecified = transitionDelay !== undefined; // 👈 The merchant has specified a transition time
2631
2723
 
@@ -2703,28 +2795,28 @@ const PaymentPlanWidget = ({
2703
2795
  className: cx(s$b.widgetButton, {
2704
2796
  [s$b.clickable]: eligiblePlans.length > 0,
2705
2797
  [s$b.unClickable]: eligiblePlans.length === 0
2706
- }),
2798
+ }, STATIC_CUSTOMISATION_CLASSES$1.container),
2707
2799
  "data-testid": "widget-button"
2708
2800
  }, /*#__PURE__*/React.createElement("div", {
2709
- className: s$b.primaryContainer
2801
+ className: cx(s$b.primaryContainer, STATIC_CUSTOMISATION_CLASSES$1.eligibilityLine)
2710
2802
  }, /*#__PURE__*/React.createElement(LogoIcon, {
2711
2803
  className: s$b.logo
2712
2804
  }), /*#__PURE__*/React.createElement("div", {
2713
- className: s$b.paymentPlans
2805
+ className: cx(s$b.paymentPlans, STATIC_CUSTOMISATION_CLASSES$1.eligibilityOptions)
2714
2806
  }, eligibilityPlans.map((eligibilityPlan, key) => {
2715
2807
  return /*#__PURE__*/React.createElement("div", {
2716
2808
  key: key,
2717
2809
  onMouseEnter: () => onHover(key),
2718
2810
  onMouseOut: onLeave,
2719
2811
  className: cx(s$b.plan, {
2720
- [s$b.active]: current === key,
2721
- [s$b.notEligible]: !eligibilityPlan.eligible
2812
+ [cx(s$b.active, STATIC_CUSTOMISATION_CLASSES$1.activeOption)]: current === key,
2813
+ [cx(s$b.notEligible, STATIC_CUSTOMISATION_CLASSES$1.notEligibleOption)]: !eligibilityPlan.eligible
2722
2814
  })
2723
2815
  }, paymentPlanShorthandName(eligibilityPlan));
2724
2816
  }))), /*#__PURE__*/React.createElement("div", {
2725
2817
  className: cx(s$b.info, {
2726
- [s$b.notEligible]: eligibilityPlans[current] && !eligibilityPlans[current].eligible
2727
- })
2818
+ [cx(s$b.notEligible, STATIC_CUSTOMISATION_CLASSES$1.notEligibleOption)]: eligibilityPlans[current] && !eligibilityPlans[current].eligible
2819
+ }, STATIC_CUSTOMISATION_CLASSES$1.paymentInfo)
2728
2820
  }, eligibilityPlans.length !== 0 && paymentPlanInfoText(eligibilityPlans[current]))), isOpen && /*#__PURE__*/React.createElement(EligibilityModal, {
2729
2821
  initialPlanIndex: getIndexWithinEligiblePlans(current),
2730
2822
  onClose: closeModal,