@pelcro/react-pelcro-js 3.2.0-beta.2 → 3.2.0-beta.22

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.js CHANGED
@@ -3244,7 +3244,8 @@ function withTranslation(ns) {
3244
3244
  var validation$1 = {
3245
3245
  validEmail: "le courriel n’est pas valide",
3246
3246
  enterEmail: "Un courriel est requis.",
3247
- enterPassword: "Mot de passe requis."
3247
+ enterPassword: "Mot de passe requis.",
3248
+ confirmPassword: "Confirmer le mot de passe requis."
3248
3249
  };
3249
3250
  var buttons$9 = {
3250
3251
  account: "Accès abonné(e)s",
@@ -3332,7 +3333,8 @@ var common_fr = {
3332
3333
  var validation = {
3333
3334
  validEmail: "Email address is not valid.",
3334
3335
  enterEmail: "Email address is required.",
3335
- enterPassword: "Password is required."
3336
+ enterPassword: "Password is required.",
3337
+ confirmPassword: "Confirm password is required."
3336
3338
  };
3337
3339
  var buttons$8 = {
3338
3340
  account: "My account",
@@ -3464,7 +3466,7 @@ var paymentMethod_fr = {
3464
3466
  var title$f = "Enter your email to subscribe to our newsletter";
3465
3467
  var updateTitle$1 = "Update newsletter selections";
3466
3468
  var subtitle$7 = "We may use your email for other marketing communication";
3467
- var labels$p = {
3469
+ var labels$r = {
3468
3470
  submit: "Submit",
3469
3471
  firstName: "First name",
3470
3472
  lastName: "Last name",
@@ -3472,7 +3474,7 @@ var labels$p = {
3472
3474
  postalCode: "Postal code",
3473
3475
  required: "required"
3474
3476
  };
3475
- var messages$r = {
3477
+ var messages$t = {
3476
3478
  alreadyHaveAccount: "Already have an account?",
3477
3479
  success: "Newsletters were successfully updated",
3478
3480
  loginHere: "Login here.",
@@ -3483,14 +3485,14 @@ var newsletter_en = {
3483
3485
  title: title$f,
3484
3486
  updateTitle: updateTitle$1,
3485
3487
  subtitle: subtitle$7,
3486
- labels: labels$p,
3487
- messages: messages$r
3488
+ labels: labels$r,
3489
+ messages: messages$t
3488
3490
  };
3489
3491
 
3490
3492
  var title$e = "Entrez votre adresse courriel pour vous abonner à notre infolettre";
3491
3493
  var updateTitle = "Mettre à jour son choix d'infolettres";
3492
3494
  var subtitle$6 = "Nous pouvons utiliser votre adresse courriel pour d’autres communications marketing";
3493
- var labels$o = {
3495
+ var labels$q = {
3494
3496
  submit: "Lire l’article !",
3495
3497
  firstName: "Prénom",
3496
3498
  lastName: "Nom de famille",
@@ -3498,7 +3500,7 @@ var labels$o = {
3498
3500
  postalCode: "Code postal",
3499
3501
  required: "Champs obligatoires"
3500
3502
  };
3501
- var messages$q = {
3503
+ var messages$s = {
3502
3504
  alreadyHaveAccount: "Vous avez déjà un compte ?",
3503
3505
  success: "Votre choix d'infolettres à été mis à jour",
3504
3506
  loginHere: "Connectez-vous ici",
@@ -3509,14 +3511,14 @@ var newsletter_fr = {
3509
3511
  title: title$e,
3510
3512
  updateTitle: updateTitle,
3511
3513
  subtitle: subtitle$6,
3512
- labels: labels$o,
3513
- messages: messages$q
3514
+ labels: labels$q,
3515
+ messages: messages$s
3514
3516
  };
3515
3517
 
3516
- var labels$n = {
3518
+ var labels$p = {
3517
3519
  "continue": "Continue to content"
3518
3520
  };
3519
- var messages$p = {
3521
+ var messages$r = {
3520
3522
  yourFreeTrial: "Subscription successful!",
3521
3523
  youHaveAccess: "Hope you enjoy the subscription. Please contact us if you have any questions or concerns.",
3522
3524
  clickToLearn: {
@@ -3542,15 +3544,15 @@ var errors$9 = {
3542
3544
  "": ""
3543
3545
  };
3544
3546
  var success_en = {
3545
- labels: labels$n,
3546
- messages: messages$p,
3547
+ labels: labels$p,
3548
+ messages: messages$r,
3547
3549
  errors: errors$9
3548
3550
  };
3549
3551
 
3550
- var labels$m = {
3552
+ var labels$o = {
3551
3553
  "continue": "Abonnement réussi !"
3552
3554
  };
3553
- var messages$o = {
3555
+ var messages$q = {
3554
3556
  yourFreeTrial: "Votre essai gratuit vient de débuter",
3555
3557
  youHaveAccess: "Nous espérons que vous allez apprécier votre abonnement. Veuillez nous contacter si vous avez des questions ou des préoccupations.",
3556
3558
  clickToLearn: {
@@ -3576,12 +3578,12 @@ var errors$8 = {
3576
3578
  "": ""
3577
3579
  };
3578
3580
  var success_fr = {
3579
- labels: labels$m,
3580
- messages: messages$o,
3581
+ labels: labels$o,
3582
+ messages: messages$q,
3581
3583
  errors: errors$8
3582
3584
  };
3583
3585
 
3584
- var messages$n = {
3586
+ var messages$p = {
3585
3587
  freeVisits: "Free visits left:",
3586
3588
  subscribeNow: "Subscribe",
3587
3589
  alreadyHaveAccount: "Already have an account?",
@@ -3591,11 +3593,11 @@ var errors$7 = {
3591
3593
  "": ""
3592
3594
  };
3593
3595
  var meter_en = {
3594
- messages: messages$n,
3596
+ messages: messages$p,
3595
3597
  errors: errors$7
3596
3598
  };
3597
3599
 
3598
- var messages$m = {
3600
+ var messages$o = {
3599
3601
  freeVisits: "Visites gratuites restantes:",
3600
3602
  subscribeNow: "Abonnez-vous maintenant !",
3601
3603
  alreadyHaveAccount: "Vous avez déjà un compte ?",
@@ -3605,15 +3607,15 @@ var errors$6 = {
3605
3607
  "": ""
3606
3608
  };
3607
3609
  var meter_fr = {
3608
- messages: messages$m,
3610
+ messages: messages$o,
3609
3611
  errors: errors$6
3610
3612
  };
3611
3613
 
3612
- var messages$l = {
3614
+ var messages$n = {
3613
3615
  youAreSafe: "You're safe - PCI compliant 128 SSL by",
3614
3616
  bankRedirection: "Please hold, redirecting you to your bank."
3615
3617
  };
3616
- var labels$l = {
3618
+ var labels$n = {
3617
3619
  card: "Enter card number",
3618
3620
  date: "Expiration date",
3619
3621
  CVC: "CVC",
@@ -3632,15 +3634,15 @@ var labels$l = {
3632
3634
  removeCoupon: "REMOVE"
3633
3635
  };
3634
3636
  var checkoutForm_en = {
3635
- messages: messages$l,
3636
- labels: labels$l
3637
+ messages: messages$n,
3638
+ labels: labels$n
3637
3639
  };
3638
3640
 
3639
- var messages$k = {
3641
+ var messages$m = {
3640
3642
  youAreSafe: "Vous êtes en sécurité - PCI conforme 128 SSL par",
3641
3643
  bankRedirection: "Veuillez patienter, nous vous redirigeons vers votre banque."
3642
3644
  };
3643
- var labels$k = {
3645
+ var labels$m = {
3644
3646
  card: "Entrez le numéro de carte",
3645
3647
  date: "Date d’expiration",
3646
3648
  CVC: "CVC",
@@ -3659,8 +3661,8 @@ var labels$k = {
3659
3661
  removeCoupon: "RETIRER"
3660
3662
  };
3661
3663
  var checkoutForm_fr = {
3662
- messages: messages$k,
3663
- labels: labels$k
3664
+ messages: messages$m,
3665
+ labels: labels$m
3664
3666
  };
3665
3667
 
3666
3668
  var youAreSafe$1 = "You're safe - PCI compliant 128 SSL by";
@@ -3701,7 +3703,7 @@ var messages_fr = {
3701
3703
  zeroTotalInvoice: zeroTotalInvoice
3702
3704
  };
3703
3705
 
3704
- var labels$j = {
3706
+ var labels$l = {
3705
3707
  email: "Enter email",
3706
3708
  password: "Enter password",
3707
3709
  required: "required",
@@ -3709,7 +3711,7 @@ var labels$j = {
3709
3711
  passwordPlaceholder: "Password",
3710
3712
  login: "Login"
3711
3713
  };
3712
- var messages$j = {
3714
+ var messages$l = {
3713
3715
  loginTo: "Login to your account",
3714
3716
  welcome: "Welcome back, sign in with your existing account.",
3715
3717
  dontHaveAccount: "Don't have an account yet?",
@@ -3728,12 +3730,12 @@ var errors$5 = {
3728
3730
  "": ""
3729
3731
  };
3730
3732
  var login_en = {
3731
- labels: labels$j,
3732
- messages: messages$j,
3733
+ labels: labels$l,
3734
+ messages: messages$l,
3733
3735
  errors: errors$5
3734
3736
  };
3735
3737
 
3736
- var labels$i = {
3738
+ var labels$k = {
3737
3739
  email: "Entrez votre adresse courriel",
3738
3740
  password: "Entrez votre mot de passe",
3739
3741
  required: "Champs obligatoires",
@@ -3741,7 +3743,7 @@ var labels$i = {
3741
3743
  passwordPlaceholder: "Mot de passe",
3742
3744
  login: "Connexion"
3743
3745
  };
3744
- var messages$i = {
3746
+ var messages$k = {
3745
3747
  loginTo: "Connectez-vous à votre compte",
3746
3748
  welcome: "Bienvenue, connectez-vous avec votre compte existant.",
3747
3749
  dontHaveAccount: "Vous n’avez pas encore de compte ?",
@@ -3760,11 +3762,39 @@ var errors$4 = {
3760
3762
  "": ""
3761
3763
  };
3762
3764
  var login_fr = {
3763
- labels: labels$i,
3764
- messages: messages$i,
3765
+ labels: labels$k,
3766
+ messages: messages$k,
3765
3767
  errors: errors$4
3766
3768
  };
3767
3769
 
3770
+ var labels$j = {
3771
+ title: "Verifying Magin Link",
3772
+ instructions: "You're on your way!\nLet's confirm your email address.\nClick on the verification link we've sent to your email:",
3773
+ resend: "Resend email"
3774
+ };
3775
+ var messages$j = {
3776
+ resent: "Resent successfully",
3777
+ success: "Link verified successfully!"
3778
+ };
3779
+ var verifyLinkToken_en = {
3780
+ labels: labels$j,
3781
+ messages: messages$j
3782
+ };
3783
+
3784
+ var labels$i = {
3785
+ title: "Confirmez votre courriel",
3786
+ instructions: "Confirmez votre courriel.\nVeuillez cliquer sur le lien de vérification, qui vous a été envoyé à:",
3787
+ resend: "Renvoyer le courriel"
3788
+ };
3789
+ var messages$i = {
3790
+ resent: "Renvoyé avec succès",
3791
+ success: "Lien vérifiée avec succès"
3792
+ };
3793
+ var verifyLinkToken_fr = {
3794
+ labels: labels$i,
3795
+ messages: messages$i
3796
+ };
3797
+
3768
3798
  var title$d = "Create an account";
3769
3799
  var subtitle$5 = "Enter your email and password below";
3770
3800
  var labels$h = {
@@ -4684,17 +4714,17 @@ var invoiceDetails_en = {
4684
4714
  buttons: buttons$1
4685
4715
  };
4686
4716
 
4687
- var title = "Invoice details";
4717
+ var title = "Détails de la facture";
4688
4718
  var labels = {
4689
- summary: "Summary",
4719
+ summary: "Résumé",
4690
4720
  total: "Total",
4691
- amountPaid: "Amount paid",
4692
- amountDue: "Amount due",
4693
- creationDate: "Created on:"
4721
+ amountPaid: "Montant payé",
4722
+ amountDue: "Montant ",
4723
+ creationDate: "Créé le:"
4694
4724
  };
4695
4725
  var buttons = {
4696
- download: "Download",
4697
- pay: "Pay now"
4726
+ download: "Télécharger",
4727
+ pay: "Payer"
4698
4728
  };
4699
4729
  var invoiceDetails_fr = {
4700
4730
  title: title,
@@ -6051,7 +6081,7 @@ class PelcroActions {
6051
6081
  view,
6052
6082
  cartItems,
6053
6083
  ...otherStateFields
6054
- } = initialState$i;
6084
+ } = initialState$j;
6055
6085
  this.set(otherStateFields);
6056
6086
  });
6057
6087
 
@@ -6370,7 +6400,7 @@ class PelcroCallbacks {
6370
6400
 
6371
6401
  }
6372
6402
 
6373
- const initialState$i = {
6403
+ const initialState$j = {
6374
6404
  // View
6375
6405
  view: null,
6376
6406
  // Plans
@@ -6400,7 +6430,7 @@ const createPelcroStore = () => createStore(middleware_3((set, get) => {
6400
6430
  return {
6401
6431
  // Store setter
6402
6432
  set,
6403
- ...initialState$i,
6433
+ ...initialState$j,
6404
6434
  // State actions
6405
6435
  ...actions,
6406
6436
  // Callbacks
@@ -6436,6 +6466,19 @@ if (process.env.NODE_ENV === "development") {
6436
6466
  c$1("Pelcro Store", usePelcro);
6437
6467
  }
6438
6468
 
6469
+ /**
6470
+ * List of zero-decimal currencies.
6471
+ * @see https://stripe.com/docs/currencies#zero-decimal
6472
+ *
6473
+ */
6474
+
6475
+ const ZERO_DECIMAL_CURRENCIES = ['BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'UGX', 'VND', 'VUV', 'XAF', 'XOF', 'XPF'];
6476
+ /**
6477
+ * @param {string}
6478
+ * @return {boolean}
6479
+ */
6480
+
6481
+ const isCurrencyZeroDecimal = currency => ZERO_DECIMAL_CURRENCIES.includes(currency);
6439
6482
  const sortCountries = countries => {
6440
6483
  const sortable = [];
6441
6484
  delete countries.CA;
@@ -6522,7 +6565,7 @@ const getFormattedPriceByLocal = (amount, currency = "USD", locale = "en") => {
6522
6565
  style: "currency",
6523
6566
  currency
6524
6567
  });
6525
- return formatter.format(amount / 100);
6568
+ return isCurrencyZeroDecimal(currency) ? formatter.format(amount) : formatter.format(amount / 100);
6526
6569
  };
6527
6570
  /** check wether or not the user have any addresses
6528
6571
  * @return {boolean} true if the user have at least one address, false otherwise
@@ -6539,7 +6582,7 @@ const calcAndFormatItemsTotal = (items, currency) => {
6539
6582
  let totalWithoutDividingBy100 = 0;
6540
6583
 
6541
6584
  for (const item of items) {
6542
- totalWithoutDividingBy100 += parseFloat(item.price ? (item.price * item.quantity).toFixed(2) : item.amount.toFixed(2));
6585
+ totalWithoutDividingBy100 += parseFloat(item.price ? isCurrencyZeroDecimal(currency) ? item.price * item.quantity : (item.price * item.quantity).toFixed(2) : isCurrencyZeroDecimal(currency) ? item.amount : item.amount.toFixed(2));
6543
6586
  }
6544
6587
 
6545
6588
  return getFormattedPriceByLocal(totalWithoutDividingBy100, currency, getPageOrDefaultLanguage());
@@ -6551,7 +6594,7 @@ const calcAndFormatItemsTotal = (items, currency) => {
6551
6594
  */
6552
6595
 
6553
6596
  const isValidViewFromURL = viewID => {
6554
- if (["login", "register", "plan-select", "gift-redeem", "password-forgot", "password-reset", "password-change", "payment-method-update", "user-edit", "newsletter", "address-create", "order-create", "cart", "email-verify", "invoice-details"].includes(viewID) || hasValidNewsletterUpdateUrl()) {
6597
+ if (["login", "register", "plan-select", "gift-redeem", "password-forgot", "password-reset", "password-change", "passwordless-login", "payment-method-update", "user-edit", "newsletter", "address-create", "order-create", "cart", "email-verify", "invoice-details"].includes(viewID) || hasValidNewsletterUpdateUrl()) {
6555
6598
  return true;
6556
6599
  }
6557
6600
 
@@ -6619,7 +6662,7 @@ const disableScroll = () => {
6619
6662
  }
6620
6663
  };
6621
6664
  const trackSubscriptionOnGA = () => {
6622
- var _ReactGA$set, _window$Pelcro$user$r5, _window$Pelcro$user$r6, _ReactGA$plugin, _ReactGA$plugin$execu, _ReactGA$plugin2, _ReactGA$plugin2$exec, _ReactGA$plugin3, _ReactGA$plugin3$exec, _ReactGA$event;
6665
+ var _window$Pelcro$user$r5, _window$Pelcro$user$r6, _ReactGA$set, _ReactGA$plugin, _ReactGA$plugin$execu, _ReactGA$plugin2, _ReactGA$plugin2$exec, _ReactGA$plugin3, _ReactGA$plugin3$exec, _ReactGA$event;
6623
6666
 
6624
6667
  const {
6625
6668
  product,
@@ -6640,13 +6683,14 @@ const trackSubscriptionOnGA = () => {
6640
6683
  return;
6641
6684
  }
6642
6685
 
6686
+ const currencyCode = (_window$Pelcro$user$r5 = (_window$Pelcro$user$r6 = window.Pelcro.user.read()) === null || _window$Pelcro$user$r6 === void 0 ? void 0 : _window$Pelcro$user$r6.currency) !== null && _window$Pelcro$user$r5 !== void 0 ? _window$Pelcro$user$r5 : plan.currency;
6643
6687
  ReactGA === null || ReactGA === void 0 ? void 0 : (_ReactGA$set = ReactGA.set) === null || _ReactGA$set === void 0 ? void 0 : _ReactGA$set.call(ReactGA, {
6644
- currencyCode: (_window$Pelcro$user$r5 = (_window$Pelcro$user$r6 = window.Pelcro.user.read()) === null || _window$Pelcro$user$r6 === void 0 ? void 0 : _window$Pelcro$user$r6.currency) !== null && _window$Pelcro$user$r5 !== void 0 ? _window$Pelcro$user$r5 : plan.currency
6688
+ currencyCode: currencyCode
6645
6689
  });
6646
6690
  ReactGA === null || ReactGA === void 0 ? void 0 : (_ReactGA$plugin = ReactGA.plugin) === null || _ReactGA$plugin === void 0 ? void 0 : (_ReactGA$plugin$execu = _ReactGA$plugin.execute) === null || _ReactGA$plugin$execu === void 0 ? void 0 : _ReactGA$plugin$execu.call(_ReactGA$plugin, "ecommerce", "addTransaction", {
6647
6691
  id: lastSubscriptionId,
6648
6692
  affiliation: "Pelcro",
6649
- revenue: plan !== null && plan !== void 0 && plan.amount ? plan.amount / 100 : 0,
6693
+ revenue: plan !== null && plan !== void 0 && plan.amount ? isCurrencyZeroDecimal(currencyCode) ? plan.amount : plan.amount / 100 : 0,
6650
6694
  coupon: couponCode
6651
6695
  });
6652
6696
  ReactGA === null || ReactGA === void 0 ? void 0 : (_ReactGA$plugin2 = ReactGA.plugin) === null || _ReactGA$plugin2 === void 0 ? void 0 : (_ReactGA$plugin2$exec = _ReactGA$plugin2.execute) === null || _ReactGA$plugin2$exec === void 0 ? void 0 : _ReactGA$plugin2$exec.call(_ReactGA$plugin2, "ecommerce", "addItem", {
@@ -6654,7 +6698,7 @@ const trackSubscriptionOnGA = () => {
6654
6698
  name: product.name,
6655
6699
  category: product.description,
6656
6700
  variant: plan.nickname,
6657
- price: plan !== null && plan !== void 0 && plan.amount ? plan.amount / 100 : 0,
6701
+ price: plan !== null && plan !== void 0 && plan.amount ? isCurrencyZeroDecimal(currencyCode) ? plan.amount : plan.amount / 100 : 0,
6658
6702
  quantity: 1
6659
6703
  });
6660
6704
  ReactGA === null || ReactGA === void 0 ? void 0 : (_ReactGA$plugin3 = ReactGA.plugin) === null || _ReactGA$plugin3 === void 0 ? void 0 : (_ReactGA$plugin3$exec = _ReactGA$plugin3.execute) === null || _ReactGA$plugin3$exec === void 0 ? void 0 : _ReactGA$plugin3$exec.call(_ReactGA$plugin3, "ecommerce", "send");
@@ -6766,6 +6810,7 @@ const resources = {
6766
6810
  checkoutForm: checkoutForm_en,
6767
6811
  messages: messages_en,
6768
6812
  login: login_en,
6813
+ verifyLinkToken: verifyLinkToken_en,
6769
6814
  register: register_en,
6770
6815
  userEdit: userEdit_en,
6771
6816
  address: address_en,
@@ -6790,6 +6835,7 @@ const resources = {
6790
6835
  checkoutForm: checkoutForm_fr,
6791
6836
  messages: messages_fr,
6792
6837
  login: login_fr,
6838
+ verifyLinkToken: verifyLinkToken_fr,
6793
6839
  register: register_fr,
6794
6840
  userEdit: userEdit_fr,
6795
6841
  address: address_fr,
@@ -8649,13 +8695,21 @@ const getErrorMessages = error => {
8649
8695
  return error === null || error === void 0 ? void 0 : (_error$response4 = error.response) === null || _error$response4 === void 0 ? void 0 : (_error$response4$data = _error$response4.data) === null || _error$response4$data === void 0 ? void 0 : (_error$response4$data2 = _error$response4$data.error) === null || _error$response4$data2 === void 0 ? void 0 : _error$response4$data2.message;
8650
8696
  }
8651
8697
 
8652
- const errorMessages = []; // enumerable error (ex: validation errors)
8698
+ if (error !== null && error !== void 0 && (_error$response5 = error.response) !== null && _error$response5 !== void 0 && (_error$response5$data = _error$response5.data) !== null && _error$response5$data !== void 0 && _error$response5$data.errors) {
8699
+ var _error$response6, _error$response6$data;
8700
+
8701
+ const errorMessages = []; // enumerable error (ex: validation errors)
8653
8702
 
8654
- Object.values(error === null || error === void 0 ? void 0 : (_error$response5 = error.response) === null || _error$response5 === void 0 ? void 0 : (_error$response5$data = _error$response5.data) === null || _error$response5$data === void 0 ? void 0 : _error$response5$data.errors).forEach(([errorMessage]) => {
8655
- errorMessages.push(errorMessage);
8656
- }); // convert to multiline string
8703
+ Object.values(error === null || error === void 0 ? void 0 : (_error$response6 = error.response) === null || _error$response6 === void 0 ? void 0 : (_error$response6$data = _error$response6.data) === null || _error$response6$data === void 0 ? void 0 : _error$response6$data.errors).forEach(([errorMessage]) => {
8704
+ errorMessages.push(errorMessage);
8705
+ }); // convert to multiline string
8706
+
8707
+ return errorMessages.join("\n");
8708
+ }
8657
8709
 
8658
- return errorMessages.join("\n");
8710
+ if (error !== null && error !== void 0 && error.message) {
8711
+ return error.message;
8712
+ }
8659
8713
  };
8660
8714
  /**
8661
8715
  * Executes function after a wait time of inactivity
@@ -8687,7 +8741,7 @@ const debounce = (func, waitTime) => {
8687
8741
  function getSiteCardProcessor() {
8688
8742
  var _window$Pelcro$site$r;
8689
8743
 
8690
- if ((_window$Pelcro$site$r = window.Pelcro.site.read()) !== null && _window$Pelcro$site$r !== void 0 && _window$Pelcro$site$r.vantiv_pay_page_id) {
8744
+ if ((_window$Pelcro$site$r = window.Pelcro.site.read()) !== null && _window$Pelcro$site$r !== void 0 && _window$Pelcro$site$r.vantiv_gateway_settings) {
8691
8745
  return "vantiv";
8692
8746
  }
8693
8747
 
@@ -8783,7 +8837,7 @@ const loadPaymentSDKs = () => {
8783
8837
  } // Load Vantiv SDKs
8784
8838
 
8785
8839
 
8786
- const supportsVantiv = Boolean(window.Pelcro.site.read().vantiv_pay_page_id);
8840
+ const supportsVantiv = Boolean(window.Pelcro.site.read().vantiv_gateway_settings);
8787
8841
 
8788
8842
  if (supportsVantiv) {
8789
8843
  if (!window.jQuery) {
@@ -8791,7 +8845,10 @@ const loadPaymentSDKs = () => {
8791
8845
  }
8792
8846
 
8793
8847
  if (!window.EprotectIframeClient) {
8794
- window.Pelcro.helpers.loadSDK("https://request.eprotect.vantivprelive.com/eProtect/js/eProtect-iframe-client.min.js", "vantiv-eprotect-sdk");
8848
+ const PRELIVE_URL = "https://request.eprotect.vantivprelive.com/eProtect/js/eProtect-iframe-client.min.js";
8849
+ const PRODUCTION_URL = "https://request.eprotect.vantivcnp.com/eProtect/js/eProtect-iframe-client4.min.js";
8850
+ const scriptUrlToUse = window.Pelcro.site.read().vantiv_gateway_settings.environment === "production" ? PRODUCTION_URL : PRELIVE_URL;
8851
+ window.Pelcro.helpers.loadSDK(scriptUrlToUse, "vantiv-eprotect-sdk");
8795
8852
  }
8796
8853
  }
8797
8854
  };
@@ -8951,6 +9008,10 @@ const initViewFromURL = () => {
8951
9008
  return verifyEmailTokenFromUrl();
8952
9009
  }
8953
9010
 
9011
+ if (view === "passwordless-login") {
9012
+ return verifyLinkTokenFromUrl();
9013
+ }
9014
+
8954
9015
  if (view === "invoice-details") {
8955
9016
  return showInvoiceDetailsFromUrl();
8956
9017
  }
@@ -9131,6 +9192,18 @@ const verifyEmailTokenFromUrl = () => {
9131
9192
  });
9132
9193
  };
9133
9194
 
9195
+ const verifyLinkTokenFromUrl = () => {
9196
+ var _window$Pelcro$user$i, _window$Pelcro$user;
9197
+
9198
+ const isAlreadyLoggedIn = (_window$Pelcro$user$i = (_window$Pelcro$user = window.Pelcro.user) === null || _window$Pelcro$user === void 0 ? void 0 : _window$Pelcro$user.isAuthenticated()) !== null && _window$Pelcro$user$i !== void 0 ? _window$Pelcro$user$i : false;
9199
+ const loginToken = window.Pelcro.helpers.getURLParameter("token");
9200
+ if (isAlreadyLoggedIn || !loginToken) return;
9201
+ const {
9202
+ switchView
9203
+ } = usePelcro.getStore();
9204
+ return switchView("passwordless-login");
9205
+ };
9206
+
9134
9207
  const showInvoiceDetailsFromUrl = () => {
9135
9208
  const {
9136
9209
  isAuthenticated,
@@ -9506,8 +9579,9 @@ const LOAD_PAYMENT_METHODS = "LOAD_PAYMENT_METHODS";
9506
9579
  const GET_NEWSLETTERS_FETCH = "GET_NEWSLETTERS_FETCH";
9507
9580
  const GET_NEWSLETTERS_SUCCESS = "GET_NEWSLETTERS_SUCCESS";
9508
9581
  const SWITCH_TO_UPDATE = "SWITCH_TO_UPDATE";
9582
+ const LINK_TOKEN_VERIFY = "LINK_TOKEN_VERIFY";
9509
9583
 
9510
- const initialState$h = {
9584
+ const initialState$i = {
9511
9585
  email: "",
9512
9586
  password: "",
9513
9587
  emailError: null,
@@ -9518,10 +9592,10 @@ const initialState$h = {
9518
9592
  content: ""
9519
9593
  }
9520
9594
  };
9521
- const store$h = /*#__PURE__*/React.createContext(initialState$h);
9595
+ const store$i = /*#__PURE__*/React.createContext(initialState$i);
9522
9596
  const {
9523
- Provider: Provider$h
9524
- } = store$h;
9597
+ Provider: Provider$i
9598
+ } = store$i;
9525
9599
 
9526
9600
  const LoginContainer = ({
9527
9601
  style,
@@ -9628,7 +9702,7 @@ const LoginContainer = ({
9628
9702
  });
9629
9703
 
9630
9704
  case RESET_LOGIN_FORM:
9631
- return initialState$h;
9705
+ return initialState$i;
9632
9706
 
9633
9707
  case DISABLE_LOGIN_BUTTON:
9634
9708
  return lib_7({ ...state,
@@ -9646,12 +9720,12 @@ const LoginContainer = ({
9646
9720
  default:
9647
9721
  return state;
9648
9722
  }
9649
- }, initialState$h);
9723
+ }, initialState$i);
9650
9724
  return /*#__PURE__*/React__default['default'].createElement("div", {
9651
9725
  style: { ...style
9652
9726
  },
9653
9727
  className: `pelcro-container pelcro-login-container ${className}`
9654
- }, /*#__PURE__*/React__default['default'].createElement(Provider$h, {
9728
+ }, /*#__PURE__*/React__default['default'].createElement(Provider$i, {
9655
9729
  value: {
9656
9730
  state,
9657
9731
  dispatch
@@ -9659,12 +9733,12 @@ const LoginContainer = ({
9659
9733
  }, children.length ? children.map((child, i) => {
9660
9734
  if (child) {
9661
9735
  return /*#__PURE__*/React__default['default'].cloneElement(child, {
9662
- store: store$h,
9736
+ store: store$i,
9663
9737
  key: i
9664
9738
  });
9665
9739
  }
9666
9740
  }) : /*#__PURE__*/React__default['default'].cloneElement(children, {
9667
- store: store$h
9741
+ store: store$i
9668
9742
  })));
9669
9743
  };
9670
9744
 
@@ -9702,6 +9776,7 @@ function Email({
9702
9776
  initWithUserEmail = true,
9703
9777
  disableEmailValidation,
9704
9778
  store,
9779
+ enableEmailEdit,
9705
9780
  ...otherProps
9706
9781
  }) {
9707
9782
  const {
@@ -9727,6 +9802,10 @@ function Email({
9727
9802
  }
9728
9803
 
9729
9804
  if (isEmailValid(email)) {
9805
+ dispatch({
9806
+ type: SET_EMAIL_ERROR,
9807
+ payload: null
9808
+ });
9730
9809
  return dispatch({
9731
9810
  type: SET_EMAIL,
9732
9811
  payload: email
@@ -9747,6 +9826,11 @@ function Email({
9747
9826
  }
9748
9827
  }
9749
9828
  }, [dispatch, email, finishedTyping]);
9829
+ React.useEffect(() => {
9830
+ if (!enableEmailEdit) {
9831
+ loadEmailIntoField();
9832
+ }
9833
+ }, [enableEmailEdit]);
9750
9834
  React.useEffect(() => {
9751
9835
  handleInputChange(email);
9752
9836
  }, [finishedTyping, email, handleInputChange]); // Initialize email field with user's email
@@ -9834,6 +9918,9 @@ function ConfirmPassword({
9834
9918
  store,
9835
9919
  ...otherProps
9836
9920
  }) {
9921
+ const {
9922
+ t
9923
+ } = useTranslation("common");
9837
9924
  const {
9838
9925
  dispatch,
9839
9926
  state: {
@@ -9858,7 +9945,7 @@ function ConfirmPassword({
9858
9945
  } else if (finishedTyping) {
9859
9946
  dispatch({
9860
9947
  type: SET_CONFIRM_PASSWORD_ERROR,
9861
- payload: "Confirm password is required."
9948
+ payload: t("validation.confirmPassword")
9862
9949
  });
9863
9950
  }
9864
9951
  }, [dispatch, password, finishedTyping]);
@@ -9909,7 +9996,7 @@ const LoginButton = ({
9909
9996
  buttonDisabled
9910
9997
  },
9911
9998
  dispatch
9912
- } = React.useContext(store$h);
9999
+ } = React.useContext(store$i);
9913
10000
  const {
9914
10001
  t
9915
10002
  } = useTranslation("login");
@@ -9930,11 +10017,11 @@ const LoginButton = ({
9930
10017
  };
9931
10018
 
9932
10019
  const LoginEmail = props => /*#__PURE__*/React__default['default'].createElement(Email, Object.assign({
9933
- store: store$h
10020
+ store: store$i
9934
10021
  }, props));
9935
10022
 
9936
10023
  const LoginPassword = props => /*#__PURE__*/React__default['default'].createElement(Password, Object.assign({
9937
- store: store$h
10024
+ store: store$i
9938
10025
  }, props));
9939
10026
 
9940
10027
  var _path$r;
@@ -10011,7 +10098,7 @@ var facebookLoginRenderProps = createCommonjsModule(function (module, exports) {
10011
10098
  var FacebookLogin = unwrapExports(facebookLoginRenderProps);
10012
10099
  facebookLoginRenderProps.FacebookLogin;
10013
10100
 
10014
- const initialState$g = {
10101
+ const initialState$h = {
10015
10102
  email: "",
10016
10103
  password: "",
10017
10104
  emailError: null,
@@ -10028,10 +10115,10 @@ const initialState$g = {
10028
10115
  content: ""
10029
10116
  }
10030
10117
  };
10031
- const store$g = /*#__PURE__*/React.createContext(initialState$g);
10118
+ const store$h = /*#__PURE__*/React.createContext(initialState$h);
10032
10119
  const {
10033
- Provider: Provider$g
10034
- } = store$g;
10120
+ Provider: Provider$h
10121
+ } = store$h;
10035
10122
 
10036
10123
  const RegisterContainer = ({
10037
10124
  style,
@@ -10214,7 +10301,7 @@ const RegisterContainer = ({
10214
10301
  });
10215
10302
 
10216
10303
  case RESET_LOGIN_FORM:
10217
- return initialState$g;
10304
+ return initialState$h;
10218
10305
 
10219
10306
  case DISABLE_REGISTRATION_BUTTON:
10220
10307
  return lib_7({ ...state,
@@ -10232,12 +10319,12 @@ const RegisterContainer = ({
10232
10319
  default:
10233
10320
  return state;
10234
10321
  }
10235
- }, initialState$g);
10322
+ }, initialState$h);
10236
10323
  return /*#__PURE__*/React__default['default'].createElement("div", {
10237
10324
  style: { ...style
10238
10325
  },
10239
10326
  className: `pelcro-container pelcro-register-container ${className}`
10240
- }, /*#__PURE__*/React__default['default'].createElement(Provider$g, {
10327
+ }, /*#__PURE__*/React__default['default'].createElement(Provider$h, {
10241
10328
  value: {
10242
10329
  state,
10243
10330
  dispatch
@@ -10245,12 +10332,12 @@ const RegisterContainer = ({
10245
10332
  }, children.length ? children.map((child, i) => {
10246
10333
  if (child) {
10247
10334
  return /*#__PURE__*/React__default['default'].cloneElement(child, {
10248
- store: store$g,
10335
+ store: store$h,
10249
10336
  key: i
10250
10337
  });
10251
10338
  }
10252
10339
  }) : /*#__PURE__*/React__default['default'].cloneElement(children, {
10253
- store: store$g
10340
+ store: store$h
10254
10341
  })));
10255
10342
  };
10256
10343
  /**
@@ -10290,10 +10377,10 @@ const FacebookLoginButton = ({
10290
10377
  const facebookLoginEnabled = (_window$Pelcro$site$r = window.Pelcro.site.read()) === null || _window$Pelcro$site$r === void 0 ? void 0 : _window$Pelcro$site$r.facebook_app_id;
10291
10378
  const {
10292
10379
  dispatch: loginDispatch
10293
- } = React.useContext(store$h);
10380
+ } = React.useContext(store$i);
10294
10381
  const {
10295
10382
  dispatch: registerDispatch
10296
- } = React.useContext(store$g);
10383
+ } = React.useContext(store$h);
10297
10384
 
10298
10385
  const onSuccess = facebookUser => {
10299
10386
  loginDispatch === null || loginDispatch === void 0 ? void 0 : loginDispatch({
@@ -10380,10 +10467,10 @@ const GoogleLoginButton = ({
10380
10467
  const googleLoginEnabled = (_window$Pelcro$site$r = window.Pelcro.site.read()) === null || _window$Pelcro$site$r === void 0 ? void 0 : _window$Pelcro$site$r.google_app_id;
10381
10468
  const {
10382
10469
  dispatch: loginDispatch
10383
- } = React.useContext(store$h);
10470
+ } = React.useContext(store$i);
10384
10471
  const {
10385
10472
  dispatch: registerDispatch
10386
- } = React.useContext(store$g);
10473
+ } = React.useContext(store$h);
10387
10474
 
10388
10475
  const onSuccess = response => {
10389
10476
  var _response$getAuthResp, _profile$getEmail, _profile$getGivenName, _profile$getFamilyNam, _profile$getEmail2, _profile$getGivenName2, _profile$getFamilyNam2;
@@ -10479,10 +10566,10 @@ const Auth0LoginButton = ({
10479
10566
  }, [auth0Enabled, auth0Loaded]);
10480
10567
  const {
10481
10568
  dispatch: loginDispatch
10482
- } = React.useContext(store$h);
10569
+ } = React.useContext(store$i);
10483
10570
  const {
10484
10571
  dispatch: registerDispatch
10485
- } = React.useContext(store$g);
10572
+ } = React.useContext(store$h);
10486
10573
 
10487
10574
  function handleClick() {
10488
10575
  var _auth0InstanceRef$cur, _auth0InstanceRef$cur2, _auth0InstanceRef$cur3;
@@ -10770,11 +10857,11 @@ function LoginModal({
10770
10857
  LoginModal.viewId = "login";
10771
10858
 
10772
10859
  const RegisterEmail = props => /*#__PURE__*/React__default['default'].createElement(Email, Object.assign({
10773
- store: store$g
10860
+ store: store$h
10774
10861
  }, props));
10775
10862
 
10776
10863
  const RegisterPassword = props => /*#__PURE__*/React__default['default'].createElement(Password, Object.assign({
10777
- store: store$g
10864
+ store: store$h
10778
10865
  }, props));
10779
10866
 
10780
10867
  const RegisterButton = ({
@@ -10794,7 +10881,7 @@ const RegisterButton = ({
10794
10881
  buttonDisabled
10795
10882
  },
10796
10883
  dispatch
10797
- } = React.useContext(store$g);
10884
+ } = React.useContext(store$h);
10798
10885
  const {
10799
10886
  t
10800
10887
  } = useTranslation("register");
@@ -10932,7 +11019,7 @@ function FirstName({
10932
11019
  }
10933
11020
 
10934
11021
  const RegisterFirstName = props => /*#__PURE__*/React__default['default'].createElement(FirstName, Object.assign({
10935
- store: store$g
11022
+ store: store$h
10936
11023
  }, props));
10937
11024
 
10938
11025
  function LastName({
@@ -10963,7 +11050,7 @@ function LastName({
10963
11050
  }
10964
11051
 
10965
11052
  const RegisterLastName = props => /*#__PURE__*/React__default['default'].createElement(LastName, Object.assign({
10966
- store: store$g
11053
+ store: store$h
10967
11054
  }, props));
10968
11055
 
10969
11056
  /**
@@ -11087,7 +11174,7 @@ function TextInput({
11087
11174
 
11088
11175
  const RegisterTextInput = props => {
11089
11176
  return /*#__PURE__*/React__default['default'].createElement(TextInput, Object.assign({}, props, {
11090
- store: store$g
11177
+ store: store$h
11091
11178
  }));
11092
11179
  };
11093
11180
 
@@ -12743,20 +12830,21 @@ var es_12 = es.injectStripe;
12743
12830
  var es_13 = es.StripeProvider;
12744
12831
 
12745
12832
  /**
12746
- * @TODO: All subscription related business logic should end up moving
12833
+ * @TODO: All payment related business logic should end up moving
12747
12834
  * to this service, and out of react components.
12748
12835
  */
12749
12836
 
12750
12837
  /**
12751
- * Enum for subscription types
12838
+ * Enum for payment types
12752
12839
  * @readonly
12753
12840
  * @enum {string}
12754
12841
  */
12755
- const SUBSCRIPTION_TYPES = {
12842
+ const PAYMENT_TYPES = {
12756
12843
  CREATE_SUBSCRIPTION: "CREATE_SUBSCRIPTION",
12757
12844
  CREATE_GIFTED_SUBSCRIPTION: "CREATE_GIFTED_SUBSCRIPTION",
12758
12845
  RENEW_SUBSCRIPTION: "RENEW_SUBSCRIPTION",
12759
12846
  RENEW_GIFTED_SUBSCRIPTION: "RENEW_GIFTED_SUBSCRIPTION",
12847
+ PURCHASE_ECOMMERCE_ORDER: "PURCHASE_ECOMMERCE_ORDER",
12760
12848
  PAY_INVOICE: "PAY_INVOICE"
12761
12849
  };
12762
12850
 
@@ -12764,9 +12852,8 @@ var _isPaymentGatewayInvalid = /*#__PURE__*/new WeakMap();
12764
12852
 
12765
12853
  var _generateUserError = /*#__PURE__*/new WeakMap();
12766
12854
 
12767
- class Subscription {
12855
+ class Payment {
12768
12856
  /**
12769
- * Subscription service constructor
12770
12857
  * @param {(StripeGateway|PaypalGateway|VantivGateway)} paymentGateway
12771
12858
  */
12772
12859
  constructor(paymentGateway) {
@@ -12778,7 +12865,7 @@ class Subscription {
12778
12865
 
12779
12866
  if (!options.type) {
12780
12867
  callback(_classPrivateFieldGet(this, _generateUserError).call(this), null);
12781
- return console.error("No subscription type provided");
12868
+ return console.error("No payment type provided");
12782
12869
  } // delegate execution to paymentgateway
12783
12870
 
12784
12871
 
@@ -12796,21 +12883,21 @@ class Subscription {
12796
12883
  writable: true,
12797
12884
  value: () => {
12798
12885
  return {
12799
- error: new Error("An error has occured in the subscription service, please try again later")
12886
+ error: new Error("An error has occured in the payment service, please try again later")
12800
12887
  };
12801
12888
  }
12802
12889
  });
12803
12890
 
12804
12891
  if (_classPrivateFieldGet(this, _isPaymentGatewayInvalid).call(this, paymentGateway)) {
12805
12892
  this.paymentGateway = null;
12806
- console.error("Incompatible subscription gateway");
12893
+ console.error("Incompatible payment gateway");
12807
12894
  } else {
12808
12895
  this.paymentGateway = paymentGateway;
12809
12896
  }
12810
12897
  }
12811
12898
  /**
12812
- * @typedef subscriptionOptions
12813
- * @property {SUBSCRIPTION_TYPES} type
12899
+ * @typedef paymentOptions
12900
+ * @property {PAYMENT_TYPES} type
12814
12901
  * @property {string} token
12815
12902
  * @property {object} plan
12816
12903
  * @property {object} [product]
@@ -12821,6 +12908,7 @@ class Subscription {
12821
12908
  * @property {string} addressId
12822
12909
  * @property {number} invoiceId
12823
12910
  * @property {boolean} isExistingSource
12911
+ * @property {Array} items
12824
12912
  */
12825
12913
 
12826
12914
  /**
@@ -12831,8 +12919,8 @@ class Subscription {
12831
12919
  */
12832
12920
 
12833
12921
  /**
12834
- * Subscription execution method
12835
- * @param {subscriptionOptions} options subscription options
12922
+ * Payment execution method
12923
+ * @param {paymentOptions} options payment options
12836
12924
  * @param {executeCallback} callback
12837
12925
  * @return {void}
12838
12926
  */
@@ -12845,7 +12933,7 @@ const PAYMENT_GATEWAYS_ENUM = {
12845
12933
  vantiv: "vantiv"
12846
12934
  };
12847
12935
  /**
12848
- * Subscription Strategies
12936
+ * Payment Strategies
12849
12937
  */
12850
12938
 
12851
12939
  /**
@@ -12862,6 +12950,8 @@ var _renewSubscription = /*#__PURE__*/new WeakMap();
12862
12950
 
12863
12951
  var _renewGiftedSubscription = /*#__PURE__*/new WeakMap();
12864
12952
 
12953
+ var _purchaseEcommerceOrder = /*#__PURE__*/new WeakMap();
12954
+
12865
12955
  var _payInvoice = /*#__PURE__*/new WeakMap();
12866
12956
 
12867
12957
  class StripeGateway {
@@ -12872,7 +12962,7 @@ class StripeGateway {
12872
12962
  });
12873
12963
 
12874
12964
  _defineProperty$3(this, "execute", (options, callback) => {
12875
- const types = SUBSCRIPTION_TYPES;
12965
+ const types = PAYMENT_TYPES;
12876
12966
 
12877
12967
  switch (options.type) {
12878
12968
  case types.CREATE_SUBSCRIPTION:
@@ -12887,11 +12977,14 @@ class StripeGateway {
12887
12977
  case types.RENEW_GIFTED_SUBSCRIPTION:
12888
12978
  return _classPrivateFieldGet(this, _renewGiftedSubscription).call(this, options, callback);
12889
12979
 
12980
+ case types.PURCHASE_ECOMMERCE_ORDER:
12981
+ return _classPrivateFieldGet(this, _purchaseEcommerceOrder).call(this, options, callback);
12982
+
12890
12983
  case types.PAY_INVOICE:
12891
12984
  return _classPrivateFieldGet(this, _payInvoice).call(this, options, callback);
12892
12985
 
12893
12986
  default:
12894
- console.error("Unsupported subscriptiion method: Stripe Gateway");
12987
+ console.error("Unsupported payment method: Stripe Gateway");
12895
12988
  }
12896
12989
  });
12897
12990
 
@@ -12913,6 +13006,7 @@ class StripeGateway {
12913
13006
  auth_token: window.Pelcro.user.read().auth_token,
12914
13007
  plan_id: plan.id,
12915
13008
  coupon_code: couponCode,
13009
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
12916
13010
  address_id: product.address_required ? addressId : null
12917
13011
  }, (err, res) => {
12918
13012
  callback(err, res);
@@ -12939,6 +13033,7 @@ class StripeGateway {
12939
13033
  auth_token: window.Pelcro.user.read().auth_token,
12940
13034
  plan_id: plan.id,
12941
13035
  coupon_code: couponCode,
13036
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
12942
13037
  gift_recipient_email: giftRecipient.email,
12943
13038
  gift_recipient_first_name: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.firstName,
12944
13039
  gift_recipient_last_name: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.lastName,
@@ -12966,6 +13061,7 @@ class StripeGateway {
12966
13061
  stripe_token: token,
12967
13062
  auth_token: window.Pelcro.user.read().auth_token,
12968
13063
  plan_id: plan.id,
13064
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
12969
13065
  coupon_code: couponCode,
12970
13066
  subscription_id: subscriptionIdToRenew,
12971
13067
  address_id: product.address_required ? addressId : null
@@ -12999,6 +13095,36 @@ class StripeGateway {
12999
13095
  }
13000
13096
  });
13001
13097
 
13098
+ _purchaseEcommerceOrder.set(this, {
13099
+ writable: true,
13100
+ value: (options, callback) => {
13101
+ const {
13102
+ token,
13103
+ items,
13104
+ couponCode,
13105
+ addressId,
13106
+ isExistingSource
13107
+ } = options;
13108
+ const params = isExistingSource ? {
13109
+ source_id: token
13110
+ } : {
13111
+ payment_gateway: _classPrivateFieldGet(this, _paymentGateway),
13112
+ gateway_token: token
13113
+ };
13114
+ window.Pelcro.ecommerce.order.create({
13115
+ items,
13116
+ coupon_code: couponCode,
13117
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
13118
+ ...params,
13119
+ ...(addressId && {
13120
+ address_id: addressId
13121
+ })
13122
+ }, (err, res) => {
13123
+ callback(err, res);
13124
+ });
13125
+ }
13126
+ });
13127
+
13002
13128
  _payInvoice.set(this, {
13003
13129
  writable: true,
13004
13130
  value: (options, callback) => {
@@ -13042,7 +13168,7 @@ class PaypalGateway {
13042
13168
  });
13043
13169
 
13044
13170
  _defineProperty$3(this, "execute", (options, callback) => {
13045
- const types = SUBSCRIPTION_TYPES;
13171
+ const types = PAYMENT_TYPES;
13046
13172
 
13047
13173
  switch (options.type) {
13048
13174
  case types.CREATE_SUBSCRIPTION:
@@ -13076,6 +13202,7 @@ class PaypalGateway {
13076
13202
  payment_gateway: _classPrivateFieldGet(this, _paymentGateway2),
13077
13203
  auth_token: window.Pelcro.user.read().auth_token,
13078
13204
  plan_id: plan.id,
13205
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
13079
13206
  coupon_code: couponCode,
13080
13207
  address_id: product.address_required ? addressId : null
13081
13208
  }, (err, res) => {
@@ -13103,6 +13230,7 @@ class PaypalGateway {
13103
13230
  auth_token: window.Pelcro.user.read().auth_token,
13104
13231
  plan_id: plan.id,
13105
13232
  coupon_code: couponCode,
13233
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
13106
13234
  gift_recipient_email: giftRecipient.email,
13107
13235
  gift_recipient_first_name: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.firstName,
13108
13236
  gift_recipient_last_name: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.lastName,
@@ -13139,6 +13267,16 @@ var _paymentGateway3 = /*#__PURE__*/new WeakMap();
13139
13267
 
13140
13268
  var _createSubscription3 = /*#__PURE__*/new WeakMap();
13141
13269
 
13270
+ var _renewSubscription2 = /*#__PURE__*/new WeakMap();
13271
+
13272
+ var _createGiftedSubscription3 = /*#__PURE__*/new WeakMap();
13273
+
13274
+ var _renewGiftedSubscription2 = /*#__PURE__*/new WeakMap();
13275
+
13276
+ var _purchaseEcommerceOrder2 = /*#__PURE__*/new WeakMap();
13277
+
13278
+ var _payInvoice3 = /*#__PURE__*/new WeakMap();
13279
+
13142
13280
  class VantivGateway {
13143
13281
  constructor() {
13144
13282
  _paymentGateway3.set(this, {
@@ -13147,14 +13285,29 @@ class VantivGateway {
13147
13285
  });
13148
13286
 
13149
13287
  _defineProperty$3(this, "execute", (options, callback) => {
13150
- const types = SUBSCRIPTION_TYPES;
13288
+ const types = PAYMENT_TYPES;
13151
13289
 
13152
13290
  switch (options.type) {
13153
13291
  case types.CREATE_SUBSCRIPTION:
13154
13292
  return _classPrivateFieldGet(this, _createSubscription3).call(this, options, callback);
13155
13293
 
13294
+ case types.RENEW_SUBSCRIPTION:
13295
+ return _classPrivateFieldGet(this, _renewSubscription2).call(this, options, callback);
13296
+
13297
+ case types.CREATE_GIFTED_SUBSCRIPTION:
13298
+ return _classPrivateFieldGet(this, _createGiftedSubscription3).call(this, options, callback);
13299
+
13300
+ case types.RENEW_GIFTED_SUBSCRIPTION:
13301
+ return _classPrivateFieldGet(this, _renewGiftedSubscription2).call(this, options, callback);
13302
+
13303
+ case types.PURCHASE_ECOMMERCE_ORDER:
13304
+ return _classPrivateFieldGet(this, _purchaseEcommerceOrder2).call(this, options, callback);
13305
+
13306
+ case types.PAY_INVOICE:
13307
+ return _classPrivateFieldGet(this, _payInvoice3).call(this, options, callback);
13308
+
13156
13309
  default:
13157
- console.error("Unsupported subscriptiion method: vantiv Gateway");
13310
+ console.error("Unsupported payment method: vantiv Gateway");
13158
13311
  }
13159
13312
  });
13160
13313
 
@@ -13167,38 +13320,197 @@ class VantivGateway {
13167
13320
  couponCode,
13168
13321
  product,
13169
13322
  quantity = 1,
13170
- addressId
13323
+ addressId,
13324
+ isExistingSource
13171
13325
  } = options;
13326
+ const params = isExistingSource ? {
13327
+ source_id: token
13328
+ } : {
13329
+ payment_gateway: _classPrivateFieldGet(this, _paymentGateway3),
13330
+ gateway_token: token
13331
+ };
13172
13332
  window.Pelcro.subscription.create({
13173
13333
  quantity,
13174
- gateway_token: token,
13334
+ auth_token: window.Pelcro.user.read().auth_token,
13335
+ plan_id: plan.id,
13336
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
13337
+ coupon_code: couponCode,
13338
+ address_id: product.address_required ? addressId : null,
13339
+ ...params
13340
+ }, (err, res) => {
13341
+ callback(err, res);
13342
+ });
13343
+ }
13344
+ });
13345
+
13346
+ _renewSubscription2.set(this, {
13347
+ writable: true,
13348
+ value: (options, callback) => {
13349
+ const {
13350
+ subscriptionIdToRenew,
13351
+ token,
13352
+ plan,
13353
+ couponCode,
13354
+ product,
13355
+ addressId,
13356
+ isExistingSource
13357
+ } = options;
13358
+ const params = isExistingSource ? {
13359
+ source_id: token
13360
+ } : {
13175
13361
  payment_gateway: _classPrivateFieldGet(this, _paymentGateway3),
13362
+ gateway_token: token
13363
+ };
13364
+ window.Pelcro.subscription.renew({
13176
13365
  auth_token: window.Pelcro.user.read().auth_token,
13177
13366
  plan_id: plan.id,
13178
13367
  coupon_code: couponCode,
13179
- address_id: product.address_required ? addressId : null
13368
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
13369
+ subscription_id: subscriptionIdToRenew,
13370
+ address_id: product.address_required ? addressId : null,
13371
+ ...params
13180
13372
  }, (err, res) => {
13181
13373
  callback(err, res);
13182
13374
  });
13183
13375
  }
13184
13376
  });
13185
- }
13186
13377
 
13187
- }
13378
+ _createGiftedSubscription3.set(this, {
13379
+ writable: true,
13380
+ value: (options, callback) => {
13381
+ const {
13382
+ token,
13383
+ plan,
13384
+ couponCode,
13385
+ product,
13386
+ giftRecipient,
13387
+ quantity = 1,
13388
+ addressId,
13389
+ isExistingSource
13390
+ } = options;
13391
+ const params = isExistingSource ? {
13392
+ source_id: token
13393
+ } : {
13394
+ payment_gateway: _classPrivateFieldGet(this, _paymentGateway3),
13395
+ gateway_token: token
13396
+ };
13397
+ window.Pelcro.subscription.create({
13398
+ quantity,
13399
+ auth_token: window.Pelcro.user.read().auth_token,
13400
+ plan_id: plan.id,
13401
+ coupon_code: couponCode,
13402
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
13403
+ gift_recipient_email: giftRecipient.email,
13404
+ gift_recipient_first_name: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.firstName,
13405
+ gift_recipient_last_name: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.lastName,
13406
+ gift_start_date: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.startDate,
13407
+ gift_message: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.giftMessage,
13408
+ address_id: product.address_required ? addressId : null,
13409
+ ...params
13410
+ }, (err, res) => {
13411
+ callback(err, res);
13412
+ });
13413
+ }
13414
+ });
13188
13415
 
13189
- /**
13190
- * @typedef {Object} PaymentStateType
13191
- * @property {boolean} disableSubmit
13192
- * @property {boolean} isLoading
13193
- * @property {boolean} disableCouponButton
13194
- * @property {object} couponObject
13195
- * @property {string} couponCode
13196
- * @property {string} couponError
13197
- * @property {boolean} enableCouponField
13198
- * @property {string} percentOff
13199
- * @property {unknown} canMakePayment
13200
- * @property {unknown} paymentRequest
13201
- * @property {number} updatedPrice
13416
+ _renewGiftedSubscription2.set(this, {
13417
+ writable: true,
13418
+ value: (options, callback) => {
13419
+ const {
13420
+ subscriptionIdToRenew,
13421
+ token,
13422
+ product,
13423
+ plan,
13424
+ couponCode,
13425
+ addressId,
13426
+ isExistingSource
13427
+ } = options;
13428
+ const params = isExistingSource ? {
13429
+ source_id: token
13430
+ } : {
13431
+ payment_gateway: _classPrivateFieldGet(this, _paymentGateway3),
13432
+ gateway_token: token
13433
+ };
13434
+ window.Pelcro.subscription.renewGift({
13435
+ auth_token: window.Pelcro.user.read().auth_token,
13436
+ plan_id: plan.id,
13437
+ coupon_code: couponCode,
13438
+ subscription_id: subscriptionIdToRenew,
13439
+ address_id: product.address_required ? addressId : null,
13440
+ ...params
13441
+ }, (err, res) => {
13442
+ callback(err, res);
13443
+ });
13444
+ }
13445
+ });
13446
+
13447
+ _purchaseEcommerceOrder2.set(this, {
13448
+ writable: true,
13449
+ value: (options, callback) => {
13450
+ const {
13451
+ token,
13452
+ items,
13453
+ couponCode,
13454
+ addressId,
13455
+ isExistingSource
13456
+ } = options;
13457
+ const params = isExistingSource ? {
13458
+ source_id: token
13459
+ } : {
13460
+ payment_gateway: _classPrivateFieldGet(this, _paymentGateway3),
13461
+ gateway_token: token
13462
+ };
13463
+ window.Pelcro.ecommerce.order.create({
13464
+ items,
13465
+ coupon_code: couponCode,
13466
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
13467
+ ...params,
13468
+ ...(addressId && {
13469
+ address_id: addressId
13470
+ })
13471
+ }, (err, res) => {
13472
+ callback(err, res);
13473
+ });
13474
+ }
13475
+ });
13476
+
13477
+ _payInvoice3.set(this, {
13478
+ writable: true,
13479
+ value: (options, callback) => {
13480
+ const {
13481
+ token,
13482
+ invoiceId
13483
+ } = options;
13484
+ const params = options.isExistingSource ? {
13485
+ source_id: token,
13486
+ invoice_id: invoiceId
13487
+ } : {
13488
+ payment_gateway: _classPrivateFieldGet(this, _paymentGateway3),
13489
+ gateway_token: token,
13490
+ invoice_id: invoiceId
13491
+ };
13492
+ window.Pelcro.invoice.pay(params, (err, res) => {
13493
+ callback(err, res);
13494
+ });
13495
+ }
13496
+ });
13497
+ }
13498
+
13499
+ }
13500
+
13501
+ /**
13502
+ * @typedef {Object} PaymentStateType
13503
+ * @property {boolean} disableSubmit
13504
+ * @property {boolean} isLoading
13505
+ * @property {boolean} disableCouponButton
13506
+ * @property {object} couponObject
13507
+ * @property {string} couponCode
13508
+ * @property {string} couponError
13509
+ * @property {boolean} enableCouponField
13510
+ * @property {string} percentOff
13511
+ * @property {unknown} canMakePayment
13512
+ * @property {unknown} paymentRequest
13513
+ * @property {number} updatedPrice
13202
13514
  * @property {number} taxAmount
13203
13515
  * @property {object} currentPlan
13204
13516
  * @property {object} alert
@@ -13206,7 +13518,7 @@ class VantivGateway {
13206
13518
 
13207
13519
  /** @type {PaymentStateType} */
13208
13520
 
13209
- const initialState$f = {
13521
+ const initialState$g = {
13210
13522
  disableSubmit: false,
13211
13523
  isLoading: false,
13212
13524
  disableCouponButton: false,
@@ -13225,10 +13537,10 @@ const initialState$f = {
13225
13537
  content: ""
13226
13538
  }
13227
13539
  };
13228
- const store$f = /*#__PURE__*/React.createContext(initialState$f);
13540
+ const store$g = /*#__PURE__*/React.createContext(initialState$g);
13229
13541
  const {
13230
- Provider: Provider$f
13231
- } = store$f;
13542
+ Provider: Provider$g
13543
+ } = store$g;
13232
13544
 
13233
13545
  const PaymentMethodContainerWithoutStripe = ({
13234
13546
  style,
@@ -13241,7 +13553,7 @@ const PaymentMethodContainerWithoutStripe = ({
13241
13553
  onFailure = () => {},
13242
13554
  ...props
13243
13555
  }) => {
13244
- var _props$product, _props$plan, _props$subscriptionId, _props$selectedAddres, _props$giftRecipient, _props$isRenewingGift, _props$invoice;
13556
+ var _props$product, _props$plan, _props$subscriptionId, _props$selectedAddres, _props$giftRecipient, _props$isGift, _props$isRenewingGift, _props$invoice;
13245
13557
 
13246
13558
  const {
13247
13559
  t
@@ -13257,6 +13569,7 @@ const PaymentMethodContainerWithoutStripe = ({
13257
13569
  const subscriptionIdToRenew = (_props$subscriptionId = props.subscriptionIdToRenew) !== null && _props$subscriptionId !== void 0 ? _props$subscriptionId : pelcroStore.subscriptionIdToRenew;
13258
13570
  const selectedAddressId = (_props$selectedAddres = props.selectedAddressId) !== null && _props$selectedAddres !== void 0 ? _props$selectedAddres : pelcroStore.selectedAddressId;
13259
13571
  const giftRecipient = (_props$giftRecipient = props.giftRecipient) !== null && _props$giftRecipient !== void 0 ? _props$giftRecipient : pelcroStore.giftRecipient;
13572
+ const isGift = (_props$isGift = props.isGift) !== null && _props$isGift !== void 0 ? _props$isGift : pelcroStore.isGift;
13260
13573
  const isRenewingGift = (_props$isRenewingGift = props.isRenewingGift) !== null && _props$isRenewingGift !== void 0 ? _props$isRenewingGift : pelcroStore.isRenewingGift;
13261
13574
  const invoice = (_props$invoice = props.invoice) !== null && _props$invoice !== void 0 ? _props$invoice : pelcroStore.invoice;
13262
13575
  React.useEffect(() => {
@@ -13273,60 +13586,185 @@ const PaymentMethodContainerWithoutStripe = ({
13273
13586
  updateTotalAmountWithTax();
13274
13587
  }, []);
13275
13588
 
13276
- function submitVantivPayment() {
13589
+ const submitUsingVantiv = () => {
13590
+ const isUsingExistingPaymentMethod = Boolean(selectedPaymentMethodId);
13591
+
13592
+ if (isUsingExistingPaymentMethod) {
13593
+ // no need to create a new source using vantiv
13594
+ return handleVantivPayment(null);
13595
+ }
13596
+
13277
13597
  if (!vantivInstanceRef.current) {
13278
13598
  return console.error("Vantiv sdk script wasn't loaded, you need to load vantiv sdk before rendering the vantiv payment flow");
13279
13599
  }
13280
13600
 
13281
- const orderId = `pelcro-${new Date().getTime()}`; // calls handleVantivPayment
13601
+ const orderId = `pelcro-${new Date().getTime()}`;
13602
+ /*
13603
+ calls handleVantivPayment to either handle a payment or update a source by simply creating a new source
13604
+ */
13282
13605
 
13283
13606
  vantivInstanceRef.current.getPaypageRegistrationId({
13284
13607
  id: orderId,
13285
13608
  orderId: orderId
13286
13609
  });
13287
- }
13610
+ };
13288
13611
 
13289
13612
  function handleVantivPayment(paymentRequest) {
13290
- const SUCCESS_STATUS = "870";
13613
+ if (paymentRequest) {
13614
+ const SUCCESS_STATUS = "870";
13615
+
13616
+ if (paymentRequest.response !== SUCCESS_STATUS) {
13617
+ return handlePaymentError({
13618
+ error: new Error(paymentRequest.message)
13619
+ });
13620
+ }
13621
+ }
13622
+
13623
+ const isUsingExistingPaymentMethod = Boolean(selectedPaymentMethodId);
13624
+
13625
+ if (type === "createPayment") {
13626
+ handleVantivSubscription();
13627
+ } else if (type === "orderCreate") {
13628
+ purchase(new VantivGateway(), isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest, state, dispatch);
13629
+ } else if (type === "invoicePayment") {
13630
+ payInvoice(new VantivGateway(), isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest, dispatch);
13631
+ } else if (type === "updatePaymentSource") {
13632
+ createNewVantivCard();
13633
+ }
13634
+
13635
+ function createNewVantivCard() {
13636
+ window.Pelcro.source.create({
13637
+ auth_token: window.Pelcro.user.read().auth_token,
13638
+ token: paymentRequest,
13639
+ gateway: "vantiv"
13640
+ }, (err, res) => {
13641
+ dispatch({
13642
+ type: DISABLE_SUBMIT,
13643
+ payload: false
13644
+ });
13645
+ dispatch({
13646
+ type: LOADING,
13647
+ payload: false
13648
+ });
13649
+
13650
+ if (err) {
13651
+ onFailure(err);
13652
+ return dispatch({
13653
+ type: SHOW_ALERT,
13654
+ payload: {
13655
+ type: "error",
13656
+ content: getErrorMessages(err)
13657
+ }
13658
+ });
13659
+ }
13291
13660
 
13292
- if (paymentRequest.response !== SUCCESS_STATUS) {
13293
- return handlePaymentError({
13294
- error: new Error(paymentRequest.message)
13661
+ dispatch({
13662
+ type: SHOW_ALERT,
13663
+ payload: {
13664
+ type: "success",
13665
+ content: t("messages.sourceUpdated")
13666
+ }
13667
+ });
13668
+ onSuccess(res);
13295
13669
  });
13296
13670
  }
13297
13671
 
13298
- const subscription = new Subscription(new VantivGateway());
13299
- const {
13300
- couponCode
13301
- } = state;
13302
- return subscription.execute({
13303
- type: SUBSCRIPTION_TYPES.CREATE_SUBSCRIPTION,
13304
- token: paymentRequest,
13305
- quantity: plan.quantity,
13306
- plan,
13307
- couponCode,
13308
- product,
13309
- addressId: selectedAddressId
13310
- }, (err, res) => {
13311
- if (err) {
13312
- return handlePaymentError(err);
13313
- }
13672
+ function handleVantivSubscription() {
13673
+ const payment = new Payment(new VantivGateway());
13674
+ const createSubscription = !isGift && !subscriptionIdToRenew;
13675
+ const renewSubscription = !isGift && subscriptionIdToRenew;
13676
+ const giftSubscriprition = isGift && !subscriptionIdToRenew;
13677
+ const renewGift = isRenewingGift;
13678
+ const {
13679
+ couponCode
13680
+ } = state;
13314
13681
 
13315
- onSuccess(res);
13316
- });
13682
+ if (renewGift) {
13683
+ return payment.execute({
13684
+ type: PAYMENT_TYPES.RENEW_GIFTED_SUBSCRIPTION,
13685
+ token: isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest,
13686
+ plan,
13687
+ couponCode,
13688
+ product,
13689
+ isExistingSource: isUsingExistingPaymentMethod,
13690
+ subscriptionIdToRenew,
13691
+ addressId: selectedAddressId
13692
+ }, (err, res) => {
13693
+ if (err) {
13694
+ return handlePaymentError(err);
13695
+ }
13696
+
13697
+ onSuccess(res);
13698
+ });
13699
+ } else if (giftSubscriprition) {
13700
+ return payment.execute({
13701
+ type: PAYMENT_TYPES.CREATE_GIFTED_SUBSCRIPTION,
13702
+ token: isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest,
13703
+ quantity: plan.quantity,
13704
+ plan,
13705
+ couponCode,
13706
+ product,
13707
+ isExistingSource: isUsingExistingPaymentMethod,
13708
+ giftRecipient,
13709
+ addressId: selectedAddressId
13710
+ }, (err, res) => {
13711
+ if (err) {
13712
+ return handlePaymentError(err);
13713
+ }
13714
+
13715
+ onSuccess(res);
13716
+ });
13717
+ } else if (renewSubscription) {
13718
+ return payment.execute({
13719
+ type: PAYMENT_TYPES.RENEW_SUBSCRIPTION,
13720
+ token: isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest,
13721
+ quantity: plan.quantity,
13722
+ plan,
13723
+ couponCode,
13724
+ product,
13725
+ isExistingSource: isUsingExistingPaymentMethod,
13726
+ subscriptionIdToRenew,
13727
+ addressId: selectedAddressId
13728
+ }, (err, res) => {
13729
+ if (err) {
13730
+ return handlePaymentError(err);
13731
+ }
13732
+
13733
+ onSuccess(res);
13734
+ });
13735
+ } else if (createSubscription) {
13736
+ return payment.execute({
13737
+ type: PAYMENT_TYPES.CREATE_SUBSCRIPTION,
13738
+ token: isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest,
13739
+ quantity: plan.quantity,
13740
+ plan,
13741
+ couponCode,
13742
+ product,
13743
+ isExistingSource: isUsingExistingPaymentMethod,
13744
+ addressId: selectedAddressId
13745
+ }, (err, res) => {
13746
+ if (err) {
13747
+ return handlePaymentError(err);
13748
+ }
13749
+
13750
+ onSuccess(res);
13751
+ });
13752
+ }
13753
+ }
13317
13754
  }
13318
13755
 
13319
13756
  const vantivInstanceRef = React__default['default'].useRef(null);
13320
13757
  React.useEffect(() => {
13321
13758
  const cardProcessor = getSiteCardProcessor();
13322
13759
 
13323
- if (cardProcessor === "vantiv") {
13324
- var _window$Pelcro$site$r;
13760
+ if (cardProcessor === "vantiv" && !selectedPaymentMethodId) {
13761
+ var _window$Pelcro$site$r, _window$Pelcro$site$r2;
13325
13762
 
13326
- const payPageId = (_window$Pelcro$site$r = window.Pelcro.site.read()) === null || _window$Pelcro$site$r === void 0 ? void 0 : _window$Pelcro$site$r.vantiv_pay_page_id;
13763
+ const payPageId = (_window$Pelcro$site$r = window.Pelcro.site.read()) === null || _window$Pelcro$site$r === void 0 ? void 0 : _window$Pelcro$site$r.vantiv_gateway_settings.pay_page_id;
13764
+ const reportGroup = (_window$Pelcro$site$r2 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r2 === void 0 ? void 0 : _window$Pelcro$site$r2.vantiv_gateway_settings.report_group;
13327
13765
  vantivInstanceRef.current = new window.EprotectIframeClient({
13328
13766
  paypageId: payPageId,
13329
- reportGroup: payPageId,
13767
+ reportGroup: reportGroup,
13330
13768
  style: "pelcro",
13331
13769
  height: "245",
13332
13770
  timeout: 50000,
@@ -13343,7 +13781,7 @@ const PaymentMethodContainerWithoutStripe = ({
13343
13781
  }
13344
13782
  });
13345
13783
  }
13346
- }, []);
13784
+ }, [selectedPaymentMethodId]);
13347
13785
 
13348
13786
  const initPaymentRequest = (state, dispatch) => {
13349
13787
  try {
@@ -13415,9 +13853,9 @@ const PaymentMethodContainerWithoutStripe = ({
13415
13853
 
13416
13854
 
13417
13855
  const updateTotalAmountWithTax = () => {
13418
- var _window$Pelcro$site$r2;
13856
+ var _window$Pelcro$site$r3;
13419
13857
 
13420
- const taxesEnabled = (_window$Pelcro$site$r2 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r2 === void 0 ? void 0 : _window$Pelcro$site$r2.taxes_enabled;
13858
+ const taxesEnabled = (_window$Pelcro$site$r3 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r3 === void 0 ? void 0 : _window$Pelcro$site$r3.taxes_enabled;
13421
13859
 
13422
13860
  if (taxesEnabled && type === "createPayment") {
13423
13861
  dispatch({
@@ -13574,6 +14012,7 @@ const PaymentMethodContainerWithoutStripe = ({
13574
14012
  window.Pelcro.order.create({
13575
14013
  auth_token: window.Pelcro.user.read().auth_token,
13576
14014
  plan_id: plan.id,
14015
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
13577
14016
  coupon_code: couponCode,
13578
14017
  address_id: selectedAddressId
13579
14018
  }, handleCouponResponse);
@@ -13655,6 +14094,7 @@ const PaymentMethodContainerWithoutStripe = ({
13655
14094
  stripe_token: !stripeSource.isExistingSource ? stripeSource.id : undefined,
13656
14095
  auth_token: window.Pelcro.user.read().auth_token,
13657
14096
  plan_id: plan.id,
14097
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
13658
14098
  quantity: plan.quantity,
13659
14099
  coupon_code: couponCode,
13660
14100
  gift_recipient_email: giftRecipient ? giftRecipient.email : null,
@@ -13726,6 +14166,7 @@ const PaymentMethodContainerWithoutStripe = ({
13726
14166
  stripe_token: !stripeSource.isExistingSource ? stripeSource.id : undefined,
13727
14167
  auth_token: window.Pelcro.user.read().auth_token,
13728
14168
  plan_id: plan.id,
14169
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
13729
14170
  coupon_code: couponCode,
13730
14171
  subscription_id: subscriptionIdToRenew,
13731
14172
  address_id: product.address_required ? selectedAddressId : null
@@ -13767,7 +14208,7 @@ const PaymentMethodContainerWithoutStripe = ({
13767
14208
 
13768
14209
 
13769
14210
  const handlePaypalSubscription = (state, paypalNonce) => {
13770
- const subscription = new Subscription(new PaypalGateway());
14211
+ const payment = new Payment(new PaypalGateway());
13771
14212
  const {
13772
14213
  couponCode
13773
14214
  } = state;
@@ -13776,8 +14217,8 @@ const PaymentMethodContainerWithoutStripe = ({
13776
14217
  */
13777
14218
 
13778
14219
  if (giftRecipient) {
13779
- return subscription.execute({
13780
- type: SUBSCRIPTION_TYPES.CREATE_GIFTED_SUBSCRIPTION,
14220
+ return payment.execute({
14221
+ type: PAYMENT_TYPES.CREATE_GIFTED_SUBSCRIPTION,
13781
14222
  token: paypalNonce,
13782
14223
  quantity: plan.quantity,
13783
14224
  plan,
@@ -13810,8 +14251,8 @@ const PaymentMethodContainerWithoutStripe = ({
13810
14251
  });
13811
14252
  }
13812
14253
 
13813
- return subscription.execute({
13814
- type: SUBSCRIPTION_TYPES.CREATE_SUBSCRIPTION,
14254
+ return payment.execute({
14255
+ type: PAYMENT_TYPES.CREATE_SUBSCRIPTION,
13815
14256
  token: paypalNonce,
13816
14257
  quantity: plan.quantity,
13817
14258
  plan,
@@ -13843,7 +14284,7 @@ const PaymentMethodContainerWithoutStripe = ({
13843
14284
  });
13844
14285
  };
13845
14286
 
13846
- const purchase = (stripeSource, state, dispatch) => {
14287
+ const purchase = (gatewayService, gatewayToken, state, dispatch) => {
13847
14288
  const isQuickPurchase = !Array.isArray(order);
13848
14289
  const mappedOrderItems = isQuickPurchase ? [{
13849
14290
  sku_id: order.id,
@@ -13855,14 +14296,14 @@ const PaymentMethodContainerWithoutStripe = ({
13855
14296
  const {
13856
14297
  couponCode
13857
14298
  } = state;
13858
- window.Pelcro.ecommerce.order.create({
13859
- source_id: stripeSource.isExistingSource ? stripeSource.id : undefined,
13860
- stripe_token: !stripeSource.isExistingSource ? stripeSource.id : undefined,
14299
+ const payment = new Payment(gatewayService);
14300
+ payment.execute({
14301
+ type: PAYMENT_TYPES.PURCHASE_ECOMMERCE_ORDER,
14302
+ token: gatewayToken,
14303
+ isExistingSource: Boolean(selectedPaymentMethodId),
13861
14304
  items: mappedOrderItems,
13862
- coupon_code: couponCode,
13863
- ...(selectedAddressId && {
13864
- address_id: selectedAddressId
13865
- })
14305
+ addressId: selectedAddressId,
14306
+ couponCode
13866
14307
  }, (err, res) => {
13867
14308
  dispatch({
13868
14309
  type: DISABLE_SUBMIT,
@@ -13900,9 +14341,9 @@ const PaymentMethodContainerWithoutStripe = ({
13900
14341
  };
13901
14342
 
13902
14343
  const payInvoice = (gatewayService, gatewayToken, dispatch) => {
13903
- const subscription = new Subscription(gatewayService);
13904
- return subscription.execute({
13905
- type: SUBSCRIPTION_TYPES.PAY_INVOICE,
14344
+ const payment = new Payment(gatewayService);
14345
+ return payment.execute({
14346
+ type: PAYMENT_TYPES.PAY_INVOICE,
13906
14347
  token: gatewayToken,
13907
14348
  isExistingSource: Boolean(selectedPaymentMethodId),
13908
14349
  invoiceId: invoice.id
@@ -13947,7 +14388,9 @@ const PaymentMethodContainerWithoutStripe = ({
13947
14388
 
13948
14389
  if ((source === null || source === void 0 ? void 0 : (_source$card2 = source.card) === null || _source$card2 === void 0 ? void 0 : _source$card2.three_d_secure) === "required") {
13949
14390
  return handlePaymentError({
13950
- message: t("messages.cardAuthNotSupported")
14391
+ error: {
14392
+ message: t("messages.cardAuthNotSupported")
14393
+ }
13951
14394
  });
13952
14395
  }
13953
14396
 
@@ -14062,13 +14505,13 @@ const PaymentMethodContainerWithoutStripe = ({
14062
14505
 
14063
14506
 
14064
14507
  const resolveTaxCalculation = () => {
14065
- var _window$Pelcro$site$r3;
14508
+ var _window$Pelcro$site$r4;
14066
14509
 
14067
14510
  if (type === "invoicePayment") {
14068
14511
  return new Promise(resolve => resolve());
14069
14512
  }
14070
14513
 
14071
- const taxesEnabled = (_window$Pelcro$site$r3 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r3 === void 0 ? void 0 : _window$Pelcro$site$r3.taxes_enabled;
14514
+ const taxesEnabled = (_window$Pelcro$site$r4 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r4 === void 0 ? void 0 : _window$Pelcro$site$r4.taxes_enabled;
14072
14515
  return new Promise((resolve, reject) => {
14073
14516
  // resolve early if taxes isn't enabled
14074
14517
  if (!taxesEnabled) {
@@ -14078,6 +14521,7 @@ const PaymentMethodContainerWithoutStripe = ({
14078
14521
  window.Pelcro.order.create({
14079
14522
  auth_token: window.Pelcro.user.read().auth_token,
14080
14523
  plan_id: plan.id,
14524
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
14081
14525
  coupon_code: state === null || state === void 0 ? void 0 : state.couponCode,
14082
14526
  address_id: selectedAddressId
14083
14527
  }, (error, res) => {
@@ -14140,7 +14584,7 @@ const PaymentMethodContainerWithoutStripe = ({
14140
14584
  if (stripeSource && type === "createPayment") {
14141
14585
  subscribe(stripeSource, state, dispatch);
14142
14586
  } else if (stripeSource && type === "orderCreate") {
14143
- purchase(stripeSource, state, dispatch);
14587
+ purchase(new StripeGateway(), stripeSource.id, state, dispatch);
14144
14588
  } else if (stripeSource && type === "invoicePayment") {
14145
14589
  payInvoice(new StripeGateway(), stripeSource.id, dispatch);
14146
14590
  }
@@ -14191,7 +14635,9 @@ const PaymentMethodContainerWithoutStripe = ({
14191
14635
 
14192
14636
  if ((source === null || source === void 0 ? void 0 : source.status) === "failed") {
14193
14637
  return handlePaymentError({
14194
- message: t("messages.cardAuthFailed")
14638
+ error: {
14639
+ message: t("messages.cardAuthFailed")
14640
+ }
14195
14641
  });
14196
14642
  }
14197
14643
 
@@ -14262,6 +14708,10 @@ const PaymentMethodContainerWithoutStripe = ({
14262
14708
  disableSubmit: true,
14263
14709
  isLoading: true
14264
14710
  }, (state, dispatch) => {
14711
+ if (getSiteCardProcessor() === "vantiv") {
14712
+ return submitUsingVantiv();
14713
+ }
14714
+
14265
14715
  if (selectedPaymentMethodId) {
14266
14716
  // pay with selected method (source) if exists already
14267
14717
  return handlePayment({
@@ -14274,10 +14724,6 @@ const PaymentMethodContainerWithoutStripe = ({
14274
14724
  return updatePaymentSource(state, dispatch);
14275
14725
  }
14276
14726
 
14277
- if (getSiteCardProcessor() === "vantiv") {
14278
- return submitVantivPayment();
14279
- }
14280
-
14281
14727
  submitPayment(state);
14282
14728
  });
14283
14729
 
@@ -14346,21 +14792,21 @@ const PaymentMethodContainerWithoutStripe = ({
14346
14792
  default:
14347
14793
  return state;
14348
14794
  }
14349
- }, initialState$f);
14795
+ }, initialState$g);
14350
14796
  return /*#__PURE__*/React__default['default'].createElement("div", {
14351
14797
  style: { ...style
14352
14798
  },
14353
14799
  className: `pelcro-container pelcro-payment-container ${className}`
14354
- }, /*#__PURE__*/React__default['default'].createElement(Provider$f, {
14800
+ }, /*#__PURE__*/React__default['default'].createElement(Provider$g, {
14355
14801
  value: {
14356
14802
  state,
14357
14803
  dispatch
14358
14804
  }
14359
14805
  }, children.length ? children.map((child, i) => /*#__PURE__*/React__default['default'].cloneElement(child, {
14360
- store: store$f,
14806
+ store: store$g,
14361
14807
  key: i
14362
14808
  })) : /*#__PURE__*/React__default['default'].cloneElement(children, {
14363
- store: store$f
14809
+ store: store$g
14364
14810
  })));
14365
14811
  };
14366
14812
 
@@ -14382,7 +14828,7 @@ const PaymentMethodContainer = props => {
14382
14828
  stripeAccount: window.Pelcro.site.read().account_id,
14383
14829
  locale: getPageOrDefaultLanguage()
14384
14830
  }, /*#__PURE__*/React__default['default'].createElement(es_11, null, /*#__PURE__*/React__default['default'].createElement(UnwrappedForm, Object.assign({
14385
- store: store$f
14831
+ store: store$g
14386
14832
  }, props))));
14387
14833
  }
14388
14834
 
@@ -14435,7 +14881,7 @@ const PelcroPaymentRequestButton = props => {
14435
14881
  currentPlan,
14436
14882
  updatedPrice
14437
14883
  }
14438
- } = React.useContext(store$f);
14884
+ } = React.useContext(store$g);
14439
14885
 
14440
14886
  const updatePaymentRequest = () => {
14441
14887
  // Make sure payment request is up to date, eg. user added a coupon code.
@@ -14511,7 +14957,7 @@ const DiscountedPrice = props => {
14511
14957
  taxAmount,
14512
14958
  percentOff
14513
14959
  }
14514
- } = React.useContext(store$f);
14960
+ } = React.useContext(store$g);
14515
14961
  const {
14516
14962
  order,
14517
14963
  plan
@@ -14561,7 +15007,7 @@ const SubmitPaymentMethod = ({
14561
15007
  isLoading,
14562
15008
  updatedPrice
14563
15009
  }
14564
- } = React.useContext(store$f);
15010
+ } = React.useContext(store$g);
14565
15011
  const planQuantity = (_plan$quantity = plan === null || plan === void 0 ? void 0 : plan.quantity) !== null && _plan$quantity !== void 0 ? _plan$quantity : 1;
14566
15012
  const price = updatedPrice !== null && updatedPrice !== void 0 ? updatedPrice : plan === null || plan === void 0 ? void 0 : plan.amount;
14567
15013
  const priceFormatted = getFormattedPriceByLocal(price * planQuantity, plan === null || plan === void 0 ? void 0 : plan.currency, getPageOrDefaultLanguage());
@@ -14611,7 +15057,7 @@ const ApplyCouponButton = ({
14611
15057
  disableCouponButton
14612
15058
  },
14613
15059
  dispatch
14614
- } = React.useContext(store$f);
15060
+ } = React.useContext(store$g);
14615
15061
  const {
14616
15062
  t
14617
15063
  } = useTranslation("checkoutForm");
@@ -14645,7 +15091,7 @@ const CouponCodeField = props => {
14645
15091
  couponCode,
14646
15092
  couponError
14647
15093
  }
14648
- } = React.useContext(store$f);
15094
+ } = React.useContext(store$g);
14649
15095
 
14650
15096
  const onCouponCodeChange = e => {
14651
15097
  dispatch({
@@ -14701,7 +15147,7 @@ const CouponCode = ({
14701
15147
  state: {
14702
15148
  enableCouponField
14703
15149
  }
14704
- } = React.useContext(store$f);
15150
+ } = React.useContext(store$g);
14705
15151
  const {
14706
15152
  t
14707
15153
  } = useTranslation("checkoutForm");
@@ -14958,7 +15404,7 @@ const PaypalSubscribeButton = props => {
14958
15404
  const {
14959
15405
  dispatch,
14960
15406
  state
14961
- } = React.useContext(store$f);
15407
+ } = React.useContext(store$g);
14962
15408
  const {
14963
15409
  product,
14964
15410
  plan,
@@ -14973,7 +15419,7 @@ const PaypalSubscribeButton = props => {
14973
15419
  const selectedAddress = getAddressById((_props$selectedAddres = props.selectedAddressId) !== null && _props$selectedAddres !== void 0 ? _props$selectedAddres : selectedAddressId); // initialize paypal client, then render paypal button.
14974
15420
 
14975
15421
  const initializePaypal = async () => {
14976
- var _props$buttonElementI, _props$product$addres, _props$product, _props$plan2;
15422
+ var _props$buttonElementI, _props$product$addres, _props$product;
14977
15423
 
14978
15424
  const paypalCheckoutInstance = new PaypalClient({
14979
15425
  buttonElementID: (_props$buttonElementI = props.buttonElementID) !== null && _props$buttonElementI !== void 0 ? _props$buttonElementI : "pelcro-paypal-button",
@@ -14983,12 +15429,33 @@ const PaypalSubscribeButton = props => {
14983
15429
  displayName: props.merchantDisplayName,
14984
15430
  locale: props.locale,
14985
15431
  billingAgreementDescription: props.billingDescription
14986
- }); // Await building paypal instance
15432
+ });
15433
+
15434
+ const getProduct = () => {
15435
+ if (invoice) {
15436
+ invoice.plan = null;
15437
+
15438
+ if (invoice.plan) {
15439
+ return invoice.plan;
15440
+ } else {
15441
+ // standalone invoices dont have a plan
15442
+ return {
15443
+ currency: invoice.currency,
15444
+ nickname: `invoice #${invoice.id}`
15445
+ };
15446
+ }
15447
+ } else if (props.plan) {
15448
+ return props.plan;
15449
+ } else {
15450
+ return plan;
15451
+ }
15452
+ }; // Await building paypal instance
15453
+
14987
15454
 
14988
15455
  await paypalCheckoutInstance.build(); // Create paypal payment
14989
15456
 
14990
15457
  paypalCheckoutInstance.createPayment({
14991
- product: invoice ? invoice.plan : (_props$plan2 = props.plan) !== null && _props$plan2 !== void 0 ? _props$plan2 : plan,
15458
+ product: getProduct(),
14992
15459
  amount: updatedPrice,
14993
15460
  address: invoice ? null : selectedAddress,
14994
15461
  onButtonClick: () => {
@@ -15070,7 +15537,7 @@ const SelectedPaymentMethod = () => {
15070
15537
  state: {
15071
15538
  isLoading
15072
15539
  }
15073
- } = React.useContext(store$f);
15540
+ } = React.useContext(store$g);
15074
15541
  const {
15075
15542
  switchView,
15076
15543
  selectedPaymentMethodId
@@ -15112,7 +15579,7 @@ const TaxAmount = () => {
15112
15579
  state: {
15113
15580
  taxAmount
15114
15581
  }
15115
- } = React.useContext(store$f);
15582
+ } = React.useContext(store$g);
15116
15583
  const {
15117
15584
  plan
15118
15585
  } = usePelcro();
@@ -15631,7 +16098,7 @@ class DefaultNewsLetter extends React.Component {
15631
16098
 
15632
16099
  const NewsLetter = withTranslation("newsletter")(DefaultNewsLetter);
15633
16100
 
15634
- const initialState$e = {
16101
+ const initialState$f = {
15635
16102
  didSubToNewslettersBefore: false,
15636
16103
  newsletters: [],
15637
16104
  isListLoading: true,
@@ -15641,10 +16108,10 @@ const initialState$e = {
15641
16108
  content: ""
15642
16109
  }
15643
16110
  };
15644
- const store$e = /*#__PURE__*/React.createContext(initialState$e);
16111
+ const store$f = /*#__PURE__*/React.createContext(initialState$f);
15645
16112
  const {
15646
- Provider: Provider$e
15647
- } = store$e;
16113
+ Provider: Provider$f
16114
+ } = store$f;
15648
16115
 
15649
16116
  const NewsletterUpdateContainer = ({
15650
16117
  style,
@@ -15757,7 +16224,7 @@ const NewsletterUpdateContainer = ({
15757
16224
  default:
15758
16225
  return state;
15759
16226
  }
15760
- }, initialState$e);
16227
+ }, initialState$f);
15761
16228
  React.useEffect(() => {
15762
16229
  const getUserNewsletters = () => {
15763
16230
  var _window$Pelcro$user$r3, _window$Pelcro$user$r4;
@@ -15801,7 +16268,7 @@ const NewsletterUpdateContainer = ({
15801
16268
  style: { ...style
15802
16269
  },
15803
16270
  className: `pelcro-container pelcro-newsletter-update-container ${className}`
15804
- }, /*#__PURE__*/React__default['default'].createElement(Provider$e, {
16271
+ }, /*#__PURE__*/React__default['default'].createElement(Provider$f, {
15805
16272
  value: {
15806
16273
  state,
15807
16274
  dispatch
@@ -15809,12 +16276,12 @@ const NewsletterUpdateContainer = ({
15809
16276
  }, children.length ? children.map((child, i) => {
15810
16277
  if (child) {
15811
16278
  return /*#__PURE__*/React__default['default'].cloneElement(child, {
15812
- store: store$e,
16279
+ store: store$f,
15813
16280
  key: i
15814
16281
  });
15815
16282
  }
15816
16283
  }) : /*#__PURE__*/React__default['default'].cloneElement(children, {
15817
- store: store$e
16284
+ store: store$f
15818
16285
  })));
15819
16286
  };
15820
16287
 
@@ -15829,7 +16296,7 @@ const NewsletterUpdateButton = ({
15829
16296
  isSubmitting,
15830
16297
  isListLoading
15831
16298
  }
15832
- } = React.useContext(store$e);
16299
+ } = React.useContext(store$f);
15833
16300
  const {
15834
16301
  t
15835
16302
  } = useTranslation("newsletter");
@@ -15859,7 +16326,7 @@ const NewsletterUpdateList = () => {
15859
16326
  newsletters,
15860
16327
  isListLoading
15861
16328
  }
15862
- } = React.useContext(store$e);
16329
+ } = React.useContext(store$f);
15863
16330
 
15864
16331
  if (isListLoading) {
15865
16332
  return /*#__PURE__*/React__default['default'].createElement(Loader, {
@@ -16063,8 +16530,9 @@ function SubscriptionCreateModal({
16063
16530
  SubscriptionCreateModal.viewId = "subscription-create";
16064
16531
 
16065
16532
  var _window$Pelcro$user$r, _window$Pelcro$user$r2, _window$Pelcro$user$r3, _window$Pelcro$user$r4, _window$Pelcro$user$r5;
16066
- const initialState$d = {
16533
+ const initialState$e = {
16067
16534
  email: (_window$Pelcro$user$r = window.Pelcro.user.read()) === null || _window$Pelcro$user$r === void 0 ? void 0 : _window$Pelcro$user$r.email,
16535
+ emailError: null,
16068
16536
  firstName: (_window$Pelcro$user$r2 = window.Pelcro.user.read()) === null || _window$Pelcro$user$r2 === void 0 ? void 0 : _window$Pelcro$user$r2.first_name,
16069
16537
  lastName: (_window$Pelcro$user$r3 = window.Pelcro.user.read()) === null || _window$Pelcro$user$r3 === void 0 ? void 0 : _window$Pelcro$user$r3.last_name,
16070
16538
  displayName: (_window$Pelcro$user$r4 = window.Pelcro.user.read()) === null || _window$Pelcro$user$r4 === void 0 ? void 0 : _window$Pelcro$user$r4.display_name,
@@ -16076,10 +16544,10 @@ const initialState$d = {
16076
16544
  content: ""
16077
16545
  }
16078
16546
  };
16079
- const store$d = /*#__PURE__*/React.createContext(initialState$d);
16547
+ const store$e = /*#__PURE__*/React.createContext(initialState$e);
16080
16548
  const {
16081
- Provider: Provider$d
16082
- } = store$d;
16549
+ Provider: Provider$e
16550
+ } = store$e;
16083
16551
 
16084
16552
  const UserUpdateContainer = ({
16085
16553
  style,
@@ -16099,20 +16567,23 @@ const UserUpdateContainer = ({
16099
16567
  }, []);
16100
16568
 
16101
16569
  const loadUserDataIntoFields = () => {
16102
- var _window$Pelcro$user$r6, _window$Pelcro$user$r7, _window$Pelcro$user$r8, _window$Pelcro$user$r9;
16570
+ var _window$Pelcro$user$r6, _window$Pelcro$user$r7, _window$Pelcro$user$r8, _window$Pelcro$user$r9, _window$Pelcro$user$r10;
16103
16571
 
16104
16572
  const fields = [{
16573
+ type: SET_EMAIL,
16574
+ payload: (_window$Pelcro$user$r6 = window.Pelcro.user.read()) === null || _window$Pelcro$user$r6 === void 0 ? void 0 : _window$Pelcro$user$r6.email
16575
+ }, {
16105
16576
  type: SET_FIRST_NAME,
16106
- payload: (_window$Pelcro$user$r6 = window.Pelcro.user.read()) === null || _window$Pelcro$user$r6 === void 0 ? void 0 : _window$Pelcro$user$r6.first_name
16577
+ payload: (_window$Pelcro$user$r7 = window.Pelcro.user.read()) === null || _window$Pelcro$user$r7 === void 0 ? void 0 : _window$Pelcro$user$r7.first_name
16107
16578
  }, {
16108
16579
  type: SET_LAST_NAME,
16109
- payload: (_window$Pelcro$user$r7 = window.Pelcro.user.read()) === null || _window$Pelcro$user$r7 === void 0 ? void 0 : _window$Pelcro$user$r7.last_name
16580
+ payload: (_window$Pelcro$user$r8 = window.Pelcro.user.read()) === null || _window$Pelcro$user$r8 === void 0 ? void 0 : _window$Pelcro$user$r8.last_name
16110
16581
  }, {
16111
16582
  type: SET_DISPLAY_NAME,
16112
- payload: (_window$Pelcro$user$r8 = window.Pelcro.user.read()) === null || _window$Pelcro$user$r8 === void 0 ? void 0 : _window$Pelcro$user$r8.display_name
16583
+ payload: (_window$Pelcro$user$r9 = window.Pelcro.user.read()) === null || _window$Pelcro$user$r9 === void 0 ? void 0 : _window$Pelcro$user$r9.display_name
16113
16584
  }, {
16114
16585
  type: SET_PHONE,
16115
- payload: (_window$Pelcro$user$r9 = window.Pelcro.user.read()) === null || _window$Pelcro$user$r9 === void 0 ? void 0 : _window$Pelcro$user$r9.phone
16586
+ payload: (_window$Pelcro$user$r10 = window.Pelcro.user.read()) === null || _window$Pelcro$user$r10 === void 0 ? void 0 : _window$Pelcro$user$r10.phone
16116
16587
  }];
16117
16588
  fields.filter(field => Boolean(field.payload)).forEach(field => {
16118
16589
  dispatch(field);
@@ -16120,6 +16591,7 @@ const UserUpdateContainer = ({
16120
16591
  };
16121
16592
 
16122
16593
  const handleUpdateUser = ({
16594
+ email,
16123
16595
  firstName,
16124
16596
  lastName,
16125
16597
  phone,
@@ -16128,6 +16600,7 @@ const UserUpdateContainer = ({
16128
16600
  }, dispatch) => {
16129
16601
  window.Pelcro.user.update({
16130
16602
  auth_token: window.Pelcro.user.read().auth_token,
16603
+ email: email,
16131
16604
  first_name: firstName,
16132
16605
  last_name: lastName,
16133
16606
  display_name: displayName,
@@ -16173,6 +16646,16 @@ const UserUpdateContainer = ({
16173
16646
  }
16174
16647
  });
16175
16648
 
16649
+ case SET_EMAIL:
16650
+ return lib_7({ ...state,
16651
+ email: action.payload
16652
+ });
16653
+
16654
+ case SET_EMAIL_ERROR:
16655
+ return lib_7({ ...state,
16656
+ emailError: action.payload
16657
+ });
16658
+
16176
16659
  case SET_FIRST_NAME:
16177
16660
  return lib_7({ ...state,
16178
16661
  firstName: action.payload
@@ -16211,28 +16694,85 @@ const UserUpdateContainer = ({
16211
16694
  default:
16212
16695
  return state;
16213
16696
  }
16214
- }, initialState$d);
16697
+ }, initialState$e);
16215
16698
  return /*#__PURE__*/React__default['default'].createElement("div", {
16216
16699
  style: { ...style
16217
16700
  },
16218
16701
  className: `pelcro-container pelcro-user-update-container ${className}`
16219
- }, /*#__PURE__*/React__default['default'].createElement(Provider$d, {
16702
+ }, /*#__PURE__*/React__default['default'].createElement(Provider$e, {
16220
16703
  value: {
16221
16704
  state,
16222
16705
  dispatch
16223
16706
  }
16224
16707
  }, children.length ? children.map((child, i) => /*#__PURE__*/React__default['default'].cloneElement(child, {
16225
- store: store$d,
16708
+ store: store$e,
16226
16709
  key: i
16227
16710
  })) : /*#__PURE__*/React__default['default'].cloneElement(children, {
16228
- store: store$d
16711
+ store: store$e
16229
16712
  })));
16230
16713
  };
16231
16714
 
16232
- const UserUpdateEmail = props => /*#__PURE__*/React__default['default'].createElement(Email, Object.assign({
16233
- disabled: true,
16234
- store: store$d
16235
- }, props));
16715
+ var _path$i;
16716
+
16717
+ function _extends$k() { _extends$k = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$k.apply(this, arguments); }
16718
+
16719
+ function SvgEdit(props) {
16720
+ return /*#__PURE__*/React__namespace.createElement("svg", _extends$k({
16721
+ className: "plc-w-6 plc-h-6",
16722
+ xmlns: "http://www.w3.org/2000/svg",
16723
+ viewBox: "0 0 20 20",
16724
+ fill: "currentColor"
16725
+ }, props), _path$i || (_path$i = /*#__PURE__*/React__namespace.createElement("path", {
16726
+ d: "M13.586 3.586a2 2 0 112.828 2.828l-.793.793-2.828-2.828.793-.793zm-2.207 2.207L3 14.172V17h2.828l8.38-8.379-2.83-2.828z"
16727
+ })));
16728
+ }
16729
+
16730
+ const UserUpdateEmail = props => {
16731
+ const {
16732
+ dispatch,
16733
+ state: {
16734
+ email,
16735
+ emailError
16736
+ }
16737
+ } = React.useContext(store$e);
16738
+ const [enableEmailEdit, setEnableEmailEdit] = React.useState(false);
16739
+ const {
16740
+ t
16741
+ } = useTranslation("userEdit");
16742
+
16743
+ const handleEnableEmailEdit = () => {
16744
+ if (enableEmailEdit) {
16745
+ dispatch({
16746
+ type: SET_EMAIL,
16747
+ payload: email
16748
+ });
16749
+ dispatch({
16750
+ type: SET_EMAIL_ERROR,
16751
+ payload: null
16752
+ });
16753
+ setEnableEmailEdit(false);
16754
+ } else {
16755
+ setEnableEmailEdit(true);
16756
+ }
16757
+ };
16758
+
16759
+ return /*#__PURE__*/React__default['default'].createElement("div", null, /*#__PURE__*/React__default['default'].createElement("div", {
16760
+ className: "plc-flex plc-items-start plc-relative"
16761
+ }, /*#__PURE__*/React__default['default'].createElement(Email, Object.assign({
16762
+ disabled: !enableEmailEdit,
16763
+ store: store$e,
16764
+ label: t("labels.email"),
16765
+ enableEmailEdit: enableEmailEdit
16766
+ }, props)), /*#__PURE__*/React__default['default'].createElement(Button, {
16767
+ variant: "icon",
16768
+ className: "plc-absolute plc-rounded-none plc-text-gray-500 plc-w-10 plc-h-10 plc-top-7 plc-right-0 hover:plc-text-gray-900 hover:plc-bg-transparent focus:plc-ring-0 focus:plc-shadow-none",
16769
+ icon: enableEmailEdit ? /*#__PURE__*/React__default['default'].createElement(SvgXIcon, {
16770
+ className: "plc-w-6"
16771
+ }) : /*#__PURE__*/React__default['default'].createElement(SvgEdit, null),
16772
+ id: "pelcro-user-update-picture-button",
16773
+ onClick: handleEnableEmailEdit
16774
+ })));
16775
+ };
16236
16776
 
16237
16777
  const UserUpdateButton = ({
16238
16778
  name,
@@ -16241,10 +16781,11 @@ const UserUpdateButton = ({
16241
16781
  }) => {
16242
16782
  const {
16243
16783
  state: {
16244
- buttonDisabled
16784
+ buttonDisabled,
16785
+ emailError
16245
16786
  },
16246
16787
  dispatch
16247
- } = React.useContext(store$d);
16788
+ } = React.useContext(store$e);
16248
16789
  const {
16249
16790
  t
16250
16791
  } = useTranslation("userEdit");
@@ -16255,17 +16796,17 @@ const UserUpdateButton = ({
16255
16796
  });
16256
16797
  onClick === null || onClick === void 0 ? void 0 : onClick();
16257
16798
  },
16258
- disabled: buttonDisabled,
16259
- isLoading: buttonDisabled
16799
+ disabled: buttonDisabled || emailError,
16800
+ isLoading: buttonDisabled && !emailError
16260
16801
  }, otherProps), name !== null && name !== void 0 ? name : t("labels.submit"));
16261
16802
  };
16262
16803
 
16263
16804
  const UserUpdateFirstName = props => /*#__PURE__*/React__default['default'].createElement(FirstName, Object.assign({
16264
- store: store$d
16805
+ store: store$e
16265
16806
  }, props));
16266
16807
 
16267
16808
  const UserUpdateLastName = props => /*#__PURE__*/React__default['default'].createElement(LastName, Object.assign({
16268
- store: store$d
16809
+ store: store$e
16269
16810
  }, props));
16270
16811
 
16271
16812
  function Phone({
@@ -16294,26 +16835,11 @@ function Phone({
16294
16835
  }
16295
16836
 
16296
16837
  const UserUpdatePhone = props => /*#__PURE__*/React__default['default'].createElement(Phone, Object.assign({
16297
- store: store$d
16838
+ store: store$e
16298
16839
  }, props));
16299
16840
 
16300
16841
  var userSolidIcon = "data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20class%3D%22plc-h-5%20plc-w-5%22%20viewBox%3D%220%200%2020%2020%22%20fill%3D%22white%22%3E%20%20%3Cpath%20transform%3D%22translate%280%2C2%29%22%20fill-rule%3D%22evenodd%22%20d%3D%22M10%209a3%203%200%20100-6%203%203%200%20000%206zm-7%209a7%207%200%201114%200H3z%22%20clip-rule%3D%22evenodd%22%20%2F%3E%3C%2Fsvg%3E";
16301
16842
 
16302
- var _path$i;
16303
-
16304
- function _extends$k() { _extends$k = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$k.apply(this, arguments); }
16305
-
16306
- function SvgEdit(props) {
16307
- return /*#__PURE__*/React__namespace.createElement("svg", _extends$k({
16308
- className: "plc-w-6 plc-h-6",
16309
- xmlns: "http://www.w3.org/2000/svg",
16310
- viewBox: "0 0 20 20",
16311
- fill: "currentColor"
16312
- }, props), _path$i || (_path$i = /*#__PURE__*/React__namespace.createElement("path", {
16313
- d: "M13.586 3.586a2 2 0 112.828 2.828l-.793.793-2.828-2.828.793-.793zm-2.207 2.207L3 14.172V17h2.828l8.38-8.379-2.83-2.828z"
16314
- })));
16315
- }
16316
-
16317
16843
  const UserUpdateProfilePic = ({
16318
16844
  onClick,
16319
16845
  ...otherProps
@@ -16332,7 +16858,7 @@ const UserUpdateProfilePic = ({
16332
16858
  onClick: onClick
16333
16859
  }, otherProps)), /*#__PURE__*/React__default['default'].createElement(Button, {
16334
16860
  variant: "icon",
16335
- className: "plc-absolute plc-bg-gray-500 plc-text-white plc-w-10 plc-h-10 plc-top-24 plc-right-2 hover:plc-bg-gray-600",
16861
+ className: "plc-absolute plc-bg-gray-500 plc-text-white plc-w-10 plc-h-10 plc-top-24 plc-right-2 hover:plc-bg-gray-600 hover:plc-text-white",
16336
16862
  icon: /*#__PURE__*/React__default['default'].createElement(SvgEdit, null),
16337
16863
  id: "pelcro-user-update-picture-button",
16338
16864
  onClick: onClick
@@ -16354,11 +16880,7 @@ const UserUpdateView = props => {
16354
16880
  className: "plc-mt-2 pelcro-form"
16355
16881
  }, /*#__PURE__*/React__default['default'].createElement(UserUpdateContainer, props, /*#__PURE__*/React__default['default'].createElement(AlertWithContext, null), /*#__PURE__*/React__default['default'].createElement(UserUpdateProfilePic, {
16356
16882
  onClick: props.onPictureClick
16357
- }), /*#__PURE__*/React__default['default'].createElement("div", {
16358
- className: "plc-flex plc-items-start"
16359
- }, /*#__PURE__*/React__default['default'].createElement(UserUpdateEmail, {
16360
- label: t("labels.email")
16361
- })), /*#__PURE__*/React__default['default'].createElement("div", {
16883
+ }), /*#__PURE__*/React__default['default'].createElement(UserUpdateEmail, null), /*#__PURE__*/React__default['default'].createElement("div", {
16362
16884
  className: "plc-flex plc-items-start"
16363
16885
  }, /*#__PURE__*/React__default['default'].createElement(UserUpdateFirstName, {
16364
16886
  autoComplete: "first-name",
@@ -16441,16 +16963,16 @@ function DisplayName({
16441
16963
  }
16442
16964
 
16443
16965
  const UserUpdateDisplayName = props => /*#__PURE__*/React__default['default'].createElement(DisplayName, Object.assign({
16444
- store: store$d
16966
+ store: store$e
16445
16967
  }, props));
16446
16968
 
16447
16969
  const UserUpdateTextInput = props => {
16448
16970
  return /*#__PURE__*/React__default['default'].createElement(TextInput, Object.assign({}, props, {
16449
- store: store$d
16971
+ store: store$e
16450
16972
  }));
16451
16973
  };
16452
16974
 
16453
- const initialState$c = {
16975
+ const initialState$d = {
16454
16976
  isSubmitting: false,
16455
16977
  firstName: "",
16456
16978
  firstNameError: "",
@@ -16475,10 +16997,10 @@ const initialState$c = {
16475
16997
  content: ""
16476
16998
  }
16477
16999
  };
16478
- const store$c = /*#__PURE__*/React.createContext(initialState$c);
17000
+ const store$d = /*#__PURE__*/React.createContext(initialState$d);
16479
17001
  const {
16480
- Provider: Provider$c
16481
- } = store$c;
17002
+ Provider: Provider$d
17003
+ } = store$d;
16482
17004
 
16483
17005
  const getNewlyCreatedAddress = addresses => addresses[addresses.length - 1];
16484
17006
 
@@ -16685,7 +17207,7 @@ const AddressCreateContainer = ({
16685
17207
  default:
16686
17208
  return state;
16687
17209
  }
16688
- }, initialState$c);
17210
+ }, initialState$d);
16689
17211
  React.useEffect(() => {
16690
17212
  const getStates = () => {
16691
17213
  dispatch({
@@ -16717,16 +17239,16 @@ const AddressCreateContainer = ({
16717
17239
  style: { ...style
16718
17240
  },
16719
17241
  className: `pelcro-container pelcro-address-create-container ${className}`
16720
- }, /*#__PURE__*/React__default['default'].createElement(Provider$c, {
17242
+ }, /*#__PURE__*/React__default['default'].createElement(Provider$d, {
16721
17243
  value: {
16722
17244
  state,
16723
17245
  dispatch
16724
17246
  }
16725
17247
  }, children.length ? children.map((child, i) => /*#__PURE__*/React__default['default'].cloneElement(child, {
16726
- store: store$c,
17248
+ store: store$d,
16727
17249
  key: i
16728
17250
  })) : /*#__PURE__*/React__default['default'].cloneElement(children, {
16729
- store: store$c
17251
+ store: store$d
16730
17252
  })));
16731
17253
  };
16732
17254
 
@@ -16737,7 +17259,7 @@ function AddressCreateFirstName(props) {
16737
17259
  firstName,
16738
17260
  firstNameError
16739
17261
  }
16740
- } = React.useContext(store$c);
17262
+ } = React.useContext(store$d);
16741
17263
 
16742
17264
  const handleBlur = () => {
16743
17265
  return dispatch({
@@ -16780,7 +17302,7 @@ function AddressCreateLastName(props) {
16780
17302
  lastName,
16781
17303
  lastNameError
16782
17304
  }
16783
- } = React.useContext(store$c);
17305
+ } = React.useContext(store$d);
16784
17306
 
16785
17307
  const handleBlur = () => {
16786
17308
  return dispatch({
@@ -16823,7 +17345,7 @@ function AddressCreateLine1(props) {
16823
17345
  line1,
16824
17346
  line1Error
16825
17347
  }
16826
- } = React.useContext(store$c);
17348
+ } = React.useContext(store$d);
16827
17349
 
16828
17350
  const handleBlur = () => {
16829
17351
  return dispatch({
@@ -16866,7 +17388,7 @@ function AddressCreateCity(props) {
16866
17388
  city,
16867
17389
  cityError
16868
17390
  }
16869
- } = React.useContext(store$c);
17391
+ } = React.useContext(store$d);
16870
17392
 
16871
17393
  const handleBlur = () => {
16872
17394
  return dispatch({
@@ -16909,7 +17431,7 @@ function AddressCreatePostalCode(props) {
16909
17431
  postalCode,
16910
17432
  postalCodeError
16911
17433
  }
16912
- } = React.useContext(store$c);
17434
+ } = React.useContext(store$d);
16913
17435
 
16914
17436
  const handleBlur = () => {
16915
17437
  return dispatch({
@@ -16955,7 +17477,7 @@ const AddressCreateSubmit = ({
16955
17477
  state: {
16956
17478
  isSubmitting
16957
17479
  }
16958
- } = React.useContext(store$c);
17480
+ } = React.useContext(store$d);
16959
17481
  const {
16960
17482
  t
16961
17483
  } = useTranslation("address");
@@ -17066,7 +17588,7 @@ function CountrySelect({
17066
17588
  }
17067
17589
 
17068
17590
  const AddressCreateCountrySelect = props => /*#__PURE__*/React__default['default'].createElement(CountrySelect, Object.assign({
17069
- store: store$c
17591
+ store: store$d
17070
17592
  }, props));
17071
17593
 
17072
17594
  function StateSelect({
@@ -17154,7 +17676,7 @@ function StateSelect({
17154
17676
  }
17155
17677
 
17156
17678
  const AddressCreateStateSelect = props => /*#__PURE__*/React__default['default'].createElement(StateSelect, Object.assign({
17157
- store: store$c
17679
+ store: store$d
17158
17680
  }, props));
17159
17681
 
17160
17682
  const AddressCreateView = props => {
@@ -17259,18 +17781,18 @@ AddressCreateModal.viewId = "address-create";
17259
17781
 
17260
17782
  const AddressCreateTextInput = props => {
17261
17783
  return /*#__PURE__*/React__default['default'].createElement(TextInput, Object.assign({}, props, {
17262
- store: store$c
17784
+ store: store$d
17263
17785
  }));
17264
17786
  };
17265
17787
 
17266
17788
  const AddressCreateLine2 = props => {
17267
17789
  return /*#__PURE__*/React__default['default'].createElement(TextInput, Object.assign({
17268
17790
  fieldName: "line2",
17269
- store: store$c
17791
+ store: store$d
17270
17792
  }, props));
17271
17793
  };
17272
17794
 
17273
- const initialState$b = {
17795
+ const initialState$c = {
17274
17796
  isSubmitting: false,
17275
17797
  firstName: "",
17276
17798
  firstNameError: "",
@@ -17295,10 +17817,10 @@ const initialState$b = {
17295
17817
  content: ""
17296
17818
  }
17297
17819
  };
17298
- const store$b = /*#__PURE__*/React.createContext(initialState$b);
17820
+ const store$c = /*#__PURE__*/React.createContext(initialState$c);
17299
17821
  const {
17300
- Provider: Provider$b
17301
- } = store$b;
17822
+ Provider: Provider$c
17823
+ } = store$c;
17302
17824
 
17303
17825
  const AddressUpdateContainer = ({
17304
17826
  style,
@@ -17350,7 +17872,7 @@ const AddressUpdateContainer = ({
17350
17872
  const thisAddress = addresses[address];
17351
17873
 
17352
17874
  if (+thisAddress.id === +addressId) {
17353
- const newState = { ...initialState$b,
17875
+ const newState = { ...initialState$c,
17354
17876
  firstName: thisAddress.first_name,
17355
17877
  lastName: thisAddress.last_name,
17356
17878
  line1: thisAddress.line1,
@@ -17483,7 +18005,7 @@ const AddressUpdateContainer = ({
17483
18005
  default:
17484
18006
  return state;
17485
18007
  }
17486
- }, initialState$b);
18008
+ }, initialState$c);
17487
18009
  React.useEffect(() => {
17488
18010
  const getStates = () => {
17489
18011
  dispatch({
@@ -17515,21 +18037,21 @@ const AddressUpdateContainer = ({
17515
18037
  style: { ...style
17516
18038
  },
17517
18039
  className: `pelcro-container pelcro-address-update-container ${className}`
17518
- }, /*#__PURE__*/React__default['default'].createElement(Provider$b, {
18040
+ }, /*#__PURE__*/React__default['default'].createElement(Provider$c, {
17519
18041
  value: {
17520
18042
  state,
17521
18043
  dispatch
17522
18044
  }
17523
18045
  }, children.length ? children.map((child, i) => /*#__PURE__*/React__default['default'].cloneElement(child, {
17524
- store: store$b,
18046
+ store: store$c,
17525
18047
  key: i
17526
18048
  })) : /*#__PURE__*/React__default['default'].cloneElement(children, {
17527
- store: store$b
18049
+ store: store$c
17528
18050
  })));
17529
18051
  };
17530
18052
 
17531
18053
  const AddressUpdateCountrySelect = props => /*#__PURE__*/React__default['default'].createElement(CountrySelect, Object.assign({
17532
- store: store$b
18054
+ store: store$c
17533
18055
  }, props));
17534
18056
 
17535
18057
  function AddressUpdateFirstName(props) {
@@ -17539,7 +18061,7 @@ function AddressUpdateFirstName(props) {
17539
18061
  firstName,
17540
18062
  firstNameError
17541
18063
  }
17542
- } = React.useContext(store$b);
18064
+ } = React.useContext(store$c);
17543
18065
 
17544
18066
  const handleBlur = () => {
17545
18067
  return dispatch({
@@ -17582,7 +18104,7 @@ function AddressUpdateLastName(props) {
17582
18104
  lastName,
17583
18105
  lastNameError
17584
18106
  }
17585
- } = React.useContext(store$b);
18107
+ } = React.useContext(store$c);
17586
18108
 
17587
18109
  const handleBlur = () => {
17588
18110
  return dispatch({
@@ -17625,7 +18147,7 @@ function AddressUpdateLine1(props) {
17625
18147
  line1,
17626
18148
  line1Error
17627
18149
  }
17628
- } = React.useContext(store$b);
18150
+ } = React.useContext(store$c);
17629
18151
 
17630
18152
  const handleBlur = () => {
17631
18153
  return dispatch({
@@ -17665,7 +18187,7 @@ const AddressUpdateLine2 = props => {
17665
18187
  return /*#__PURE__*/React__default['default'].createElement(TextInput, Object.assign({
17666
18188
  fieldName: "line2"
17667
18189
  }, props, {
17668
- store: store$b
18190
+ store: store$c
17669
18191
  }));
17670
18192
  };
17671
18193
 
@@ -17676,7 +18198,7 @@ function AddressUpdateCity(props) {
17676
18198
  city,
17677
18199
  cityError
17678
18200
  }
17679
- } = React.useContext(store$b);
18201
+ } = React.useContext(store$c);
17680
18202
 
17681
18203
  const handleBlur = () => {
17682
18204
  return dispatch({
@@ -17719,7 +18241,7 @@ function AddressUpdatePostalCode(props) {
17719
18241
  postalCode,
17720
18242
  postalCodeError
17721
18243
  }
17722
- } = React.useContext(store$b);
18244
+ } = React.useContext(store$c);
17723
18245
 
17724
18246
  const handleBlur = () => {
17725
18247
  return dispatch({
@@ -17765,7 +18287,7 @@ const AddressUpdateSubmit = ({
17765
18287
  state: {
17766
18288
  isSubmitting
17767
18289
  }
17768
- } = React.useContext(store$b);
18290
+ } = React.useContext(store$c);
17769
18291
  const {
17770
18292
  t
17771
18293
  } = useTranslation("address");
@@ -17781,7 +18303,7 @@ const AddressUpdateSubmit = ({
17781
18303
  };
17782
18304
 
17783
18305
  const AddressUpdateStateSelect = props => /*#__PURE__*/React__default['default'].createElement(StateSelect, Object.assign({
17784
- store: store$b
18306
+ store: store$c
17785
18307
  }, props));
17786
18308
 
17787
18309
  const AddressUpdateView = props => {
@@ -17864,7 +18386,7 @@ AddressUpdateModal.viewId = "address-edit";
17864
18386
 
17865
18387
  const AddressUpdateTextInput = props => {
17866
18388
  return /*#__PURE__*/React__default['default'].createElement(TextInput, Object.assign({}, props, {
17867
- store: store$b
18389
+ store: store$c
17868
18390
  }));
17869
18391
  };
17870
18392
 
@@ -17947,7 +18469,7 @@ const PaymentMethodUpdateModal = props => {
17947
18469
  };
17948
18470
  PaymentMethodUpdateModal.viewId = "payment-method-update";
17949
18471
 
17950
- const initialState$a = {
18472
+ const initialState$b = {
17951
18473
  email: "",
17952
18474
  password: "",
17953
18475
  passwordError: null,
@@ -17960,10 +18482,10 @@ const initialState$a = {
17960
18482
  content: ""
17961
18483
  }
17962
18484
  };
17963
- const store$a = /*#__PURE__*/React.createContext(initialState$a);
18485
+ const store$b = /*#__PURE__*/React.createContext(initialState$b);
17964
18486
  const {
17965
- Provider: Provider$a
17966
- } = store$a;
18487
+ Provider: Provider$b
18488
+ } = store$b;
17967
18489
 
17968
18490
  const PasswordResetContainer = ({
17969
18491
  style,
@@ -18020,7 +18542,7 @@ const PasswordResetContainer = ({
18020
18542
  type: SET_EMAIL,
18021
18543
  payload: window.Pelcro.helpers.getURLParameter("email")
18022
18544
  });
18023
- initialState$a.email = window.Pelcro.helpers.getURLParameter("email");
18545
+ initialState$b.email = window.Pelcro.helpers.getURLParameter("email");
18024
18546
  dispatch({
18025
18547
  type: SET_TOKEN,
18026
18548
  payload: window.Pelcro.helpers.getURLParameter("token")
@@ -18080,26 +18602,26 @@ const PasswordResetContainer = ({
18080
18602
  default:
18081
18603
  return state;
18082
18604
  }
18083
- }, initialState$a);
18605
+ }, initialState$b);
18084
18606
  return /*#__PURE__*/React__default['default'].createElement("div", {
18085
18607
  style: { ...style
18086
18608
  },
18087
18609
  className: `pelcro-container pelcro-password-reset-container ${className}`
18088
- }, /*#__PURE__*/React__default['default'].createElement(Provider$a, {
18610
+ }, /*#__PURE__*/React__default['default'].createElement(Provider$b, {
18089
18611
  value: {
18090
18612
  state,
18091
18613
  dispatch
18092
18614
  }
18093
18615
  }, children.length ? children.map((child, i) => /*#__PURE__*/React__default['default'].cloneElement(child, {
18094
- store: store$a,
18616
+ store: store$b,
18095
18617
  key: i
18096
18618
  })) : /*#__PURE__*/React__default['default'].cloneElement(children, {
18097
- store: store$a
18619
+ store: store$b
18098
18620
  })));
18099
18621
  };
18100
18622
 
18101
18623
  const PasswordResetPassword = props => /*#__PURE__*/React__default['default'].createElement(Password, Object.assign({
18102
- store: store$a
18624
+ store: store$b
18103
18625
  }, props));
18104
18626
 
18105
18627
  const PasswordResetButton = ({
@@ -18112,7 +18634,7 @@ const PasswordResetButton = ({
18112
18634
  buttonDisabled
18113
18635
  },
18114
18636
  dispatch
18115
- } = React.useContext(store$a);
18637
+ } = React.useContext(store$b);
18116
18638
  const {
18117
18639
  t
18118
18640
  } = useTranslation("passwordReset");
@@ -18129,14 +18651,14 @@ const PasswordResetButton = ({
18129
18651
  };
18130
18652
 
18131
18653
  const PasswordResetEmail = props => /*#__PURE__*/React__default['default'].createElement(Email, Object.assign({
18132
- store: store$a
18654
+ store: store$b
18133
18655
  }, props, {
18134
18656
  value: window.Pelcro.helpers.getURLParameter("email"),
18135
18657
  disabled: true
18136
18658
  }));
18137
18659
 
18138
18660
  const PasswordResetConfirmPassword = props => /*#__PURE__*/React__default['default'].createElement(ConfirmPassword, Object.assign({
18139
- store: store$a
18661
+ store: store$b
18140
18662
  }, props));
18141
18663
 
18142
18664
  const PasswordResetView = props => {
@@ -18188,7 +18710,7 @@ const PasswordResetModal = ({
18188
18710
  };
18189
18711
  PasswordResetModal.viewId = "password-reset";
18190
18712
 
18191
- const initialState$9 = {
18713
+ const initialState$a = {
18192
18714
  email: "",
18193
18715
  emailError: null,
18194
18716
  buttonDisabled: false,
@@ -18197,10 +18719,10 @@ const initialState$9 = {
18197
18719
  content: ""
18198
18720
  }
18199
18721
  };
18200
- const store$9 = /*#__PURE__*/React.createContext(initialState$9);
18722
+ const store$a = /*#__PURE__*/React.createContext(initialState$a);
18201
18723
  const {
18202
- Provider: Provider$9
18203
- } = store$9;
18724
+ Provider: Provider$a
18725
+ } = store$a;
18204
18726
 
18205
18727
  const PasswordForgotContainer = ({
18206
18728
  style,
@@ -18278,21 +18800,21 @@ const PasswordForgotContainer = ({
18278
18800
  default:
18279
18801
  return state;
18280
18802
  }
18281
- }, initialState$9);
18803
+ }, initialState$a);
18282
18804
  return /*#__PURE__*/React__default['default'].createElement("div", {
18283
18805
  style: { ...style
18284
18806
  },
18285
18807
  className: `pelcro-container pelcro-password-forgot-container ${className}`
18286
- }, /*#__PURE__*/React__default['default'].createElement(Provider$9, {
18808
+ }, /*#__PURE__*/React__default['default'].createElement(Provider$a, {
18287
18809
  value: {
18288
18810
  state,
18289
18811
  dispatch
18290
18812
  }
18291
18813
  }, children.length ? children.map((child, i) => /*#__PURE__*/React__default['default'].cloneElement(child, {
18292
- store: store$9,
18814
+ store: store$a,
18293
18815
  key: i
18294
18816
  })) : /*#__PURE__*/React__default['default'].cloneElement(children, {
18295
- store: store$9
18817
+ store: store$a
18296
18818
  })));
18297
18819
  };
18298
18820
 
@@ -18308,7 +18830,7 @@ const PasswordForgotButton = ({
18308
18830
  emailError
18309
18831
  },
18310
18832
  dispatch
18311
- } = React.useContext(store$9);
18833
+ } = React.useContext(store$a);
18312
18834
  const {
18313
18835
  t
18314
18836
  } = useTranslation("passwordForgot");
@@ -18329,7 +18851,7 @@ const PasswordForgotButton = ({
18329
18851
  };
18330
18852
 
18331
18853
  const PasswordForgotEmail = props => /*#__PURE__*/React__default['default'].createElement(Email, Object.assign({
18332
- store: store$9
18854
+ store: store$a
18333
18855
  }, props));
18334
18856
 
18335
18857
  const PasswordForgotView = props => {
@@ -18379,7 +18901,7 @@ const PasswordForgotModal = ({
18379
18901
  };
18380
18902
  PasswordForgotModal.viewId = "password-forgot";
18381
18903
 
18382
- const initialState$8 = {
18904
+ const initialState$9 = {
18383
18905
  currentPassword: "",
18384
18906
  newPassword: "",
18385
18907
  confirmNewPassword: "",
@@ -18393,10 +18915,10 @@ const initialState$8 = {
18393
18915
  content: ""
18394
18916
  }
18395
18917
  };
18396
- const store$8 = /*#__PURE__*/React.createContext(initialState$8);
18918
+ const store$9 = /*#__PURE__*/React.createContext(initialState$9);
18397
18919
  const {
18398
- Provider: Provider$8
18399
- } = store$8;
18920
+ Provider: Provider$9
18921
+ } = store$9;
18400
18922
  const PasswordChangeContainer = ({
18401
18923
  style,
18402
18924
  className = "",
@@ -18548,21 +19070,21 @@ const PasswordChangeContainer = ({
18548
19070
  default:
18549
19071
  return state;
18550
19072
  }
18551
- }, initialState$8);
19073
+ }, initialState$9);
18552
19074
  return /*#__PURE__*/React__default['default'].createElement("div", {
18553
19075
  style: { ...style
18554
19076
  },
18555
19077
  className: `pelcro-container pelcro-password-change-container ${className}`
18556
- }, /*#__PURE__*/React__default['default'].createElement(Provider$8, {
19078
+ }, /*#__PURE__*/React__default['default'].createElement(Provider$9, {
18557
19079
  value: {
18558
19080
  state,
18559
19081
  dispatch
18560
19082
  }
18561
19083
  }, children.length ? children.map((child, i) => /*#__PURE__*/React__default['default'].cloneElement(child, {
18562
- store: store$8,
19084
+ store: store$9,
18563
19085
  key: i
18564
19086
  })) : /*#__PURE__*/React__default['default'].cloneElement(children, {
18565
- store: store$8
19087
+ store: store$9
18566
19088
  })));
18567
19089
  };
18568
19090
 
@@ -18573,7 +19095,7 @@ function PasswordChangeCurrentPassword(props) {
18573
19095
  currentPassword,
18574
19096
  currentPasswordError
18575
19097
  }
18576
- } = React.useContext(store$8);
19098
+ } = React.useContext(store$9);
18577
19099
  const handleBlur = React.useCallback(() => {
18578
19100
  return dispatch({
18579
19101
  type: VALIDATE_PASSWORD
@@ -18607,7 +19129,7 @@ function PasswordChangeNewPassword(props) {
18607
19129
  newPassword,
18608
19130
  newPasswordError
18609
19131
  }
18610
- } = React.useContext(store$8);
19132
+ } = React.useContext(store$9);
18611
19133
  const handleBlur = React.useCallback(() => {
18612
19134
  return dispatch({
18613
19135
  type: VALIDATE_NEW_PASSWORD
@@ -18641,7 +19163,7 @@ function PasswordChangeConfirmNewPassword(props) {
18641
19163
  confirmNewPassword,
18642
19164
  confirmNewPasswordError
18643
19165
  }
18644
- } = React.useContext(store$8);
19166
+ } = React.useContext(store$9);
18645
19167
  const handleBlur = React.useCallback(() => {
18646
19168
  return dispatch({
18647
19169
  type: VALIDATE_CONFIRM_NEW_PASSWORD
@@ -18682,7 +19204,7 @@ const PasswordChangeButton = ({
18682
19204
  confirmNewPasswordError
18683
19205
  },
18684
19206
  dispatch
18685
- } = React.useContext(store$8);
19207
+ } = React.useContext(store$9);
18686
19208
  const {
18687
19209
  t
18688
19210
  } = useTranslation("passwordChange");
@@ -18748,17 +19270,17 @@ const PasswordChangeModal = ({
18748
19270
  };
18749
19271
  PasswordChangeModal.viewId = "password-change";
18750
19272
 
18751
- const initialState$7 = {
19273
+ const initialState$8 = {
18752
19274
  buttonDisabled: false,
18753
19275
  alert: {
18754
19276
  type: "error",
18755
19277
  content: ""
18756
19278
  }
18757
19279
  };
18758
- const store$7 = /*#__PURE__*/React.createContext(initialState$7);
19280
+ const store$8 = /*#__PURE__*/React.createContext(initialState$8);
18759
19281
  const {
18760
- Provider: Provider$7
18761
- } = store$7;
19282
+ Provider: Provider$8
19283
+ } = store$8;
18762
19284
 
18763
19285
  const CartContainer = ({
18764
19286
  style,
@@ -18849,21 +19371,21 @@ const CartContainer = ({
18849
19371
  default:
18850
19372
  return state;
18851
19373
  }
18852
- }, initialState$7);
19374
+ }, initialState$8);
18853
19375
  return /*#__PURE__*/React__default['default'].createElement("div", {
18854
19376
  style: { ...style
18855
19377
  },
18856
19378
  className: `pelcro-container pelcro-cart-container ${className}`
18857
- }, /*#__PURE__*/React__default['default'].createElement(Provider$7, {
19379
+ }, /*#__PURE__*/React__default['default'].createElement(Provider$8, {
18858
19380
  value: {
18859
19381
  state,
18860
19382
  dispatch
18861
19383
  }
18862
19384
  }, children.length ? children.map((child, i) => /*#__PURE__*/React__default['default'].cloneElement(child, {
18863
- store: store$7,
19385
+ store: store$8,
18864
19386
  key: i
18865
19387
  })) : /*#__PURE__*/React__default['default'].cloneElement(children, {
18866
- store: store$7
19388
+ store: store$8
18867
19389
  })));
18868
19390
  };
18869
19391
 
@@ -18900,7 +19422,7 @@ const CartSubmit = ({
18900
19422
  buttonDisabled
18901
19423
  },
18902
19424
  dispatch
18903
- } = React.useContext(store$7);
19425
+ } = React.useContext(store$8);
18904
19426
  const {
18905
19427
  t
18906
19428
  } = useTranslation("cart");
@@ -18931,7 +19453,7 @@ const CartTotalPrice = () => {
18931
19453
  state: {
18932
19454
  alert
18933
19455
  }
18934
- } = React.useContext(store$7);
19456
+ } = React.useContext(store$8);
18935
19457
  const {
18936
19458
  cartItems
18937
19459
  } = usePelcro();
@@ -19244,7 +19766,7 @@ const OrderConfirmModal = props => {
19244
19766
  };
19245
19767
  OrderConfirmModal.viewId = "order-confirm";
19246
19768
 
19247
- const initialState$6 = {
19769
+ const initialState$7 = {
19248
19770
  email: "",
19249
19771
  firstName: "",
19250
19772
  lastName: "",
@@ -19256,10 +19778,10 @@ const initialState$6 = {
19256
19778
  content: ""
19257
19779
  }
19258
19780
  };
19259
- const store$6 = /*#__PURE__*/React.createContext(initialState$6);
19781
+ const store$7 = /*#__PURE__*/React.createContext(initialState$7);
19260
19782
  const {
19261
- Provider: Provider$6
19262
- } = store$6;
19783
+ Provider: Provider$7
19784
+ } = store$7;
19263
19785
 
19264
19786
  const GiftCreateContainer = ({
19265
19787
  style,
@@ -19363,21 +19885,21 @@ const GiftCreateContainer = ({
19363
19885
  default:
19364
19886
  return state;
19365
19887
  }
19366
- }, initialState$6);
19888
+ }, initialState$7);
19367
19889
  return /*#__PURE__*/React__default['default'].createElement("div", {
19368
19890
  style: { ...style
19369
19891
  },
19370
19892
  className: `pelcro-container pelcro-gift-create-container ${className}`
19371
- }, /*#__PURE__*/React__default['default'].createElement(Provider$6, {
19893
+ }, /*#__PURE__*/React__default['default'].createElement(Provider$7, {
19372
19894
  value: {
19373
19895
  state,
19374
19896
  dispatch
19375
19897
  }
19376
19898
  }, children.length ? children.map((child, i) => /*#__PURE__*/React__default['default'].cloneElement(child, {
19377
- store: store$6,
19899
+ store: store$7,
19378
19900
  key: i
19379
19901
  })) : /*#__PURE__*/React__default['default'].cloneElement(children, {
19380
- store: store$6
19902
+ store: store$7
19381
19903
  })));
19382
19904
  };
19383
19905
 
@@ -19391,7 +19913,7 @@ const GiftCreateSubmitButton = ({
19391
19913
  state: {
19392
19914
  disableSubmit
19393
19915
  }
19394
- } = React.useContext(store$6);
19916
+ } = React.useContext(store$7);
19395
19917
  const {
19396
19918
  t
19397
19919
  } = useTranslation("register");
@@ -19408,15 +19930,15 @@ const GiftCreateSubmitButton = ({
19408
19930
 
19409
19931
  const GiftCreateEmail = props => /*#__PURE__*/React__default['default'].createElement(Email, Object.assign({
19410
19932
  initWithUserEmail: false,
19411
- store: store$6
19933
+ store: store$7
19412
19934
  }, props));
19413
19935
 
19414
19936
  const GiftCreateFirstName = props => /*#__PURE__*/React__default['default'].createElement(FirstName, Object.assign({
19415
- store: store$6
19937
+ store: store$7
19416
19938
  }, props));
19417
19939
 
19418
19940
  const GiftCreateLastName = props => /*#__PURE__*/React__default['default'].createElement(LastName, Object.assign({
19419
- store: store$6
19941
+ store: store$7
19420
19942
  }, props));
19421
19943
 
19422
19944
  var _path$h;
@@ -19501,7 +20023,7 @@ const GiftCreateStartDate = props => {
19501
20023
  const {
19502
20024
  dispatch,
19503
20025
  state
19504
- } = React.useContext(store$6);
20026
+ } = React.useContext(store$7);
19505
20027
 
19506
20028
  const handleInputChange = value => {
19507
20029
  dispatch({
@@ -19574,7 +20096,7 @@ function GiftCreateMessage(props) {
19574
20096
  const {
19575
20097
  dispatch,
19576
20098
  state
19577
- } = React.useContext(store$6);
20099
+ } = React.useContext(store$7);
19578
20100
  const MAX_CHARS_COUNT = 200;
19579
20101
  const remainingCharsCount = (_ref = MAX_CHARS_COUNT - ((_state$giftMessage = state.giftMessage) === null || _state$giftMessage === void 0 ? void 0 : _state$giftMessage.length)) !== null && _ref !== void 0 ? _ref : 0;
19580
20102
 
@@ -19698,7 +20220,7 @@ const GiftCreateModal = ({
19698
20220
  };
19699
20221
  GiftCreateModal.viewId = "gift-create";
19700
20222
 
19701
- const initialState$5 = {
20223
+ const initialState$6 = {
19702
20224
  giftCode: "",
19703
20225
  buttonDisabled: true,
19704
20226
  alert: {
@@ -19706,10 +20228,10 @@ const initialState$5 = {
19706
20228
  content: ""
19707
20229
  }
19708
20230
  };
19709
- const store$5 = /*#__PURE__*/React.createContext(initialState$5);
20231
+ const store$6 = /*#__PURE__*/React.createContext(initialState$6);
19710
20232
  const {
19711
- Provider: Provider$5
19712
- } = store$5;
20233
+ Provider: Provider$6
20234
+ } = store$6;
19713
20235
 
19714
20236
  const GiftRedeemContainer = ({
19715
20237
  style,
@@ -19774,21 +20296,21 @@ const GiftRedeemContainer = ({
19774
20296
  default:
19775
20297
  return state;
19776
20298
  }
19777
- }, initialState$5);
20299
+ }, initialState$6);
19778
20300
  return /*#__PURE__*/React__default['default'].createElement("div", {
19779
20301
  style: { ...style
19780
20302
  },
19781
20303
  className: `pelcro-container pelcro-gift-redeem-container ${className}`
19782
- }, /*#__PURE__*/React__default['default'].createElement(Provider$5, {
20304
+ }, /*#__PURE__*/React__default['default'].createElement(Provider$6, {
19783
20305
  value: {
19784
20306
  state,
19785
20307
  dispatch
19786
20308
  }
19787
20309
  }, children.length ? children.map((child, i) => /*#__PURE__*/React__default['default'].cloneElement(child, {
19788
- store: store$5,
20310
+ store: store$6,
19789
20311
  key: i
19790
20312
  })) : /*#__PURE__*/React__default['default'].cloneElement(children, {
19791
- store: store$5
20313
+ store: store$6
19792
20314
  })));
19793
20315
  };
19794
20316
 
@@ -19825,7 +20347,7 @@ function GiftCode({
19825
20347
  }
19826
20348
 
19827
20349
  const GiftRedeemCode = props => /*#__PURE__*/React__default['default'].createElement(GiftCode, Object.assign({
19828
- store: store$5
20350
+ store: store$6
19829
20351
  }, props));
19830
20352
 
19831
20353
  const GiftRedeemSubmitButton = ({
@@ -19838,7 +20360,7 @@ const GiftRedeemSubmitButton = ({
19838
20360
  state: {
19839
20361
  disableSubmit
19840
20362
  }
19841
- } = React.useContext(store$5);
20363
+ } = React.useContext(store$6);
19842
20364
  const {
19843
20365
  t
19844
20366
  } = useTranslation("register");
@@ -19931,7 +20453,7 @@ const moveDefaultAddressToStart = addresses => {
19931
20453
  return [defaultAddress, ...addressesWithoutDefault];
19932
20454
  };
19933
20455
 
19934
- const initialState$4 = {
20456
+ const initialState$5 = {
19935
20457
  addresses: [],
19936
20458
  selectedAddressId: null,
19937
20459
  isSubmitting: false,
@@ -19940,10 +20462,10 @@ const initialState$4 = {
19940
20462
  content: ""
19941
20463
  }
19942
20464
  };
19943
- const store$4 = /*#__PURE__*/React.createContext(initialState$4);
20465
+ const store$5 = /*#__PURE__*/React.createContext(initialState$5);
19944
20466
  const {
19945
- Provider: Provider$4
19946
- } = store$4;
20467
+ Provider: Provider$5
20468
+ } = store$5;
19947
20469
 
19948
20470
  const AddressSelectContainer = ({
19949
20471
  style,
@@ -20038,7 +20560,7 @@ const AddressSelectContainer = ({
20038
20560
  default:
20039
20561
  return state;
20040
20562
  }
20041
- }, initialState$4);
20563
+ }, initialState$5);
20042
20564
  React.useEffect(() => {
20043
20565
  var _window$Pelcro$user$r;
20044
20566
 
@@ -20051,16 +20573,16 @@ const AddressSelectContainer = ({
20051
20573
  style: { ...style
20052
20574
  },
20053
20575
  className: `pelcro-container pelcro-address-select-container ${className}`
20054
- }, /*#__PURE__*/React__default['default'].createElement(Provider$4, {
20576
+ }, /*#__PURE__*/React__default['default'].createElement(Provider$5, {
20055
20577
  value: {
20056
20578
  state,
20057
20579
  dispatch
20058
20580
  }
20059
20581
  }, children.length ? children.map((child, i) => /*#__PURE__*/React__default['default'].cloneElement(child, {
20060
- store: store$4,
20582
+ store: store$5,
20061
20583
  key: i
20062
20584
  })) : /*#__PURE__*/React__default['default'].cloneElement(children, {
20063
- store: store$4
20585
+ store: store$5
20064
20586
  })));
20065
20587
  };
20066
20588
 
@@ -20071,7 +20593,7 @@ const AddressSelectList = () => {
20071
20593
  addresses,
20072
20594
  selectedAddressId
20073
20595
  }
20074
- } = React.useContext(store$4);
20596
+ } = React.useContext(store$5);
20075
20597
 
20076
20598
  const handleAddressSelect = event => {
20077
20599
  dispatch({
@@ -20115,7 +20637,7 @@ const AddressSelectSubmit = ({
20115
20637
  selectedAddressId,
20116
20638
  isSubmitting
20117
20639
  }
20118
- } = React.useContext(store$4);
20640
+ } = React.useContext(store$5);
20119
20641
  const {
20120
20642
  t
20121
20643
  } = useTranslation("address");
@@ -20211,7 +20733,7 @@ const moveDefaultPaymentMethodToStart = paymentMethods => {
20211
20733
  return [defaultPaymentMethod, ...paymentMethodsWithoutDefault];
20212
20734
  };
20213
20735
 
20214
- const initialState$3 = {
20736
+ const initialState$4 = {
20215
20737
  paymentMethods: [],
20216
20738
  selectedPaymentMethodId: null,
20217
20739
  isSubmitting: false,
@@ -20220,10 +20742,10 @@ const initialState$3 = {
20220
20742
  content: ""
20221
20743
  }
20222
20744
  };
20223
- const store$3 = /*#__PURE__*/React.createContext(initialState$3);
20745
+ const store$4 = /*#__PURE__*/React.createContext(initialState$4);
20224
20746
  const {
20225
- Provider: Provider$3
20226
- } = store$3;
20747
+ Provider: Provider$4
20748
+ } = store$4;
20227
20749
 
20228
20750
  const PaymentMethodSelectContainer = ({
20229
20751
  style,
@@ -20282,7 +20804,7 @@ const PaymentMethodSelectContainer = ({
20282
20804
  default:
20283
20805
  return state;
20284
20806
  }
20285
- }, initialState$3);
20807
+ }, initialState$4);
20286
20808
  React.useEffect(() => {
20287
20809
  var _window$Pelcro$user$r3;
20288
20810
 
@@ -20295,16 +20817,16 @@ const PaymentMethodSelectContainer = ({
20295
20817
  style: { ...style
20296
20818
  },
20297
20819
  className: `pelcro-container pelcro-payment-select-container ${className}`
20298
- }, /*#__PURE__*/React__default['default'].createElement(Provider$3, {
20820
+ }, /*#__PURE__*/React__default['default'].createElement(Provider$4, {
20299
20821
  value: {
20300
20822
  state,
20301
20823
  dispatch
20302
20824
  }
20303
20825
  }, children.length ? children.map((child, i) => /*#__PURE__*/React__default['default'].cloneElement(child, {
20304
- store: store$3,
20826
+ store: store$4,
20305
20827
  key: i
20306
20828
  })) : /*#__PURE__*/React__default['default'].cloneElement(children, {
20307
- store: store$3
20829
+ store: store$4
20308
20830
  })));
20309
20831
  };
20310
20832
 
@@ -20318,7 +20840,7 @@ const PaymentMethodSelectList = () => {
20318
20840
  paymentMethods,
20319
20841
  selectedPaymentMethodId
20320
20842
  }
20321
- } = React.useContext(store$3);
20843
+ } = React.useContext(store$4);
20322
20844
 
20323
20845
  const handlePaymentMethodSelect = event => {
20324
20846
  dispatch({
@@ -20368,7 +20890,7 @@ const PaymentMethodSelectSubmit = ({
20368
20890
  selectedPaymentMethodId,
20369
20891
  isSubmitting
20370
20892
  }
20371
- } = React.useContext(store$3);
20893
+ } = React.useContext(store$4);
20372
20894
  return /*#__PURE__*/React__default['default'].createElement(Button, Object.assign({
20373
20895
  onClick: () => {
20374
20896
  dispatch({
@@ -23160,7 +23682,7 @@ const DashboardOpenButton = () => {
23160
23682
  };
23161
23683
  DashboardOpenButton.viewId = "dashboard-open";
23162
23684
 
23163
- const initialState$2 = {
23685
+ const initialState$3 = {
23164
23686
  imageSrc: null,
23165
23687
  crop: {
23166
23688
  x: 0,
@@ -23174,10 +23696,10 @@ const initialState$2 = {
23174
23696
  content: ""
23175
23697
  }
23176
23698
  };
23177
- const store$2 = /*#__PURE__*/React.createContext(initialState$2);
23699
+ const store$3 = /*#__PURE__*/React.createContext(initialState$3);
23178
23700
  const {
23179
- Provider: Provider$2
23180
- } = store$2;
23701
+ Provider: Provider$3
23702
+ } = store$3;
23181
23703
 
23182
23704
  const ProfilePicChangeContainer = ({
23183
23705
  style,
@@ -23311,21 +23833,21 @@ const ProfilePicChangeContainer = ({
23311
23833
  default:
23312
23834
  return state;
23313
23835
  }
23314
- }, initialState$2);
23836
+ }, initialState$3);
23315
23837
  return /*#__PURE__*/React__default['default'].createElement("div", {
23316
23838
  style: { ...style
23317
23839
  },
23318
23840
  className: `pelcro-container pelcro-profile-picture-container ${className}`
23319
- }, /*#__PURE__*/React__default['default'].createElement(Provider$2, {
23841
+ }, /*#__PURE__*/React__default['default'].createElement(Provider$3, {
23320
23842
  value: {
23321
23843
  state,
23322
23844
  dispatch
23323
23845
  }
23324
23846
  }, children.length ? children.map((child, i) => /*#__PURE__*/React__default['default'].cloneElement(child, {
23325
- store: store$2,
23847
+ store: store$3,
23326
23848
  key: i
23327
23849
  })) : /*#__PURE__*/React__default['default'].cloneElement(children, {
23328
- store: store$2
23850
+ store: store$3
23329
23851
  })));
23330
23852
  };
23331
23853
  /**
@@ -23387,7 +23909,7 @@ const ProfilePicChangeButton = ({
23387
23909
  isSubmitting
23388
23910
  },
23389
23911
  dispatch
23390
- } = React.useContext(store$2);
23912
+ } = React.useContext(store$3);
23391
23913
  const {
23392
23914
  t
23393
23915
  } = useTranslation("userEdit");
@@ -24755,7 +25277,7 @@ const ProfilePicChangeCropper = ({
24755
25277
  zoom
24756
25278
  },
24757
25279
  dispatch
24758
- } = React.useContext(store$2);
25280
+ } = React.useContext(store$3);
24759
25281
  return /*#__PURE__*/React__default['default'].createElement("div", {
24760
25282
  className: `plc-relative plc-w-full plc-h-52 sm:plc-h-96 ${className}`
24761
25283
  }, /*#__PURE__*/React__default['default'].createElement(Cropper, Object.assign({
@@ -24797,7 +25319,7 @@ const ProfilePicChangeZoom = ({
24797
25319
  zoom
24798
25320
  },
24799
25321
  dispatch
24800
- } = React.useContext(store$2);
25322
+ } = React.useContext(store$3);
24801
25323
  const {
24802
25324
  t
24803
25325
  } = useTranslation("userEdit");
@@ -24849,7 +25371,7 @@ const ProfilePicChangeSelectButton = ({
24849
25371
  state: {
24850
25372
  isSubmitting
24851
25373
  }
24852
- } = React.useContext(store$2);
25374
+ } = React.useContext(store$3);
24853
25375
  const {
24854
25376
  t
24855
25377
  } = useTranslation("userEdit");
@@ -24891,7 +25413,7 @@ const ProfilePicChangeRemoveButton = ({
24891
25413
  state: {
24892
25414
  isSubmitting
24893
25415
  }
24894
- } = React.useContext(store$2);
25416
+ } = React.useContext(store$3);
24895
25417
  const {
24896
25418
  t
24897
25419
  } = useTranslation("userEdit");
@@ -24914,7 +25436,7 @@ const ProfilePicChangeWrapper = () => {
24914
25436
  state: {
24915
25437
  imageSrc
24916
25438
  }
24917
- } = React.useContext(store$2);
25439
+ } = React.useContext(store$3);
24918
25440
  const {
24919
25441
  t
24920
25442
  } = useTranslation("userEdit");
@@ -24976,17 +25498,17 @@ function ProfilePicChangeModal({
24976
25498
  }
24977
25499
  ProfilePicChangeModal.viewId = "profile-picture";
24978
25500
 
24979
- const initialState$1 = {
25501
+ const initialState$2 = {
24980
25502
  isSubmitting: false,
24981
25503
  alert: {
24982
25504
  type: "error",
24983
25505
  content: ""
24984
25506
  }
24985
25507
  };
24986
- const store$1 = /*#__PURE__*/React.createContext(initialState$1);
25508
+ const store$2 = /*#__PURE__*/React.createContext(initialState$2);
24987
25509
  const {
24988
- Provider: Provider$1
24989
- } = store$1;
25510
+ Provider: Provider$2
25511
+ } = store$2;
24990
25512
 
24991
25513
  const EmailVerifyContainer = ({
24992
25514
  style,
@@ -25049,21 +25571,21 @@ const EmailVerifyContainer = ({
25049
25571
  default:
25050
25572
  return state;
25051
25573
  }
25052
- }, initialState$1);
25574
+ }, initialState$2);
25053
25575
  return /*#__PURE__*/React__default['default'].createElement("div", {
25054
25576
  style: { ...style
25055
25577
  },
25056
25578
  className: `pelcro-container pelcro-email-verify-container ${className}`
25057
- }, /*#__PURE__*/React__default['default'].createElement(Provider$1, {
25579
+ }, /*#__PURE__*/React__default['default'].createElement(Provider$2, {
25058
25580
  value: {
25059
25581
  state,
25060
25582
  dispatch
25061
25583
  }
25062
25584
  }, children.length ? children.map((child, i) => /*#__PURE__*/React__default['default'].cloneElement(child, {
25063
- store: store$1,
25585
+ store: store$2,
25064
25586
  key: i
25065
25587
  })) : /*#__PURE__*/React__default['default'].cloneElement(children, {
25066
- store: store$1
25588
+ store: store$2
25067
25589
  })));
25068
25590
  };
25069
25591
 
@@ -25077,7 +25599,7 @@ const EmailVerifyResendButton = ({
25077
25599
  state: {
25078
25600
  isSubmitting
25079
25601
  }
25080
- } = React.useContext(store$1);
25602
+ } = React.useContext(store$2);
25081
25603
  const {
25082
25604
  t
25083
25605
  } = useTranslation("verifyEmail");
@@ -25152,6 +25674,170 @@ const EmailVerifyModal = ({
25152
25674
  };
25153
25675
  EmailVerifyModal.viewId = "email-verify";
25154
25676
 
25677
+ const initialState$1 = {
25678
+ isLoading: true,
25679
+ isTokenValid: false,
25680
+ alert: {
25681
+ type: "error",
25682
+ content: ""
25683
+ }
25684
+ };
25685
+ const store$1 = /*#__PURE__*/React.createContext(initialState$1);
25686
+ const {
25687
+ Provider: Provider$1
25688
+ } = store$1;
25689
+
25690
+ const VerifyLinkTokenContainer = ({
25691
+ style,
25692
+ className = "",
25693
+ onSuccess = () => {},
25694
+ onFailure = () => {},
25695
+ children
25696
+ }) => {
25697
+ const handleVerifyLinkToken = ({}, dispatch) => {
25698
+ const token = window.Pelcro.helpers.getURLParameter("token");
25699
+ window.Pelcro.user.verifyLoginToken({
25700
+ token
25701
+ }, (err, res) => {
25702
+ dispatch({
25703
+ type: LOADING,
25704
+ payload: false
25705
+ });
25706
+
25707
+ if (err) {
25708
+ dispatch({
25709
+ type: SHOW_ALERT,
25710
+ payload: {
25711
+ type: "error",
25712
+ content: getErrorMessages(err)
25713
+ }
25714
+ });
25715
+ onFailure(err);
25716
+ } else {
25717
+ onSuccess(res);
25718
+ }
25719
+ });
25720
+ };
25721
+
25722
+ const [state, dispatch] = useReducerWithSideEffects((state, action) => {
25723
+ switch (action.type) {
25724
+ case SHOW_ALERT:
25725
+ return lib_7({ ...state,
25726
+ alert: action.payload
25727
+ });
25728
+
25729
+ case LOADING:
25730
+ return lib_7({ ...state,
25731
+ isLoading: action.payload
25732
+ });
25733
+
25734
+ case LINK_TOKEN_VERIFY:
25735
+ return lib_5({ ...state,
25736
+ isLoading: true
25737
+ }, (state, dispatch) => handleVerifyLinkToken(state, dispatch));
25738
+
25739
+ default:
25740
+ return state;
25741
+ }
25742
+ }, initialState$1);
25743
+ return /*#__PURE__*/React__default['default'].createElement("div", {
25744
+ style: { ...style
25745
+ },
25746
+ className: `pelcro-container pelcro-login-container ${className}`
25747
+ }, /*#__PURE__*/React__default['default'].createElement(Provider$1, {
25748
+ value: {
25749
+ state,
25750
+ dispatch
25751
+ }
25752
+ }, children.length ? children.map((child, i) => {
25753
+ if (child) {
25754
+ return /*#__PURE__*/React__default['default'].cloneElement(child, {
25755
+ store: store$1,
25756
+ key: i
25757
+ });
25758
+ }
25759
+ }) : /*#__PURE__*/React__default['default'].cloneElement(children, {
25760
+ store: store$1
25761
+ })));
25762
+ };
25763
+
25764
+ const VerifyLinkTokenLoader = () => {
25765
+ React.useEffect(() => {
25766
+ dispatch({
25767
+ type: LINK_TOKEN_VERIFY
25768
+ });
25769
+ }, []);
25770
+ const {
25771
+ dispatch,
25772
+ state: {
25773
+ isLoading
25774
+ }
25775
+ } = React.useContext(store$1);
25776
+
25777
+ if (isLoading) {
25778
+ return /*#__PURE__*/React__default['default'].createElement(Loader, {
25779
+ width: 60,
25780
+ height: 100
25781
+ });
25782
+ }
25783
+
25784
+ return /*#__PURE__*/React__default['default'].createElement("div", {
25785
+ className: "plc-max-h-80 plc-overflow-y-auto pelcro-newsletters-wrapper"
25786
+ });
25787
+ };
25788
+
25789
+ /**
25790
+ *
25791
+ */
25792
+
25793
+ function VerifyLinkTokenView(props) {
25794
+ const {
25795
+ t
25796
+ } = useTranslation("verifyLinkToken");
25797
+ return /*#__PURE__*/React__default['default'].createElement("div", {
25798
+ id: "pelcro-login-view"
25799
+ }, /*#__PURE__*/React__default['default'].createElement("div", {
25800
+ className: "plc-mb-6 plc-text-2xl plc-font-semibold plc-text-center plc-text-gray-900 pelcro-title-wrapper"
25801
+ }, /*#__PURE__*/React__default['default'].createElement("h4", null, t("labels.title"))), /*#__PURE__*/React__default['default'].createElement("form", {
25802
+ action: "javascript:void(0);",
25803
+ className: "plc-mt-2 pelcro-form"
25804
+ }, /*#__PURE__*/React__default['default'].createElement(VerifyLinkTokenContainer, props, /*#__PURE__*/React__default['default'].createElement(VerifyLinkTokenLoader, null), /*#__PURE__*/React__default['default'].createElement(AlertWithContext, null))));
25805
+ }
25806
+
25807
+ /**
25808
+ *
25809
+ */
25810
+
25811
+ function VerifyLinkTokenModal({
25812
+ onDisplay,
25813
+ onClose,
25814
+ ...props
25815
+ }) {
25816
+ const {
25817
+ t
25818
+ } = useTranslation("verifyLinkToken");
25819
+ const {
25820
+ resetView
25821
+ } = usePelcro();
25822
+
25823
+ const onSuccess = res => {
25824
+ var _props$onSuccess;
25825
+
25826
+ (_props$onSuccess = props.onSuccess) === null || _props$onSuccess === void 0 ? void 0 : _props$onSuccess.call(props, res);
25827
+ resetView();
25828
+ notify.success(t("messages.success"));
25829
+ };
25830
+
25831
+ return /*#__PURE__*/React__default['default'].createElement(Modal, {
25832
+ id: "pelcro-login-modal",
25833
+ onDisplay: onDisplay,
25834
+ onClose: onClose
25835
+ }, /*#__PURE__*/React__default['default'].createElement(ModalBody, null, /*#__PURE__*/React__default['default'].createElement(VerifyLinkTokenView, Object.assign({}, props, {
25836
+ onSuccess: onSuccess
25837
+ }))), /*#__PURE__*/React__default['default'].createElement(ModalFooter, null, /*#__PURE__*/React__default['default'].createElement(Authorship, null)));
25838
+ }
25839
+ VerifyLinkTokenModal.viewId = "passwordless-login";
25840
+
25155
25841
  const InvoicePaymentContainer = props => /*#__PURE__*/React__default['default'].createElement(PaymentMethodContainer, Object.assign({
25156
25842
  type: "invoicePayment",
25157
25843
  className: "pelcro-invoice-payment-container"
@@ -25298,6 +25984,8 @@ const InvoiceDetailsView = props => {
25298
25984
  invoice
25299
25985
  } = usePelcro();
25300
25986
  const showPayButton = canPayInvoice(invoice);
25987
+ const showDownloadButton = Boolean(invoice === null || invoice === void 0 ? void 0 : invoice.invoice_pdf);
25988
+ const hasPlanDetails = Boolean(invoice.plan);
25301
25989
  const creationDate = new Date(invoice === null || invoice === void 0 ? void 0 : invoice.created_at);
25302
25990
  const formattedCreationDate = new Intl.DateTimeFormat("en-CA").format(creationDate);
25303
25991
  return /*#__PURE__*/React__default['default'].createElement("div", {
@@ -25315,7 +26003,7 @@ const InvoiceDetailsView = props => {
25315
26003
  className: "plc-font-bold pelcro-invoice-summary-title"
25316
26004
  }, t("labels.summary")), invoice && /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, null, /*#__PURE__*/React__default['default'].createElement("p", {
25317
26005
  className: "plc-mr-2 pelcro-invoice-creation-date"
25318
- }, `${t("labels.creationDate")} ${formattedCreationDate}`), /*#__PURE__*/React__default['default'].createElement("div", {
26006
+ }, `${t("labels.creationDate")} ${formattedCreationDate}`), hasPlanDetails && /*#__PURE__*/React__default['default'].createElement("div", {
25319
26007
  className: "plc-flex plc-items-center plc-pt-2 plc-mt-2 plc-border-t plc-border-gray-400 plc-min-h-12 plc-justify-between pelcro-invoice-plan-wrapper"
25320
26008
  }, /*#__PURE__*/React__default['default'].createElement("div", {
25321
26009
  className: "plc-break-words pelcro-invoice-plan-name"
@@ -25341,7 +26029,7 @@ const InvoiceDetailsView = props => {
25341
26029
  className: "plc-font-semibold pelcro-invoice-total"
25342
26030
  }, getFormattedPriceByLocal(invoice.amount_remaining, invoice.currency, getPageOrDefaultLanguage())))))), /*#__PURE__*/React__default['default'].createElement("div", {
25343
26031
  className: "plc-flex plc-items-center plc-justify-center plc-mt-4"
25344
- }, /*#__PURE__*/React__default['default'].createElement(InvoiceDetailsDownloadButton, {
26032
+ }, showDownloadButton && /*#__PURE__*/React__default['default'].createElement(InvoiceDetailsDownloadButton, {
25345
26033
  url: invoice === null || invoice === void 0 ? void 0 : invoice.invoice_pdf,
25346
26034
  className: "plc-w-full plc-text-center"
25347
26035
  }), showPayButton && /*#__PURE__*/React__default['default'].createElement(InvoiceDetailsPayButton, {
@@ -25575,6 +26263,10 @@ exports.UserUpdatePhone = UserUpdatePhone;
25575
26263
  exports.UserUpdateProfilePic = UserUpdateProfilePic;
25576
26264
  exports.UserUpdateTextInput = UserUpdateTextInput;
25577
26265
  exports.UserUpdateView = UserUpdateView;
26266
+ exports.VerifyLinkTokenContainer = VerifyLinkTokenContainer;
26267
+ exports.VerifyLinkTokenLoader = VerifyLinkTokenLoader;
26268
+ exports.VerifyLinkTokenModal = VerifyLinkTokenModal;
26269
+ exports.VerifyLinkTokenView = VerifyLinkTokenView;
25578
26270
  exports.authenticatedButtons = authenticatedButtons;
25579
26271
  exports.i18n = i18next;
25580
26272
  exports.initButtons = init$1;