@miden-npm/react 2.0.4 → 2.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -3022,13 +3022,12 @@ function PayByCard({
3022
3022
  setIsMakingPayment(false);
3023
3023
  return;
3024
3024
  }
3025
- setMessage(response?.responseMessage || "Payment failed");
3026
- onPaymentAuthorized?.({
3027
- paymentId: response?.transactionReference,
3028
- paymentDate: response?.data?.updatedAt,
3029
- paymentStatus: "payment failed",
3030
- message
3031
- });
3025
+ if (response && response.message) {
3026
+ setMessage(response.message);
3027
+ onError?.({
3028
+ errorMessage: response.message
3029
+ });
3030
+ }
3032
3031
  setIsMakingPayment(false);
3033
3032
  } catch (err) {
3034
3033
  let friendly = "Payment failed";
@@ -3112,6 +3111,9 @@ function PayByCard({
3112
3111
  setLoadingCountries(false);
3113
3112
  }
3114
3113
  };
3114
+ const goBack = () => {
3115
+ setFormIndex(formIndex > 0 ? formIndex - 1 : 0);
3116
+ };
3115
3117
  const getStates = async (countryIso2) => {
3116
3118
  const country = rawCountries.find((c) => c.iso2 === countryIso2);
3117
3119
  if (!country) return;
@@ -3201,7 +3203,9 @@ function PayByCard({
3201
3203
  (c) => c.code.toLowerCase() === e.toLowerCase()
3202
3204
  )[0];
3203
3205
  if (selectedCountry) {
3204
- setDefaultCountryCode(`${selectedCountry.phoneCode}-${selectedCountry.code}`);
3206
+ setDefaultCountryCode(
3207
+ `${selectedCountry.phoneCode}-${selectedCountry.code}`
3208
+ );
3205
3209
  }
3206
3210
  if (billingErrors.country) {
3207
3211
  setBillingErrors((er) => ({ ...er, country: "" }));
@@ -3257,7 +3261,7 @@ function PayByCard({
3257
3261
  validationError: billingErrors.postalCode ?? ""
3258
3262
  }
3259
3263
  ),
3260
- /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
3264
+ /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: "col-span-2", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
3261
3265
  BaseInput,
3262
3266
  {
3263
3267
  label: "Email",
@@ -3271,12 +3275,13 @@ function PayByCard({
3271
3275
  },
3272
3276
  validationError: billingErrors.emailAddress ?? ""
3273
3277
  }
3274
- ),
3278
+ ) }),
3275
3279
  /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: "col-span-2", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
3276
3280
  BasePhoneNumberInput,
3277
3281
  {
3278
3282
  label: "Phone Number",
3279
3283
  required: true,
3284
+ preventPaste: true,
3280
3285
  value: billingForm.phoneNumber,
3281
3286
  phoneCodeOptions,
3282
3287
  defaultCountryCode,
@@ -3388,18 +3393,30 @@ function PayByCard({
3388
3393
  ]
3389
3394
  }
3390
3395
  ),
3391
- /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
3392
- BaseButton,
3393
- {
3394
- label: formIndex === 0 ? "Proceed" : `Pay ${formatAmountHandler}`,
3395
- type: "primary",
3396
- customClass: "w-full mt-6",
3397
- caller,
3398
- loading: isMakingPayment,
3399
- onClick: proceedHandler,
3400
- disabled: isMakingPayment
3401
- }
3402
- )
3396
+ /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: "flex items-center justify-between gap-4 mt-6", children: [
3397
+ formIndex > 0 && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
3398
+ BaseButton,
3399
+ {
3400
+ label: "Previous",
3401
+ type: "secondary",
3402
+ customClass: "w-1/2",
3403
+ caller,
3404
+ onClick: goBack
3405
+ }
3406
+ ),
3407
+ /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
3408
+ BaseButton,
3409
+ {
3410
+ label: formIndex === 0 ? "Proceed" : `Pay ${formatAmountHandler}`,
3411
+ type: "primary",
3412
+ customClass: `${formIndex > 0 ? "w-1/2" : "w-full"}`,
3413
+ caller,
3414
+ loading: isMakingPayment,
3415
+ onClick: proceedHandler,
3416
+ disabled: isMakingPayment
3417
+ }
3418
+ )
3419
+ ] })
3403
3420
  ] });
3404
3421
  }
3405
3422