@pelcro/react-pelcro-js 3.9.0-beta.1 → 3.9.0-beta.3

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
@@ -3824,7 +3824,10 @@ var labels$F = {
3824
3824
  interval: "{{count}} {{interval}}",
3825
3825
  interval_plural: "{{count}} {{interval}}s",
3826
3826
  tax: "+ Tax",
3827
- removeCoupon: "REMOVE"
3827
+ removeCoupon: "REMOVE",
3828
+ firstName: "First name",
3829
+ lastName: "Last name",
3830
+ phone: "Phone"
3828
3831
  };
3829
3832
  var checkoutForm_en = {
3830
3833
  messages: messages$I,
@@ -3851,7 +3854,10 @@ var labels$E = {
3851
3854
  interval: "{{count}} {{interval}}",
3852
3855
  interval_plural: "{{count}} {{interval}}s",
3853
3856
  tax: "+ Taxe",
3854
- removeCoupon: "RETIRER"
3857
+ removeCoupon: "RETIRER",
3858
+ firstName: "Prénom",
3859
+ lastName: "Nom de famille",
3860
+ phone: "Téléphoner"
3855
3861
  };
3856
3862
  var checkoutForm_fr = {
3857
3863
  messages: messages$H,
@@ -3878,7 +3884,10 @@ var labels$D = {
3878
3884
  interval: "{{count}} {{interval}}",
3879
3885
  interval_plural: "{{count}} {{interval}}",
3880
3886
  tax: "+ 세금",
3881
- removeCoupon: "제거"
3887
+ removeCoupon: "제거",
3888
+ firstName: "이름",
3889
+ lastName: "성",
3890
+ phone: "핸드폰"
3882
3891
  };
3883
3892
  var checkoutForm_ko = {
3884
3893
  messages: messages$G,
@@ -12277,32 +12286,25 @@ const RegisterButton = ({
12277
12286
  className,
12278
12287
  ...otherProps
12279
12288
  }) => {
12280
- var _window$Pelcro$site$r, _window$Pelcro$site$r2;
12289
+ var _window$Pelcro$site$r;
12281
12290
 
12282
12291
  const {
12283
12292
  state: {
12284
12293
  emailError,
12285
12294
  passwordError,
12286
- firstNameError,
12287
- lastNameError,
12288
- phoneError,
12289
12295
  email,
12290
12296
  password,
12291
- firstName,
12292
- lastName,
12293
- phone,
12294
12297
  buttonDisabled
12295
12298
  },
12296
12299
  dispatch
12297
12300
  } = React.useContext(store$k);
12298
- const supportsTap = Boolean((_window$Pelcro$site$r = window.Pelcro.site.read()) === null || _window$Pelcro$site$r === void 0 ? void 0 : _window$Pelcro$site$r.tap_gateway_settings);
12299
12301
  const {
12300
12302
  t
12301
12303
  } = useTranslation("register");
12302
12304
  const [isDisabled, setDisabled] = React.useState(true);
12303
12305
  React.useEffect(() => {
12304
- setDisabled(buttonDisabled || emailError || passwordError || firstNameError || lastNameError || phoneError || !email.length || !password.length || supportsTap && !firstName.length || supportsTap && !lastName.length || supportsTap && !phone.length);
12305
- }, [buttonDisabled, emailError, passwordError, firstNameError, lastNameError, phoneError, email, password, firstName, lastName, phone]);
12306
+ setDisabled(buttonDisabled || emailError || passwordError || !email.length || !password.length);
12307
+ }, [buttonDisabled, emailError, passwordError, email, password]);
12306
12308
  return /*#__PURE__*/React__default['default'].createElement(Button, Object.assign({
12307
12309
  onClick: () => {
12308
12310
  dispatch({
@@ -12314,11 +12316,12 @@ const RegisterButton = ({
12314
12316
  isLoading: buttonDisabled,
12315
12317
  className: `${className} g-recaptcha`,
12316
12318
  "data-action": "register",
12317
- "data-sitekey": (_window$Pelcro$site$r2 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r2 === void 0 ? void 0 : _window$Pelcro$site$r2.security_key
12319
+ "data-sitekey": (_window$Pelcro$site$r = window.Pelcro.site.read()) === null || _window$Pelcro$site$r === void 0 ? void 0 : _window$Pelcro$site$r.security_key
12318
12320
  }, otherProps), name !== null && name !== void 0 ? name : t("messages.createAccount"));
12319
12321
  };
12320
12322
 
12321
12323
  function FirstName({
12324
+ initWithUserFirstName = true,
12322
12325
  store,
12323
12326
  ...otherProps
12324
12327
  }) {
@@ -12351,7 +12354,23 @@ function FirstName({
12351
12354
  }, [dispatch, firstName, finishedTyping]);
12352
12355
  React.useEffect(() => {
12353
12356
  handleInputChange(firstName);
12354
- }, [finishedTyping, firstName, handleInputChange]);
12357
+ }, [finishedTyping, firstName, handleInputChange]); // Initialize first name field with user's first name
12358
+
12359
+ const loadFirstNameIntoField = () => {
12360
+ handleInputChange(window.Pelcro.user.read().first_name);
12361
+ };
12362
+
12363
+ React.useEffect(() => {
12364
+ if (initWithUserFirstName) {
12365
+ document.addEventListener("PelcroUserLoaded", () => {
12366
+ loadFirstNameIntoField();
12367
+ });
12368
+ loadFirstNameIntoField();
12369
+ return () => {
12370
+ document.removeEventListener("PelcroUserLoaded", handleInputChange);
12371
+ };
12372
+ }
12373
+ }, []);
12355
12374
  return /*#__PURE__*/React__default['default'].createElement(Input, Object.assign({
12356
12375
  type: "text",
12357
12376
  error: firstNameError,
@@ -12367,6 +12386,7 @@ const RegisterFirstName = props => /*#__PURE__*/React__default['default'].create
12367
12386
  }, props));
12368
12387
 
12369
12388
  function LastName({
12389
+ initWithUserLastName = true,
12370
12390
  store,
12371
12391
  ...otherProps
12372
12392
  }) {
@@ -12399,7 +12419,23 @@ function LastName({
12399
12419
  }, [dispatch, lastName, finishedTyping]);
12400
12420
  React.useEffect(() => {
12401
12421
  handleInputChange(lastName);
12402
- }, [finishedTyping, lastName, handleInputChange]);
12422
+ }, [finishedTyping, lastName, handleInputChange]); // Initialize last name field with user's last name
12423
+
12424
+ const loadLastNameIntoField = () => {
12425
+ handleInputChange(window.Pelcro.user.read().last_name);
12426
+ };
12427
+
12428
+ React.useEffect(() => {
12429
+ if (initWithUserLastName) {
12430
+ document.addEventListener("PelcroUserLoaded", () => {
12431
+ loadLastNameIntoField();
12432
+ });
12433
+ loadLastNameIntoField();
12434
+ return () => {
12435
+ document.removeEventListener("PelcroUserLoaded", handleInputChange);
12436
+ };
12437
+ }
12438
+ }, []);
12403
12439
  return /*#__PURE__*/React__default['default'].createElement(Input, Object.assign({
12404
12440
  type: "text",
12405
12441
  error: lastNameError,
@@ -12415,6 +12451,7 @@ const RegisterLastName = props => /*#__PURE__*/React__default['default'].createE
12415
12451
  }, props));
12416
12452
 
12417
12453
  function Phone({
12454
+ initWithUserPhone = true,
12418
12455
  store,
12419
12456
  ...otherProps
12420
12457
  }) {
@@ -12447,7 +12484,23 @@ function Phone({
12447
12484
  }, [dispatch, phone, finishedTyping]);
12448
12485
  React.useEffect(() => {
12449
12486
  handleInputChange(phone);
12450
- }, [finishedTyping, phone, handleInputChange]);
12487
+ }, [finishedTyping, phone, handleInputChange]); // Initialize phone field with user's phone
12488
+
12489
+ const loadPhoneIntoField = () => {
12490
+ handleInputChange(window.Pelcro.user.read().phone);
12491
+ };
12492
+
12493
+ React.useEffect(() => {
12494
+ if (initWithUserPhone) {
12495
+ document.addEventListener("PelcroUserLoaded", () => {
12496
+ loadPhoneIntoField();
12497
+ });
12498
+ loadPhoneIntoField();
12499
+ return () => {
12500
+ document.removeEventListener("PelcroUserLoaded", handleInputChange);
12501
+ };
12502
+ }
12503
+ }, []);
12451
12504
  return /*#__PURE__*/React__default['default'].createElement(Input, Object.assign({
12452
12505
  type: "tel",
12453
12506
  error: phoneError,
@@ -12458,16 +12511,12 @@ function Phone({
12458
12511
  }, otherProps));
12459
12512
  }
12460
12513
 
12461
- const RegisterPhone = props => /*#__PURE__*/React__default['default'].createElement(Phone, Object.assign({
12462
- store: store$k
12463
- }, props));
12464
-
12465
12514
  /**
12466
12515
  *
12467
12516
  */
12468
12517
 
12469
12518
  function RegisterView(props) {
12470
- var _product$paywall$regi, _product$paywall, _product$paywall$regi2, _product$paywall2, _window$Pelcro$site$r, _window$Pelcro$site$r2, _window$Pelcro$site$r3, _window$Pelcro, _window$Pelcro$uiSett, _window$Pelcro$site$r4;
12519
+ var _product$paywall$regi, _product$paywall, _product$paywall$regi2, _product$paywall2, _window$Pelcro$site$r, _window$Pelcro$site$r2, _window$Pelcro$site$r3, _window$Pelcro, _window$Pelcro$uiSett;
12471
12520
 
12472
12521
  const {
12473
12522
  t
@@ -12479,7 +12528,6 @@ function RegisterView(props) {
12479
12528
  const subtitle = (_product$paywall$regi2 = product === null || product === void 0 ? void 0 : (_product$paywall2 = product.paywall) === null || _product$paywall2 === void 0 ? void 0 : _product$paywall2.register_subtitle) !== null && _product$paywall$regi2 !== void 0 ? _product$paywall$regi2 : t("subtitle");
12480
12529
  const socialLoginEnabled = ((_window$Pelcro$site$r = window.Pelcro.site.read()) === null || _window$Pelcro$site$r === void 0 ? void 0 : _window$Pelcro$site$r.facebook_app_id) || ((_window$Pelcro$site$r2 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r2 === void 0 ? void 0 : _window$Pelcro$site$r2.google_app_id) || ((_window$Pelcro$site$r3 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r3 === void 0 ? void 0 : _window$Pelcro$site$r3.auth0_client_id);
12481
12530
  const showNameFields = (_window$Pelcro = window.Pelcro) === null || _window$Pelcro === void 0 ? void 0 : (_window$Pelcro$uiSett = _window$Pelcro.uiSettings) === null || _window$Pelcro$uiSett === void 0 ? void 0 : _window$Pelcro$uiSett.enableNameFieldsInRegister;
12482
- const supportsTap = Boolean((_window$Pelcro$site$r4 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r4 === void 0 ? void 0 : _window$Pelcro$site$r4.tap_gateway_settings);
12483
12531
  return /*#__PURE__*/React__default['default'].createElement("div", {
12484
12532
  id: "pelcro-register-view"
12485
12533
  }, /*#__PURE__*/React__default['default'].createElement("div", {
@@ -12489,25 +12537,18 @@ function RegisterView(props) {
12489
12537
  }, title), /*#__PURE__*/React__default['default'].createElement("p", null, subtitle)), /*#__PURE__*/React__default['default'].createElement("form", {
12490
12538
  action: "javascript:void(0);",
12491
12539
  className: "plc-mt-2 pelcro-form"
12492
- }, /*#__PURE__*/React__default['default'].createElement(RegisterContainer, props, /*#__PURE__*/React__default['default'].createElement(AlertWithContext, null), (showNameFields || supportsTap) && /*#__PURE__*/React__default['default'].createElement("div", {
12540
+ }, /*#__PURE__*/React__default['default'].createElement(RegisterContainer, props, /*#__PURE__*/React__default['default'].createElement(AlertWithContext, null), showNameFields && /*#__PURE__*/React__default['default'].createElement("div", {
12493
12541
  className: "plc-flex plc-items-start"
12494
12542
  }, /*#__PURE__*/React__default['default'].createElement(RegisterFirstName, {
12495
12543
  id: "pelcro-input-first-name",
12496
12544
  label: t("labels.firstName"),
12497
- errorId: "pelcro-input-firstName-error",
12498
- required: supportsTap ? true : false
12545
+ errorId: "pelcro-input-firstName-error"
12499
12546
  }), /*#__PURE__*/React__default['default'].createElement(RegisterLastName, {
12500
12547
  wrapperClassName: "plc-ml-3",
12501
12548
  id: "pelcro-input-last-name",
12502
12549
  label: t("labels.lastName"),
12503
- errorId: "pelcro-input-lastName-error",
12504
- required: supportsTap ? true : false
12505
- })), supportsTap && /*#__PURE__*/React__default['default'].createElement(RegisterPhone, {
12506
- id: "pelcro-input-phone",
12507
- errorId: "pelcro-input-phone-error",
12508
- label: t("labels.phone"),
12509
- required: supportsTap ? true : false
12510
- }), /*#__PURE__*/React__default['default'].createElement(RegisterEmail, {
12550
+ errorId: "pelcro-input-lastName-error"
12551
+ })), /*#__PURE__*/React__default['default'].createElement(RegisterEmail, {
12511
12552
  id: "pelcro-input-email",
12512
12553
  errorId: "pelcro-input-email-error",
12513
12554
  label: t("labels.email"),
@@ -12553,9 +12594,9 @@ function RegisterView(props) {
12553
12594
  */
12554
12595
 
12555
12596
  function hasSecurityTokenEnabled() {
12556
- var _window$Pelcro$site, _window$Pelcro$site$r5;
12597
+ var _window$Pelcro$site, _window$Pelcro$site$r4;
12557
12598
 
12558
- return Boolean((_window$Pelcro$site = window.Pelcro.site) === null || _window$Pelcro$site === void 0 ? void 0 : (_window$Pelcro$site$r5 = _window$Pelcro$site.read()) === null || _window$Pelcro$site$r5 === void 0 ? void 0 : _window$Pelcro$site$r5.security_key);
12599
+ return Boolean((_window$Pelcro$site = window.Pelcro.site) === null || _window$Pelcro$site === void 0 ? void 0 : (_window$Pelcro$site$r4 = _window$Pelcro$site.read()) === null || _window$Pelcro$site$r4 === void 0 ? void 0 : _window$Pelcro$site$r4.security_key);
12559
12600
  }
12560
12601
 
12561
12602
  const Loader = props => /*#__PURE__*/React__default['default'].createElement("div", {
@@ -15274,6 +15315,12 @@ const initialState$j = {
15274
15315
  updatedPrice: null,
15275
15316
  taxAmount: null,
15276
15317
  currentPlan: null,
15318
+ firstName: "",
15319
+ lastName: "",
15320
+ phone: "",
15321
+ firstNameError: null,
15322
+ lastNameError: null,
15323
+ phoneError: null,
15277
15324
  alert: {
15278
15325
  type: "error",
15279
15326
  content: ""
@@ -15390,8 +15437,14 @@ const PaymentMethodContainerWithoutStripe = ({
15390
15437
  }
15391
15438
  });
15392
15439
  } else {
15440
+ console.log("First Name", state.firstName);
15441
+ console.log("Last Name", state.lastName);
15442
+ console.log("Phone", state.phone);
15393
15443
  window.Pelcro.payment.authorize({
15394
15444
  auth_token: window.Pelcro.user.read().auth_token,
15445
+ first_name: window.Pelcro.user.read().first_name || state.firstName,
15446
+ last_name: window.Pelcro.user.read().last_name || state.lastName,
15447
+ phone: window.Pelcro.user.read().phone || state.phone,
15395
15448
  site_id: window.Pelcro.siteid,
15396
15449
  amount: totalAmount,
15397
15450
  currency: (plan === null || plan === void 0 ? void 0 : plan.currency) || (invoice === null || invoice === void 0 ? void 0 : invoice.currency) || window.Pelcro.site.read().default_currency,
@@ -16917,6 +16970,42 @@ const PaymentMethodContainerWithoutStripe = ({
16917
16970
  percentOff: action.payload
16918
16971
  });
16919
16972
 
16973
+ case SET_FIRST_NAME:
16974
+ return lib_7({ ...state,
16975
+ firstName: action.payload,
16976
+ firstNameError: null
16977
+ });
16978
+
16979
+ case SET_LAST_NAME:
16980
+ return lib_7({ ...state,
16981
+ lastName: action.payload,
16982
+ lastNameError: null
16983
+ });
16984
+
16985
+ case SET_PHONE:
16986
+ return lib_7({ ...state,
16987
+ phone: action.payload,
16988
+ phoneError: null
16989
+ });
16990
+
16991
+ case SET_FIRST_NAME_ERROR:
16992
+ return lib_7({ ...state,
16993
+ firstNameError: action.payload,
16994
+ firstName: ""
16995
+ });
16996
+
16997
+ case SET_LAST_NAME_ERROR:
16998
+ return lib_7({ ...state,
16999
+ lastNameError: action.payload,
17000
+ lastName: ""
17001
+ });
17002
+
17003
+ case SET_PHONE_ERROR:
17004
+ return lib_7({ ...state,
17005
+ phoneError: action.payload,
17006
+ phone: null
17007
+ });
17008
+
16920
17009
  case SHOW_ALERT:
16921
17010
  return lib_7({ ...state,
16922
17011
  alert: action.payload
@@ -17131,7 +17220,7 @@ const SubmitPaymentMethod = ({
17131
17220
  onClick,
17132
17221
  ...otherProps
17133
17222
  }) => {
17134
- var _plan$quantity;
17223
+ var _plan$quantity, _window$Pelcro$site$r;
17135
17224
 
17136
17225
  const {
17137
17226
  plan
@@ -17142,6 +17231,12 @@ const SubmitPaymentMethod = ({
17142
17231
  const {
17143
17232
  dispatch,
17144
17233
  state: {
17234
+ firstNameError,
17235
+ lastNameError,
17236
+ phoneError,
17237
+ firstName,
17238
+ lastName,
17239
+ phone,
17145
17240
  disableSubmit,
17146
17241
  isLoading,
17147
17242
  updatedPrice
@@ -17150,6 +17245,18 @@ const SubmitPaymentMethod = ({
17150
17245
  const planQuantity = (_plan$quantity = plan === null || plan === void 0 ? void 0 : plan.quantity) !== null && _plan$quantity !== void 0 ? _plan$quantity : 1;
17151
17246
  const price = updatedPrice !== null && updatedPrice !== void 0 ? updatedPrice : plan === null || plan === void 0 ? void 0 : plan.amount;
17152
17247
  const priceFormatted = getFormattedPriceByLocal(price * planQuantity, plan === null || plan === void 0 ? void 0 : plan.currency, getPageOrDefaultLanguage());
17248
+ const supportsTap = Boolean((_window$Pelcro$site$r = window.Pelcro.site.read()) === null || _window$Pelcro$site$r === void 0 ? void 0 : _window$Pelcro$site$r.tap_gateway_settings);
17249
+ const isUserFirstName = Boolean(window.Pelcro.user.read().first_name);
17250
+ const isUserLastName = Boolean(window.Pelcro.user.read().last_name);
17251
+ const isUserPhone = Boolean(window.Pelcro.user.read().phone);
17252
+ const [isDisabled, setDisabled] = React.useState(true);
17253
+ React.useEffect(() => {
17254
+ if (supportsTap && isUserFirstName && isUserLastName && isUserPhone) {
17255
+ setDisabled(disableSubmit);
17256
+ } else {
17257
+ setDisabled(disableSubmit || supportsTap && firstNameError || supportsTap && lastNameError || supportsTap && phoneError || supportsTap && !firstName.length || supportsTap && !lastName.length || supportsTap && !phone.length);
17258
+ }
17259
+ }, [disableSubmit, firstNameError, lastNameError, phoneError, firstName, lastName, phone]);
17153
17260
  return /*#__PURE__*/React__default['default'].createElement(Button, Object.assign({
17154
17261
  role: "submit",
17155
17262
  className: "plc-w-full plc-py-3",
@@ -17161,7 +17268,7 @@ const SubmitPaymentMethod = ({
17161
17268
  });
17162
17269
  onClick === null || onClick === void 0 ? void 0 : onClick();
17163
17270
  },
17164
- disabled: disableSubmit
17271
+ disabled: isDisabled
17165
17272
  }, otherProps), plan ? /*#__PURE__*/React__default['default'].createElement("span", {
17166
17273
  className: "plc-capitalize "
17167
17274
  }, t("labels.pay"), " ", priceFormatted && priceFormatted) : t("labels.submit"));
@@ -17736,6 +17843,18 @@ const TaxAmount = () => {
17736
17843
  return null;
17737
17844
  };
17738
17845
 
17846
+ const IncludeFirstName = props => /*#__PURE__*/React__default['default'].createElement(FirstName, Object.assign({
17847
+ store: store$j
17848
+ }, props));
17849
+
17850
+ const IncludeLastName = props => /*#__PURE__*/React__default['default'].createElement(LastName, Object.assign({
17851
+ store: store$j
17852
+ }, props));
17853
+
17854
+ const IncludePhone = props => /*#__PURE__*/React__default['default'].createElement(Phone, Object.assign({
17855
+ store: store$j
17856
+ }, props));
17857
+
17739
17858
  /**
17740
17859
  *
17741
17860
  */
@@ -17755,7 +17874,10 @@ function PaymentMethodView({
17755
17874
  } = useTranslation("checkoutForm");
17756
17875
  const cardProcessor = getSiteCardProcessor();
17757
17876
  const supportsVantiv = Boolean((_window$Pelcro$site$r = window.Pelcro.site.read()) === null || _window$Pelcro$site$r === void 0 ? void 0 : _window$Pelcro$site$r.vantiv_gateway_settings);
17758
- Boolean((_window$Pelcro$site$r2 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r2 === void 0 ? void 0 : _window$Pelcro$site$r2.tap_gateway_settings);
17877
+ const supportsTap = Boolean((_window$Pelcro$site$r2 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r2 === void 0 ? void 0 : _window$Pelcro$site$r2.tap_gateway_settings);
17878
+ const isUserFirstName = Boolean(window.Pelcro.user.read().first_name);
17879
+ const isUserLastName = Boolean(window.Pelcro.user.read().last_name);
17880
+ const isUserPhone = Boolean(window.Pelcro.user.read().phone);
17759
17881
  return /*#__PURE__*/React__default['default'].createElement("div", {
17760
17882
  className: "plc-flex plc-flex-col plc-items-center plc-mt-4 sm:plc-px-8 pelcro-payment-block"
17761
17883
  }, cardProcessor === "stripe" && /*#__PURE__*/React__default['default'].createElement("div", {
@@ -17777,7 +17899,25 @@ function PaymentMethodView({
17777
17899
  onFailure: onFailure
17778
17900
  }, /*#__PURE__*/React__default['default'].createElement(BankRedirection, null), /*#__PURE__*/React__default['default'].createElement(AlertWithContext, {
17779
17901
  className: "plc-mb-2"
17780
- }), /*#__PURE__*/React__default['default'].createElement("div", null, /*#__PURE__*/React__default['default'].createElement(SelectedPaymentMethod, null), /*#__PURE__*/React__default['default'].createElement(CheckoutForm, null), showCoupon && /*#__PURE__*/React__default['default'].createElement("div", {
17902
+ }), /*#__PURE__*/React__default['default'].createElement("div", null, /*#__PURE__*/React__default['default'].createElement(SelectedPaymentMethod, null), supportsTap && (!isUserFirstName || !isUserLastName || !isUserPhone) && /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, null, /*#__PURE__*/React__default['default'].createElement("div", {
17903
+ className: "plc-flex plc-items-start"
17904
+ }, /*#__PURE__*/React__default['default'].createElement(IncludeFirstName, {
17905
+ id: "pelcro-input-first-name",
17906
+ label: t("labels.firstName"),
17907
+ errorId: "pelcro-input-firstName-error",
17908
+ required: true
17909
+ }), /*#__PURE__*/React__default['default'].createElement(IncludeLastName, {
17910
+ wrapperClassName: "plc-ml-3",
17911
+ id: "pelcro-input-last-name",
17912
+ label: t("labels.lastName"),
17913
+ errorId: "pelcro-input-lastName-error",
17914
+ required: true
17915
+ })), /*#__PURE__*/React__default['default'].createElement(IncludePhone, {
17916
+ id: "pelcro-input-phone",
17917
+ errorId: "pelcro-input-phone-error",
17918
+ label: t("labels.phone"),
17919
+ required: true
17920
+ })), /*#__PURE__*/React__default['default'].createElement(CheckoutForm, null), showCoupon && /*#__PURE__*/React__default['default'].createElement("div", {
17781
17921
  className: "plc-mb-2"
17782
17922
  }, /*#__PURE__*/React__default['default'].createElement(CouponCode, null), /*#__PURE__*/React__default['default'].createElement(DiscountedPrice, null)), /*#__PURE__*/React__default['default'].createElement(TaxAmount, null), /*#__PURE__*/React__default['default'].createElement("div", {
17783
17923
  className: "plc-grid plc-mt-4 plc-gap-y-2"
@@ -19531,30 +19671,16 @@ const UserUpdateButton = ({
19531
19671
  onClick,
19532
19672
  ...otherProps
19533
19673
  }) => {
19534
- var _window$Pelcro$site$r;
19535
-
19536
19674
  const {
19537
19675
  state: {
19538
19676
  buttonDisabled,
19539
- email,
19540
- firstName,
19541
- lastName,
19542
- phone,
19543
- emailError,
19544
- firstNameError,
19545
- lastNameError,
19546
- phoneError
19677
+ emailError
19547
19678
  },
19548
19679
  dispatch
19549
19680
  } = React.useContext(store$f);
19550
- const supportsTap = Boolean((_window$Pelcro$site$r = window.Pelcro.site.read()) === null || _window$Pelcro$site$r === void 0 ? void 0 : _window$Pelcro$site$r.tap_gateway_settings);
19551
19681
  const {
19552
19682
  t
19553
19683
  } = useTranslation("userEdit");
19554
- const [isDisabled, setDisabled] = React.useState(true);
19555
- React.useEffect(() => {
19556
- setDisabled(buttonDisabled || emailError || firstNameError || lastNameError || phoneError || !(email !== null && email !== void 0 && email.length) || supportsTap && !(firstName !== null && firstName !== void 0 && firstName.length) || supportsTap && !(lastName !== null && lastName !== void 0 && lastName.length) || supportsTap && !(phone !== null && phone !== void 0 && phone.length));
19557
- }, [email, firstName, lastName, phone, buttonDisabled, emailError, firstNameError, lastNameError, phoneError]);
19558
19684
  return /*#__PURE__*/React__default['default'].createElement(Button, Object.assign({
19559
19685
  onClick: () => {
19560
19686
  dispatch({
@@ -19562,7 +19688,7 @@ const UserUpdateButton = ({
19562
19688
  });
19563
19689
  onClick === null || onClick === void 0 ? void 0 : onClick();
19564
19690
  },
19565
- disabled: isDisabled,
19691
+ disabled: buttonDisabled || emailError,
19566
19692
  isLoading: buttonDisabled && !emailError
19567
19693
  }, otherProps), name !== null && name !== void 0 ? name : t("labels.submit"));
19568
19694
  };
@@ -19607,12 +19733,9 @@ const UserUpdateProfilePic = ({
19607
19733
  };
19608
19734
 
19609
19735
  const UserUpdateView = props => {
19610
- var _window$Pelcro$site$r;
19611
-
19612
19736
  const {
19613
19737
  t
19614
19738
  } = useTranslation("userEdit");
19615
- const supportsTap = Boolean((_window$Pelcro$site$r = window.Pelcro.site.read()) === null || _window$Pelcro$site$r === void 0 ? void 0 : _window$Pelcro$site$r.tap_gateway_settings);
19616
19739
  return /*#__PURE__*/React__default['default'].createElement("div", {
19617
19740
  id: "pelcro-user-update-view"
19618
19741
  }, /*#__PURE__*/React__default['default'].createElement("div", {
@@ -19631,22 +19754,19 @@ const UserUpdateView = props => {
19631
19754
  id: "pelcro-input-first-name",
19632
19755
  errorId: "pelcro-input-first-name-error",
19633
19756
  label: t("labels.firstName"),
19634
- autoFocus: true,
19635
- required: supportsTap ? true : false
19757
+ autoFocus: true
19636
19758
  }), /*#__PURE__*/React__default['default'].createElement(UserUpdateLastName, {
19637
19759
  wrapperClassName: "plc-ml-3",
19638
19760
  autoComplete: "last-name",
19639
19761
  id: "pelcro-input-last-name",
19640
19762
  errorId: "pelcro-input-last-name-error",
19641
- label: t("labels.lastName"),
19642
- required: supportsTap ? true : false
19763
+ label: t("labels.lastName")
19643
19764
  })), /*#__PURE__*/React__default['default'].createElement("div", {
19644
19765
  className: "plc-flex plc-items-start"
19645
19766
  }, /*#__PURE__*/React__default['default'].createElement(UserUpdatePhone, {
19646
19767
  id: "pelcro-input-phone",
19647
19768
  errorId: "pelcro-input-phone-error",
19648
- label: t("labels.phone"),
19649
- required: supportsTap ? true : false
19769
+ label: t("labels.phone")
19650
19770
  })), /*#__PURE__*/React__default['default'].createElement(UserUpdateButton, {
19651
19771
  role: "submit",
19652
19772
  className: "plc-w-full plc-mt-2",
@@ -22951,10 +23071,12 @@ const GiftCreateEmail = props => /*#__PURE__*/React__default['default'].createEl
22951
23071
  }, props));
22952
23072
 
22953
23073
  const GiftCreateFirstName = props => /*#__PURE__*/React__default['default'].createElement(FirstName, Object.assign({
23074
+ initWithUserFirstName: false,
22954
23075
  store: store$7
22955
23076
  }, props));
22956
23077
 
22957
23078
  const GiftCreateLastName = props => /*#__PURE__*/React__default['default'].createElement(LastName, Object.assign({
23079
+ initWithUserLastName: false,
22958
23080
  store: store$7
22959
23081
  }, props));
22960
23082
 
package/dist/index.esm.js CHANGED
@@ -3794,7 +3794,10 @@ var labels$F = {
3794
3794
  interval: "{{count}} {{interval}}",
3795
3795
  interval_plural: "{{count}} {{interval}}s",
3796
3796
  tax: "+ Tax",
3797
- removeCoupon: "REMOVE"
3797
+ removeCoupon: "REMOVE",
3798
+ firstName: "First name",
3799
+ lastName: "Last name",
3800
+ phone: "Phone"
3798
3801
  };
3799
3802
  var checkoutForm_en = {
3800
3803
  messages: messages$I,
@@ -3821,7 +3824,10 @@ var labels$E = {
3821
3824
  interval: "{{count}} {{interval}}",
3822
3825
  interval_plural: "{{count}} {{interval}}s",
3823
3826
  tax: "+ Taxe",
3824
- removeCoupon: "RETIRER"
3827
+ removeCoupon: "RETIRER",
3828
+ firstName: "Prénom",
3829
+ lastName: "Nom de famille",
3830
+ phone: "Téléphoner"
3825
3831
  };
3826
3832
  var checkoutForm_fr = {
3827
3833
  messages: messages$H,
@@ -3848,7 +3854,10 @@ var labels$D = {
3848
3854
  interval: "{{count}} {{interval}}",
3849
3855
  interval_plural: "{{count}} {{interval}}",
3850
3856
  tax: "+ 세금",
3851
- removeCoupon: "제거"
3857
+ removeCoupon: "제거",
3858
+ firstName: "이름",
3859
+ lastName: "성",
3860
+ phone: "핸드폰"
3852
3861
  };
3853
3862
  var checkoutForm_ko = {
3854
3863
  messages: messages$G,
@@ -12247,32 +12256,25 @@ const RegisterButton = ({
12247
12256
  className,
12248
12257
  ...otherProps
12249
12258
  }) => {
12250
- var _window$Pelcro$site$r, _window$Pelcro$site$r2;
12259
+ var _window$Pelcro$site$r;
12251
12260
 
12252
12261
  const {
12253
12262
  state: {
12254
12263
  emailError,
12255
12264
  passwordError,
12256
- firstNameError,
12257
- lastNameError,
12258
- phoneError,
12259
12265
  email,
12260
12266
  password,
12261
- firstName,
12262
- lastName,
12263
- phone,
12264
12267
  buttonDisabled
12265
12268
  },
12266
12269
  dispatch
12267
12270
  } = useContext(store$k);
12268
- const supportsTap = Boolean((_window$Pelcro$site$r = window.Pelcro.site.read()) === null || _window$Pelcro$site$r === void 0 ? void 0 : _window$Pelcro$site$r.tap_gateway_settings);
12269
12271
  const {
12270
12272
  t
12271
12273
  } = useTranslation("register");
12272
12274
  const [isDisabled, setDisabled] = useState(true);
12273
12275
  useEffect(() => {
12274
- setDisabled(buttonDisabled || emailError || passwordError || firstNameError || lastNameError || phoneError || !email.length || !password.length || supportsTap && !firstName.length || supportsTap && !lastName.length || supportsTap && !phone.length);
12275
- }, [buttonDisabled, emailError, passwordError, firstNameError, lastNameError, phoneError, email, password, firstName, lastName, phone]);
12276
+ setDisabled(buttonDisabled || emailError || passwordError || !email.length || !password.length);
12277
+ }, [buttonDisabled, emailError, passwordError, email, password]);
12276
12278
  return /*#__PURE__*/React__default.createElement(Button, Object.assign({
12277
12279
  onClick: () => {
12278
12280
  dispatch({
@@ -12284,11 +12286,12 @@ const RegisterButton = ({
12284
12286
  isLoading: buttonDisabled,
12285
12287
  className: `${className} g-recaptcha`,
12286
12288
  "data-action": "register",
12287
- "data-sitekey": (_window$Pelcro$site$r2 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r2 === void 0 ? void 0 : _window$Pelcro$site$r2.security_key
12289
+ "data-sitekey": (_window$Pelcro$site$r = window.Pelcro.site.read()) === null || _window$Pelcro$site$r === void 0 ? void 0 : _window$Pelcro$site$r.security_key
12288
12290
  }, otherProps), name !== null && name !== void 0 ? name : t("messages.createAccount"));
12289
12291
  };
12290
12292
 
12291
12293
  function FirstName({
12294
+ initWithUserFirstName = true,
12292
12295
  store,
12293
12296
  ...otherProps
12294
12297
  }) {
@@ -12321,7 +12324,23 @@ function FirstName({
12321
12324
  }, [dispatch, firstName, finishedTyping]);
12322
12325
  useEffect(() => {
12323
12326
  handleInputChange(firstName);
12324
- }, [finishedTyping, firstName, handleInputChange]);
12327
+ }, [finishedTyping, firstName, handleInputChange]); // Initialize first name field with user's first name
12328
+
12329
+ const loadFirstNameIntoField = () => {
12330
+ handleInputChange(window.Pelcro.user.read().first_name);
12331
+ };
12332
+
12333
+ useEffect(() => {
12334
+ if (initWithUserFirstName) {
12335
+ document.addEventListener("PelcroUserLoaded", () => {
12336
+ loadFirstNameIntoField();
12337
+ });
12338
+ loadFirstNameIntoField();
12339
+ return () => {
12340
+ document.removeEventListener("PelcroUserLoaded", handleInputChange);
12341
+ };
12342
+ }
12343
+ }, []);
12325
12344
  return /*#__PURE__*/React__default.createElement(Input, Object.assign({
12326
12345
  type: "text",
12327
12346
  error: firstNameError,
@@ -12337,6 +12356,7 @@ const RegisterFirstName = props => /*#__PURE__*/React__default.createElement(Fir
12337
12356
  }, props));
12338
12357
 
12339
12358
  function LastName({
12359
+ initWithUserLastName = true,
12340
12360
  store,
12341
12361
  ...otherProps
12342
12362
  }) {
@@ -12369,7 +12389,23 @@ function LastName({
12369
12389
  }, [dispatch, lastName, finishedTyping]);
12370
12390
  useEffect(() => {
12371
12391
  handleInputChange(lastName);
12372
- }, [finishedTyping, lastName, handleInputChange]);
12392
+ }, [finishedTyping, lastName, handleInputChange]); // Initialize last name field with user's last name
12393
+
12394
+ const loadLastNameIntoField = () => {
12395
+ handleInputChange(window.Pelcro.user.read().last_name);
12396
+ };
12397
+
12398
+ useEffect(() => {
12399
+ if (initWithUserLastName) {
12400
+ document.addEventListener("PelcroUserLoaded", () => {
12401
+ loadLastNameIntoField();
12402
+ });
12403
+ loadLastNameIntoField();
12404
+ return () => {
12405
+ document.removeEventListener("PelcroUserLoaded", handleInputChange);
12406
+ };
12407
+ }
12408
+ }, []);
12373
12409
  return /*#__PURE__*/React__default.createElement(Input, Object.assign({
12374
12410
  type: "text",
12375
12411
  error: lastNameError,
@@ -12385,6 +12421,7 @@ const RegisterLastName = props => /*#__PURE__*/React__default.createElement(Last
12385
12421
  }, props));
12386
12422
 
12387
12423
  function Phone({
12424
+ initWithUserPhone = true,
12388
12425
  store,
12389
12426
  ...otherProps
12390
12427
  }) {
@@ -12417,7 +12454,23 @@ function Phone({
12417
12454
  }, [dispatch, phone, finishedTyping]);
12418
12455
  useEffect(() => {
12419
12456
  handleInputChange(phone);
12420
- }, [finishedTyping, phone, handleInputChange]);
12457
+ }, [finishedTyping, phone, handleInputChange]); // Initialize phone field with user's phone
12458
+
12459
+ const loadPhoneIntoField = () => {
12460
+ handleInputChange(window.Pelcro.user.read().phone);
12461
+ };
12462
+
12463
+ useEffect(() => {
12464
+ if (initWithUserPhone) {
12465
+ document.addEventListener("PelcroUserLoaded", () => {
12466
+ loadPhoneIntoField();
12467
+ });
12468
+ loadPhoneIntoField();
12469
+ return () => {
12470
+ document.removeEventListener("PelcroUserLoaded", handleInputChange);
12471
+ };
12472
+ }
12473
+ }, []);
12421
12474
  return /*#__PURE__*/React__default.createElement(Input, Object.assign({
12422
12475
  type: "tel",
12423
12476
  error: phoneError,
@@ -12428,16 +12481,12 @@ function Phone({
12428
12481
  }, otherProps));
12429
12482
  }
12430
12483
 
12431
- const RegisterPhone = props => /*#__PURE__*/React__default.createElement(Phone, Object.assign({
12432
- store: store$k
12433
- }, props));
12434
-
12435
12484
  /**
12436
12485
  *
12437
12486
  */
12438
12487
 
12439
12488
  function RegisterView(props) {
12440
- var _product$paywall$regi, _product$paywall, _product$paywall$regi2, _product$paywall2, _window$Pelcro$site$r, _window$Pelcro$site$r2, _window$Pelcro$site$r3, _window$Pelcro, _window$Pelcro$uiSett, _window$Pelcro$site$r4;
12489
+ var _product$paywall$regi, _product$paywall, _product$paywall$regi2, _product$paywall2, _window$Pelcro$site$r, _window$Pelcro$site$r2, _window$Pelcro$site$r3, _window$Pelcro, _window$Pelcro$uiSett;
12441
12490
 
12442
12491
  const {
12443
12492
  t
@@ -12449,7 +12498,6 @@ function RegisterView(props) {
12449
12498
  const subtitle = (_product$paywall$regi2 = product === null || product === void 0 ? void 0 : (_product$paywall2 = product.paywall) === null || _product$paywall2 === void 0 ? void 0 : _product$paywall2.register_subtitle) !== null && _product$paywall$regi2 !== void 0 ? _product$paywall$regi2 : t("subtitle");
12450
12499
  const socialLoginEnabled = ((_window$Pelcro$site$r = window.Pelcro.site.read()) === null || _window$Pelcro$site$r === void 0 ? void 0 : _window$Pelcro$site$r.facebook_app_id) || ((_window$Pelcro$site$r2 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r2 === void 0 ? void 0 : _window$Pelcro$site$r2.google_app_id) || ((_window$Pelcro$site$r3 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r3 === void 0 ? void 0 : _window$Pelcro$site$r3.auth0_client_id);
12451
12500
  const showNameFields = (_window$Pelcro = window.Pelcro) === null || _window$Pelcro === void 0 ? void 0 : (_window$Pelcro$uiSett = _window$Pelcro.uiSettings) === null || _window$Pelcro$uiSett === void 0 ? void 0 : _window$Pelcro$uiSett.enableNameFieldsInRegister;
12452
- const supportsTap = Boolean((_window$Pelcro$site$r4 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r4 === void 0 ? void 0 : _window$Pelcro$site$r4.tap_gateway_settings);
12453
12501
  return /*#__PURE__*/React__default.createElement("div", {
12454
12502
  id: "pelcro-register-view"
12455
12503
  }, /*#__PURE__*/React__default.createElement("div", {
@@ -12459,25 +12507,18 @@ function RegisterView(props) {
12459
12507
  }, title), /*#__PURE__*/React__default.createElement("p", null, subtitle)), /*#__PURE__*/React__default.createElement("form", {
12460
12508
  action: "javascript:void(0);",
12461
12509
  className: "plc-mt-2 pelcro-form"
12462
- }, /*#__PURE__*/React__default.createElement(RegisterContainer, props, /*#__PURE__*/React__default.createElement(AlertWithContext, null), (showNameFields || supportsTap) && /*#__PURE__*/React__default.createElement("div", {
12510
+ }, /*#__PURE__*/React__default.createElement(RegisterContainer, props, /*#__PURE__*/React__default.createElement(AlertWithContext, null), showNameFields && /*#__PURE__*/React__default.createElement("div", {
12463
12511
  className: "plc-flex plc-items-start"
12464
12512
  }, /*#__PURE__*/React__default.createElement(RegisterFirstName, {
12465
12513
  id: "pelcro-input-first-name",
12466
12514
  label: t("labels.firstName"),
12467
- errorId: "pelcro-input-firstName-error",
12468
- required: supportsTap ? true : false
12515
+ errorId: "pelcro-input-firstName-error"
12469
12516
  }), /*#__PURE__*/React__default.createElement(RegisterLastName, {
12470
12517
  wrapperClassName: "plc-ml-3",
12471
12518
  id: "pelcro-input-last-name",
12472
12519
  label: t("labels.lastName"),
12473
- errorId: "pelcro-input-lastName-error",
12474
- required: supportsTap ? true : false
12475
- })), supportsTap && /*#__PURE__*/React__default.createElement(RegisterPhone, {
12476
- id: "pelcro-input-phone",
12477
- errorId: "pelcro-input-phone-error",
12478
- label: t("labels.phone"),
12479
- required: supportsTap ? true : false
12480
- }), /*#__PURE__*/React__default.createElement(RegisterEmail, {
12520
+ errorId: "pelcro-input-lastName-error"
12521
+ })), /*#__PURE__*/React__default.createElement(RegisterEmail, {
12481
12522
  id: "pelcro-input-email",
12482
12523
  errorId: "pelcro-input-email-error",
12483
12524
  label: t("labels.email"),
@@ -12523,9 +12564,9 @@ function RegisterView(props) {
12523
12564
  */
12524
12565
 
12525
12566
  function hasSecurityTokenEnabled() {
12526
- var _window$Pelcro$site, _window$Pelcro$site$r5;
12567
+ var _window$Pelcro$site, _window$Pelcro$site$r4;
12527
12568
 
12528
- return Boolean((_window$Pelcro$site = window.Pelcro.site) === null || _window$Pelcro$site === void 0 ? void 0 : (_window$Pelcro$site$r5 = _window$Pelcro$site.read()) === null || _window$Pelcro$site$r5 === void 0 ? void 0 : _window$Pelcro$site$r5.security_key);
12569
+ return Boolean((_window$Pelcro$site = window.Pelcro.site) === null || _window$Pelcro$site === void 0 ? void 0 : (_window$Pelcro$site$r4 = _window$Pelcro$site.read()) === null || _window$Pelcro$site$r4 === void 0 ? void 0 : _window$Pelcro$site$r4.security_key);
12529
12570
  }
12530
12571
 
12531
12572
  const Loader = props => /*#__PURE__*/React__default.createElement("div", {
@@ -15244,6 +15285,12 @@ const initialState$j = {
15244
15285
  updatedPrice: null,
15245
15286
  taxAmount: null,
15246
15287
  currentPlan: null,
15288
+ firstName: "",
15289
+ lastName: "",
15290
+ phone: "",
15291
+ firstNameError: null,
15292
+ lastNameError: null,
15293
+ phoneError: null,
15247
15294
  alert: {
15248
15295
  type: "error",
15249
15296
  content: ""
@@ -15360,8 +15407,14 @@ const PaymentMethodContainerWithoutStripe = ({
15360
15407
  }
15361
15408
  });
15362
15409
  } else {
15410
+ console.log("First Name", state.firstName);
15411
+ console.log("Last Name", state.lastName);
15412
+ console.log("Phone", state.phone);
15363
15413
  window.Pelcro.payment.authorize({
15364
15414
  auth_token: window.Pelcro.user.read().auth_token,
15415
+ first_name: window.Pelcro.user.read().first_name || state.firstName,
15416
+ last_name: window.Pelcro.user.read().last_name || state.lastName,
15417
+ phone: window.Pelcro.user.read().phone || state.phone,
15365
15418
  site_id: window.Pelcro.siteid,
15366
15419
  amount: totalAmount,
15367
15420
  currency: (plan === null || plan === void 0 ? void 0 : plan.currency) || (invoice === null || invoice === void 0 ? void 0 : invoice.currency) || window.Pelcro.site.read().default_currency,
@@ -16887,6 +16940,42 @@ const PaymentMethodContainerWithoutStripe = ({
16887
16940
  percentOff: action.payload
16888
16941
  });
16889
16942
 
16943
+ case SET_FIRST_NAME:
16944
+ return lib_7({ ...state,
16945
+ firstName: action.payload,
16946
+ firstNameError: null
16947
+ });
16948
+
16949
+ case SET_LAST_NAME:
16950
+ return lib_7({ ...state,
16951
+ lastName: action.payload,
16952
+ lastNameError: null
16953
+ });
16954
+
16955
+ case SET_PHONE:
16956
+ return lib_7({ ...state,
16957
+ phone: action.payload,
16958
+ phoneError: null
16959
+ });
16960
+
16961
+ case SET_FIRST_NAME_ERROR:
16962
+ return lib_7({ ...state,
16963
+ firstNameError: action.payload,
16964
+ firstName: ""
16965
+ });
16966
+
16967
+ case SET_LAST_NAME_ERROR:
16968
+ return lib_7({ ...state,
16969
+ lastNameError: action.payload,
16970
+ lastName: ""
16971
+ });
16972
+
16973
+ case SET_PHONE_ERROR:
16974
+ return lib_7({ ...state,
16975
+ phoneError: action.payload,
16976
+ phone: null
16977
+ });
16978
+
16890
16979
  case SHOW_ALERT:
16891
16980
  return lib_7({ ...state,
16892
16981
  alert: action.payload
@@ -17101,7 +17190,7 @@ const SubmitPaymentMethod = ({
17101
17190
  onClick,
17102
17191
  ...otherProps
17103
17192
  }) => {
17104
- var _plan$quantity;
17193
+ var _plan$quantity, _window$Pelcro$site$r;
17105
17194
 
17106
17195
  const {
17107
17196
  plan
@@ -17112,6 +17201,12 @@ const SubmitPaymentMethod = ({
17112
17201
  const {
17113
17202
  dispatch,
17114
17203
  state: {
17204
+ firstNameError,
17205
+ lastNameError,
17206
+ phoneError,
17207
+ firstName,
17208
+ lastName,
17209
+ phone,
17115
17210
  disableSubmit,
17116
17211
  isLoading,
17117
17212
  updatedPrice
@@ -17120,6 +17215,18 @@ const SubmitPaymentMethod = ({
17120
17215
  const planQuantity = (_plan$quantity = plan === null || plan === void 0 ? void 0 : plan.quantity) !== null && _plan$quantity !== void 0 ? _plan$quantity : 1;
17121
17216
  const price = updatedPrice !== null && updatedPrice !== void 0 ? updatedPrice : plan === null || plan === void 0 ? void 0 : plan.amount;
17122
17217
  const priceFormatted = getFormattedPriceByLocal(price * planQuantity, plan === null || plan === void 0 ? void 0 : plan.currency, getPageOrDefaultLanguage());
17218
+ const supportsTap = Boolean((_window$Pelcro$site$r = window.Pelcro.site.read()) === null || _window$Pelcro$site$r === void 0 ? void 0 : _window$Pelcro$site$r.tap_gateway_settings);
17219
+ const isUserFirstName = Boolean(window.Pelcro.user.read().first_name);
17220
+ const isUserLastName = Boolean(window.Pelcro.user.read().last_name);
17221
+ const isUserPhone = Boolean(window.Pelcro.user.read().phone);
17222
+ const [isDisabled, setDisabled] = useState(true);
17223
+ useEffect(() => {
17224
+ if (supportsTap && isUserFirstName && isUserLastName && isUserPhone) {
17225
+ setDisabled(disableSubmit);
17226
+ } else {
17227
+ setDisabled(disableSubmit || supportsTap && firstNameError || supportsTap && lastNameError || supportsTap && phoneError || supportsTap && !firstName.length || supportsTap && !lastName.length || supportsTap && !phone.length);
17228
+ }
17229
+ }, [disableSubmit, firstNameError, lastNameError, phoneError, firstName, lastName, phone]);
17123
17230
  return /*#__PURE__*/React__default.createElement(Button, Object.assign({
17124
17231
  role: "submit",
17125
17232
  className: "plc-w-full plc-py-3",
@@ -17131,7 +17238,7 @@ const SubmitPaymentMethod = ({
17131
17238
  });
17132
17239
  onClick === null || onClick === void 0 ? void 0 : onClick();
17133
17240
  },
17134
- disabled: disableSubmit
17241
+ disabled: isDisabled
17135
17242
  }, otherProps), plan ? /*#__PURE__*/React__default.createElement("span", {
17136
17243
  className: "plc-capitalize "
17137
17244
  }, t("labels.pay"), " ", priceFormatted && priceFormatted) : t("labels.submit"));
@@ -17706,6 +17813,18 @@ const TaxAmount = () => {
17706
17813
  return null;
17707
17814
  };
17708
17815
 
17816
+ const IncludeFirstName = props => /*#__PURE__*/React__default.createElement(FirstName, Object.assign({
17817
+ store: store$j
17818
+ }, props));
17819
+
17820
+ const IncludeLastName = props => /*#__PURE__*/React__default.createElement(LastName, Object.assign({
17821
+ store: store$j
17822
+ }, props));
17823
+
17824
+ const IncludePhone = props => /*#__PURE__*/React__default.createElement(Phone, Object.assign({
17825
+ store: store$j
17826
+ }, props));
17827
+
17709
17828
  /**
17710
17829
  *
17711
17830
  */
@@ -17725,7 +17844,10 @@ function PaymentMethodView({
17725
17844
  } = useTranslation("checkoutForm");
17726
17845
  const cardProcessor = getSiteCardProcessor();
17727
17846
  const supportsVantiv = Boolean((_window$Pelcro$site$r = window.Pelcro.site.read()) === null || _window$Pelcro$site$r === void 0 ? void 0 : _window$Pelcro$site$r.vantiv_gateway_settings);
17728
- Boolean((_window$Pelcro$site$r2 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r2 === void 0 ? void 0 : _window$Pelcro$site$r2.tap_gateway_settings);
17847
+ const supportsTap = Boolean((_window$Pelcro$site$r2 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r2 === void 0 ? void 0 : _window$Pelcro$site$r2.tap_gateway_settings);
17848
+ const isUserFirstName = Boolean(window.Pelcro.user.read().first_name);
17849
+ const isUserLastName = Boolean(window.Pelcro.user.read().last_name);
17850
+ const isUserPhone = Boolean(window.Pelcro.user.read().phone);
17729
17851
  return /*#__PURE__*/React__default.createElement("div", {
17730
17852
  className: "plc-flex plc-flex-col plc-items-center plc-mt-4 sm:plc-px-8 pelcro-payment-block"
17731
17853
  }, cardProcessor === "stripe" && /*#__PURE__*/React__default.createElement("div", {
@@ -17747,7 +17869,25 @@ function PaymentMethodView({
17747
17869
  onFailure: onFailure
17748
17870
  }, /*#__PURE__*/React__default.createElement(BankRedirection, null), /*#__PURE__*/React__default.createElement(AlertWithContext, {
17749
17871
  className: "plc-mb-2"
17750
- }), /*#__PURE__*/React__default.createElement("div", null, /*#__PURE__*/React__default.createElement(SelectedPaymentMethod, null), /*#__PURE__*/React__default.createElement(CheckoutForm, null), showCoupon && /*#__PURE__*/React__default.createElement("div", {
17872
+ }), /*#__PURE__*/React__default.createElement("div", null, /*#__PURE__*/React__default.createElement(SelectedPaymentMethod, null), supportsTap && (!isUserFirstName || !isUserLastName || !isUserPhone) && /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("div", {
17873
+ className: "plc-flex plc-items-start"
17874
+ }, /*#__PURE__*/React__default.createElement(IncludeFirstName, {
17875
+ id: "pelcro-input-first-name",
17876
+ label: t("labels.firstName"),
17877
+ errorId: "pelcro-input-firstName-error",
17878
+ required: true
17879
+ }), /*#__PURE__*/React__default.createElement(IncludeLastName, {
17880
+ wrapperClassName: "plc-ml-3",
17881
+ id: "pelcro-input-last-name",
17882
+ label: t("labels.lastName"),
17883
+ errorId: "pelcro-input-lastName-error",
17884
+ required: true
17885
+ })), /*#__PURE__*/React__default.createElement(IncludePhone, {
17886
+ id: "pelcro-input-phone",
17887
+ errorId: "pelcro-input-phone-error",
17888
+ label: t("labels.phone"),
17889
+ required: true
17890
+ })), /*#__PURE__*/React__default.createElement(CheckoutForm, null), showCoupon && /*#__PURE__*/React__default.createElement("div", {
17751
17891
  className: "plc-mb-2"
17752
17892
  }, /*#__PURE__*/React__default.createElement(CouponCode, null), /*#__PURE__*/React__default.createElement(DiscountedPrice, null)), /*#__PURE__*/React__default.createElement(TaxAmount, null), /*#__PURE__*/React__default.createElement("div", {
17753
17893
  className: "plc-grid plc-mt-4 plc-gap-y-2"
@@ -19501,30 +19641,16 @@ const UserUpdateButton = ({
19501
19641
  onClick,
19502
19642
  ...otherProps
19503
19643
  }) => {
19504
- var _window$Pelcro$site$r;
19505
-
19506
19644
  const {
19507
19645
  state: {
19508
19646
  buttonDisabled,
19509
- email,
19510
- firstName,
19511
- lastName,
19512
- phone,
19513
- emailError,
19514
- firstNameError,
19515
- lastNameError,
19516
- phoneError
19647
+ emailError
19517
19648
  },
19518
19649
  dispatch
19519
19650
  } = useContext(store$f);
19520
- const supportsTap = Boolean((_window$Pelcro$site$r = window.Pelcro.site.read()) === null || _window$Pelcro$site$r === void 0 ? void 0 : _window$Pelcro$site$r.tap_gateway_settings);
19521
19651
  const {
19522
19652
  t
19523
19653
  } = useTranslation("userEdit");
19524
- const [isDisabled, setDisabled] = useState(true);
19525
- useEffect(() => {
19526
- setDisabled(buttonDisabled || emailError || firstNameError || lastNameError || phoneError || !(email !== null && email !== void 0 && email.length) || supportsTap && !(firstName !== null && firstName !== void 0 && firstName.length) || supportsTap && !(lastName !== null && lastName !== void 0 && lastName.length) || supportsTap && !(phone !== null && phone !== void 0 && phone.length));
19527
- }, [email, firstName, lastName, phone, buttonDisabled, emailError, firstNameError, lastNameError, phoneError]);
19528
19654
  return /*#__PURE__*/React__default.createElement(Button, Object.assign({
19529
19655
  onClick: () => {
19530
19656
  dispatch({
@@ -19532,7 +19658,7 @@ const UserUpdateButton = ({
19532
19658
  });
19533
19659
  onClick === null || onClick === void 0 ? void 0 : onClick();
19534
19660
  },
19535
- disabled: isDisabled,
19661
+ disabled: buttonDisabled || emailError,
19536
19662
  isLoading: buttonDisabled && !emailError
19537
19663
  }, otherProps), name !== null && name !== void 0 ? name : t("labels.submit"));
19538
19664
  };
@@ -19577,12 +19703,9 @@ const UserUpdateProfilePic = ({
19577
19703
  };
19578
19704
 
19579
19705
  const UserUpdateView = props => {
19580
- var _window$Pelcro$site$r;
19581
-
19582
19706
  const {
19583
19707
  t
19584
19708
  } = useTranslation("userEdit");
19585
- const supportsTap = Boolean((_window$Pelcro$site$r = window.Pelcro.site.read()) === null || _window$Pelcro$site$r === void 0 ? void 0 : _window$Pelcro$site$r.tap_gateway_settings);
19586
19709
  return /*#__PURE__*/React__default.createElement("div", {
19587
19710
  id: "pelcro-user-update-view"
19588
19711
  }, /*#__PURE__*/React__default.createElement("div", {
@@ -19601,22 +19724,19 @@ const UserUpdateView = props => {
19601
19724
  id: "pelcro-input-first-name",
19602
19725
  errorId: "pelcro-input-first-name-error",
19603
19726
  label: t("labels.firstName"),
19604
- autoFocus: true,
19605
- required: supportsTap ? true : false
19727
+ autoFocus: true
19606
19728
  }), /*#__PURE__*/React__default.createElement(UserUpdateLastName, {
19607
19729
  wrapperClassName: "plc-ml-3",
19608
19730
  autoComplete: "last-name",
19609
19731
  id: "pelcro-input-last-name",
19610
19732
  errorId: "pelcro-input-last-name-error",
19611
- label: t("labels.lastName"),
19612
- required: supportsTap ? true : false
19733
+ label: t("labels.lastName")
19613
19734
  })), /*#__PURE__*/React__default.createElement("div", {
19614
19735
  className: "plc-flex plc-items-start"
19615
19736
  }, /*#__PURE__*/React__default.createElement(UserUpdatePhone, {
19616
19737
  id: "pelcro-input-phone",
19617
19738
  errorId: "pelcro-input-phone-error",
19618
- label: t("labels.phone"),
19619
- required: supportsTap ? true : false
19739
+ label: t("labels.phone")
19620
19740
  })), /*#__PURE__*/React__default.createElement(UserUpdateButton, {
19621
19741
  role: "submit",
19622
19742
  className: "plc-w-full plc-mt-2",
@@ -22921,10 +23041,12 @@ const GiftCreateEmail = props => /*#__PURE__*/React__default.createElement(Email
22921
23041
  }, props));
22922
23042
 
22923
23043
  const GiftCreateFirstName = props => /*#__PURE__*/React__default.createElement(FirstName, Object.assign({
23044
+ initWithUserFirstName: false,
22924
23045
  store: store$7
22925
23046
  }, props));
22926
23047
 
22927
23048
  const GiftCreateLastName = props => /*#__PURE__*/React__default.createElement(LastName, Object.assign({
23049
+ initWithUserLastName: false,
22928
23050
  store: store$7
22929
23051
  }, props));
22930
23052
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pelcro/react-pelcro-js",
3
3
  "description": "Pelcro's React UI Elements",
4
- "version": "3.9.0-beta.1",
4
+ "version": "3.9.0-beta.3",
5
5
  "license": "MIT",
6
6
  "private": false,
7
7
  "main": "dist/index.cjs.js",