@pelcro/react-pelcro-js 4.0.0-alpha.4 → 4.0.0-alpha.6

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
@@ -4395,7 +4395,8 @@ var labels$t = {
4395
4395
  save: "Upload Photo",
4396
4396
  selectImage: "Upload new photo",
4397
4397
  removeImage: "Remove current photo",
4398
- zoom: "Zoom"
4398
+ zoom: "Zoom",
4399
+ tin: "Tax Identification Number"
4399
4400
  };
4400
4401
  var messages$w = {
4401
4402
  userUpdated: "Thanks! Your profile was updated successfully.",
@@ -4421,7 +4422,8 @@ var labels$s = {
4421
4422
  save: "Téléverser une photo",
4422
4423
  selectImage: "Télécharger une nouvelle photo",
4423
4424
  removeImage: "supprimer la photo actuelle",
4424
- zoom: "Zoom"
4425
+ zoom: "Zoom",
4426
+ tin: "Numéro d'identification fiscale"
4425
4427
  };
4426
4428
  var messages$v = {
4427
4429
  userUpdated: "Votre profil a été mis à jour avec succès.",
@@ -4447,7 +4449,8 @@ var labels$r = {
4447
4449
  save: "사진 업로드",
4448
4450
  selectImage: "새로운 사진 업로드",
4449
4451
  removeImage: "기존 사진 제거",
4450
- zoom: "확대"
4452
+ zoom: "확대",
4453
+ tin: "세금 식별 번호"
4451
4454
  };
4452
4455
  var messages$u = {
4453
4456
  userUpdated: "감사합니다! 프로필이 성공적으로 업데이트되었습니다.",
@@ -11695,6 +11698,7 @@ const SET_LAST_NAME = "SET_LAST_NAME";
11695
11698
  const SET_START_DATE = "SET_START_DATE";
11696
11699
  const SET_GIFT_MESSAGE = "SET_GIFT_MESSAGE";
11697
11700
  const SET_PHONE = "SET_PHONE";
11701
+ const SET_TIN = "SET_TIN";
11698
11702
  const GET_COUNTRIES_SUCCESS = "GET_COUNTRIES_SUCCESS";
11699
11703
  const GET_COUNTRIES_FETCH = "GET_COUNTRIES_FETCH";
11700
11704
  const GET_STATES_SUCCESS = "GET_STATES_SUCCESS";
@@ -15317,6 +15321,10 @@ class SelectModal extends React.Component {
15317
15321
  });
15318
15322
  }
15319
15323
 
15324
+ if (this.state.productList.length === 0 && !window.Pelcro.user.isAuthenticated()) {
15325
+ this.props.setView('register');
15326
+ }
15327
+
15320
15328
  document.addEventListener("keydown", this.handleSubmit);
15321
15329
  });
15322
15330
 
@@ -21916,7 +21924,7 @@ function SubscriptionCreateModal({
21916
21924
  }
21917
21925
  SubscriptionCreateModal.viewId = "subscription-create";
21918
21926
 
21919
- var _window$Pelcro$user$r, _window$Pelcro$user$r2, _window$Pelcro$user$r3, _window$Pelcro$user$r4, _window$Pelcro$user$r5;
21927
+ var _window$Pelcro$user$r, _window$Pelcro$user$r2, _window$Pelcro$user$r3, _window$Pelcro$user$r4, _window$Pelcro$user$r5, _window$Pelcro$user$r6;
21920
21928
  const initialState$f = {
21921
21929
  email: (_window$Pelcro$user$r = window.Pelcro.user.read()) === null || _window$Pelcro$user$r === void 0 ? void 0 : _window$Pelcro$user$r.email,
21922
21930
  emailError: null,
@@ -21927,6 +21935,7 @@ const initialState$f = {
21927
21935
  displayName: (_window$Pelcro$user$r4 = window.Pelcro.user.read()) === null || _window$Pelcro$user$r4 === void 0 ? void 0 : _window$Pelcro$user$r4.display_name,
21928
21936
  phone: (_window$Pelcro$user$r5 = window.Pelcro.user.read()) === null || _window$Pelcro$user$r5 === void 0 ? void 0 : _window$Pelcro$user$r5.phone,
21929
21937
  phoneError: null,
21938
+ tin: (_window$Pelcro$user$r6 = window.Pelcro.user.read()) === null || _window$Pelcro$user$r6 === void 0 ? void 0 : _window$Pelcro$user$r6.tin,
21930
21939
  buttonDisabled: false,
21931
21940
  textFields: {},
21932
21941
  alert: {
@@ -21957,23 +21966,26 @@ const UserUpdateContainer = ({
21957
21966
  }, []);
21958
21967
 
21959
21968
  const loadUserDataIntoFields = () => {
21960
- var _window$Pelcro$user$r6, _window$Pelcro$user$r7, _window$Pelcro$user$r8, _window$Pelcro$user$r9, _window$Pelcro$user$r10;
21969
+ var _window$Pelcro$user$r7, _window$Pelcro$user$r8, _window$Pelcro$user$r9, _window$Pelcro$user$r10, _window$Pelcro$user$r11, _window$Pelcro$user$r12;
21961
21970
 
21962
21971
  const fields = [{
21963
21972
  type: SET_EMAIL,
21964
- payload: (_window$Pelcro$user$r6 = window.Pelcro.user.read()) === null || _window$Pelcro$user$r6 === void 0 ? void 0 : _window$Pelcro$user$r6.email
21973
+ payload: (_window$Pelcro$user$r7 = window.Pelcro.user.read()) === null || _window$Pelcro$user$r7 === void 0 ? void 0 : _window$Pelcro$user$r7.email
21965
21974
  }, {
21966
21975
  type: SET_FIRST_NAME,
21967
- payload: (_window$Pelcro$user$r7 = window.Pelcro.user.read()) === null || _window$Pelcro$user$r7 === void 0 ? void 0 : _window$Pelcro$user$r7.first_name
21976
+ payload: (_window$Pelcro$user$r8 = window.Pelcro.user.read()) === null || _window$Pelcro$user$r8 === void 0 ? void 0 : _window$Pelcro$user$r8.first_name
21968
21977
  }, {
21969
21978
  type: SET_LAST_NAME,
21970
- payload: (_window$Pelcro$user$r8 = window.Pelcro.user.read()) === null || _window$Pelcro$user$r8 === void 0 ? void 0 : _window$Pelcro$user$r8.last_name
21979
+ payload: (_window$Pelcro$user$r9 = window.Pelcro.user.read()) === null || _window$Pelcro$user$r9 === void 0 ? void 0 : _window$Pelcro$user$r9.last_name
21971
21980
  }, {
21972
21981
  type: SET_DISPLAY_NAME,
21973
- payload: (_window$Pelcro$user$r9 = window.Pelcro.user.read()) === null || _window$Pelcro$user$r9 === void 0 ? void 0 : _window$Pelcro$user$r9.display_name
21982
+ payload: (_window$Pelcro$user$r10 = window.Pelcro.user.read()) === null || _window$Pelcro$user$r10 === void 0 ? void 0 : _window$Pelcro$user$r10.display_name
21974
21983
  }, {
21975
21984
  type: SET_PHONE,
21976
- payload: (_window$Pelcro$user$r10 = window.Pelcro.user.read()) === null || _window$Pelcro$user$r10 === void 0 ? void 0 : _window$Pelcro$user$r10.phone
21985
+ payload: (_window$Pelcro$user$r11 = window.Pelcro.user.read()) === null || _window$Pelcro$user$r11 === void 0 ? void 0 : _window$Pelcro$user$r11.phone
21986
+ }, {
21987
+ type: SET_TIN,
21988
+ payload: (_window$Pelcro$user$r12 = window.Pelcro.user.read()) === null || _window$Pelcro$user$r12 === void 0 ? void 0 : _window$Pelcro$user$r12.tin
21977
21989
  }];
21978
21990
  fields.filter(field => Boolean(field.payload)).forEach(field => {
21979
21991
  dispatch(field);
@@ -21985,6 +21997,7 @@ const UserUpdateContainer = ({
21985
21997
  firstName,
21986
21998
  lastName,
21987
21999
  phone,
22000
+ tin,
21988
22001
  textFields,
21989
22002
  displayName
21990
22003
  }, dispatch) => {
@@ -21995,6 +22008,7 @@ const UserUpdateContainer = ({
21995
22008
  last_name: lastName,
21996
22009
  display_name: displayName,
21997
22010
  phone: phone,
22011
+ tin: tin,
21998
22012
  metadata: {
21999
22013
  updated: "updated",
22000
22014
  ...textFields
@@ -22083,6 +22097,11 @@ const UserUpdateContainer = ({
22083
22097
  phoneError: null
22084
22098
  });
22085
22099
 
22100
+ case SET_TIN:
22101
+ return lib_7({ ...state,
22102
+ tin: action.payload
22103
+ });
22104
+
22086
22105
  case SET_PHONE_ERROR:
22087
22106
  return lib_7({ ...state,
22088
22107
  phoneError: action.payload,
@@ -22267,6 +22286,66 @@ const UserUpdateProfilePic = ({
22267
22286
  })));
22268
22287
  };
22269
22288
 
22289
+ function Tin({
22290
+ initWithUserTin = true,
22291
+ store,
22292
+ ...otherProps
22293
+ }) {
22294
+ useTranslation$1("common");
22295
+ const {
22296
+ dispatch,
22297
+ state: {
22298
+ tin: stateTin
22299
+ }
22300
+ } = React.useContext(store);
22301
+ const [tin, setTin] = React.useState(stateTin);
22302
+ const [finishedTyping, setFinishedTyping] = React.useState(false);
22303
+ const handleInputChange = React.useCallback(value => {
22304
+ setTin(value);
22305
+
22306
+ if (finishedTyping) {
22307
+ dispatch({
22308
+ type: SET_TIN,
22309
+ payload: tin
22310
+ });
22311
+ }
22312
+ }, [dispatch, tin, finishedTyping]);
22313
+ React.useEffect(() => {
22314
+ handleInputChange(tin);
22315
+ }, [finishedTyping, tin, handleInputChange]); // Initialize tin field with user's tin (Tax Identification Number)
22316
+
22317
+ const loadTinIntoField = () => {
22318
+ handleInputChange(window.Pelcro.user.read().tin);
22319
+ dispatch({
22320
+ type: SET_TIN,
22321
+ payload: window.Pelcro.user.read().tin
22322
+ });
22323
+ };
22324
+
22325
+ React.useEffect(() => {
22326
+ if (initWithUserTin) {
22327
+ document.addEventListener("PelcroUserLoaded", () => {
22328
+ loadTinIntoField();
22329
+ });
22330
+ loadTinIntoField();
22331
+ return () => {
22332
+ document.removeEventListener("PelcroUserLoaded", handleInputChange);
22333
+ };
22334
+ }
22335
+ }, []);
22336
+ return /*#__PURE__*/React__default['default'].createElement(Input, Object.assign({
22337
+ type: "text",
22338
+ value: tin,
22339
+ onChange: e => handleInputChange(e.target.value),
22340
+ onBlur: () => setFinishedTyping(true),
22341
+ onFocus: () => setFinishedTyping(false)
22342
+ }, otherProps));
22343
+ }
22344
+
22345
+ const UserUpdateTin = props => /*#__PURE__*/React__default['default'].createElement(Tin, Object.assign({
22346
+ store: store$f
22347
+ }, props));
22348
+
22270
22349
  const UserUpdateView = props => {
22271
22350
  var _window$Pelcro$site$r;
22272
22351
 
@@ -22304,6 +22383,11 @@ const UserUpdateView = props => {
22304
22383
  errorId: "pelcro-input-phone-error",
22305
22384
  label: t("labels.phone"),
22306
22385
  required: supportsTap ? true : false
22386
+ })), /*#__PURE__*/React__default['default'].createElement("div", {
22387
+ className: "plc-flex plc-items-start"
22388
+ }, /*#__PURE__*/React__default['default'].createElement(UserUpdateTin, {
22389
+ id: "pelcro-input-tin",
22390
+ label: t("labels.tin")
22307
22391
  })), /*#__PURE__*/React__default['default'].createElement(UserUpdateButton, {
22308
22392
  role: "submit",
22309
22393
  className: "plc-w-full plc-mt-2",
@@ -28355,14 +28439,14 @@ const SubscriptionsItems = ({
28355
28439
  onClick: onRenewClick,
28356
28440
  disabled: disableSubmit,
28357
28441
  "data-key": sub.id
28358
- }, t("labels.renew")), sub.shipments_suspended_until && sub.shipments_remaining > 0 && /*#__PURE__*/React__default['default'].createElement(Button$1, {
28442
+ }, t("labels.renew")), sub.shipments_suspended_until && isDateAfterToday(sub.shipments_suspended_until) && sub.shipments_remaining > 0 && /*#__PURE__*/React__default['default'].createElement(Button$1, {
28359
28443
  variant: "ghost",
28360
28444
  className: "plc-text-blue-400 pelcro-dashboard-sub-suspend-button",
28361
28445
  icon: /*#__PURE__*/React__default['default'].createElement(SvgXIconSolid, null),
28362
28446
  onClick: onUnSuspendClick,
28363
28447
  disabled: disableSubmit,
28364
28448
  "data-key": sub.id
28365
- }, t("labels.unsuspend")), !sub.shipments_suspended_until && sub.shipments_remaining > 0 && /*#__PURE__*/React__default['default'].createElement(Button$1, {
28449
+ }, t("labels.unsuspend")), (!sub.shipments_suspended_until && sub.shipments_remaining > 0 || sub.shipments_suspended_until && !isDateAfterToday(sub.shipments_suspended_until)) && /*#__PURE__*/React__default['default'].createElement(Button$1, {
28366
28450
  variant: "ghost",
28367
28451
  className: "plc-text-red-500 focus:plc-ring-red-500 pelcro-dashboard-sub-suspend-button",
28368
28452
  icon: /*#__PURE__*/React__default['default'].createElement(SvgCalendar, null),
@@ -28422,6 +28506,12 @@ function getNonDonationSubs() {
28422
28506
  return (_window$Pelcro$subscr = (_window$Pelcro$subscr2 = window.Pelcro.subscription) === null || _window$Pelcro$subscr2 === void 0 ? void 0 : (_window$Pelcro$subscr3 = _window$Pelcro$subscr2.list()) === null || _window$Pelcro$subscr3 === void 0 ? void 0 : _window$Pelcro$subscr3.filter(sub => !sub.plan.is_donation)) !== null && _window$Pelcro$subscr !== void 0 ? _window$Pelcro$subscr : [];
28423
28507
  }
28424
28508
 
28509
+ function isDateAfterToday(date) {
28510
+ const today = new Date().setHours(0, 0, 0, 0);
28511
+ const newDate = new Date(date).setHours(0, 0, 0, 0);
28512
+ return newDate === today ? true : newDate > today;
28513
+ }
28514
+
28425
28515
  /**
28426
28516
  * @typedef {Object} AccordionPropsType
28427
28517
  * @property {string} initialActiveMenu the initial active menu
package/dist/index.esm.js CHANGED
@@ -4365,7 +4365,8 @@ var labels$t = {
4365
4365
  save: "Upload Photo",
4366
4366
  selectImage: "Upload new photo",
4367
4367
  removeImage: "Remove current photo",
4368
- zoom: "Zoom"
4368
+ zoom: "Zoom",
4369
+ tin: "Tax Identification Number"
4369
4370
  };
4370
4371
  var messages$w = {
4371
4372
  userUpdated: "Thanks! Your profile was updated successfully.",
@@ -4391,7 +4392,8 @@ var labels$s = {
4391
4392
  save: "Téléverser une photo",
4392
4393
  selectImage: "Télécharger une nouvelle photo",
4393
4394
  removeImage: "supprimer la photo actuelle",
4394
- zoom: "Zoom"
4395
+ zoom: "Zoom",
4396
+ tin: "Numéro d'identification fiscale"
4395
4397
  };
4396
4398
  var messages$v = {
4397
4399
  userUpdated: "Votre profil a été mis à jour avec succès.",
@@ -4417,7 +4419,8 @@ var labels$r = {
4417
4419
  save: "사진 업로드",
4418
4420
  selectImage: "새로운 사진 업로드",
4419
4421
  removeImage: "기존 사진 제거",
4420
- zoom: "확대"
4422
+ zoom: "확대",
4423
+ tin: "세금 식별 번호"
4421
4424
  };
4422
4425
  var messages$u = {
4423
4426
  userUpdated: "감사합니다! 프로필이 성공적으로 업데이트되었습니다.",
@@ -11665,6 +11668,7 @@ const SET_LAST_NAME = "SET_LAST_NAME";
11665
11668
  const SET_START_DATE = "SET_START_DATE";
11666
11669
  const SET_GIFT_MESSAGE = "SET_GIFT_MESSAGE";
11667
11670
  const SET_PHONE = "SET_PHONE";
11671
+ const SET_TIN = "SET_TIN";
11668
11672
  const GET_COUNTRIES_SUCCESS = "GET_COUNTRIES_SUCCESS";
11669
11673
  const GET_COUNTRIES_FETCH = "GET_COUNTRIES_FETCH";
11670
11674
  const GET_STATES_SUCCESS = "GET_STATES_SUCCESS";
@@ -15287,6 +15291,10 @@ class SelectModal extends Component {
15287
15291
  });
15288
15292
  }
15289
15293
 
15294
+ if (this.state.productList.length === 0 && !window.Pelcro.user.isAuthenticated()) {
15295
+ this.props.setView('register');
15296
+ }
15297
+
15290
15298
  document.addEventListener("keydown", this.handleSubmit);
15291
15299
  });
15292
15300
 
@@ -21886,7 +21894,7 @@ function SubscriptionCreateModal({
21886
21894
  }
21887
21895
  SubscriptionCreateModal.viewId = "subscription-create";
21888
21896
 
21889
- var _window$Pelcro$user$r, _window$Pelcro$user$r2, _window$Pelcro$user$r3, _window$Pelcro$user$r4, _window$Pelcro$user$r5;
21897
+ var _window$Pelcro$user$r, _window$Pelcro$user$r2, _window$Pelcro$user$r3, _window$Pelcro$user$r4, _window$Pelcro$user$r5, _window$Pelcro$user$r6;
21890
21898
  const initialState$f = {
21891
21899
  email: (_window$Pelcro$user$r = window.Pelcro.user.read()) === null || _window$Pelcro$user$r === void 0 ? void 0 : _window$Pelcro$user$r.email,
21892
21900
  emailError: null,
@@ -21897,6 +21905,7 @@ const initialState$f = {
21897
21905
  displayName: (_window$Pelcro$user$r4 = window.Pelcro.user.read()) === null || _window$Pelcro$user$r4 === void 0 ? void 0 : _window$Pelcro$user$r4.display_name,
21898
21906
  phone: (_window$Pelcro$user$r5 = window.Pelcro.user.read()) === null || _window$Pelcro$user$r5 === void 0 ? void 0 : _window$Pelcro$user$r5.phone,
21899
21907
  phoneError: null,
21908
+ tin: (_window$Pelcro$user$r6 = window.Pelcro.user.read()) === null || _window$Pelcro$user$r6 === void 0 ? void 0 : _window$Pelcro$user$r6.tin,
21900
21909
  buttonDisabled: false,
21901
21910
  textFields: {},
21902
21911
  alert: {
@@ -21927,23 +21936,26 @@ const UserUpdateContainer = ({
21927
21936
  }, []);
21928
21937
 
21929
21938
  const loadUserDataIntoFields = () => {
21930
- var _window$Pelcro$user$r6, _window$Pelcro$user$r7, _window$Pelcro$user$r8, _window$Pelcro$user$r9, _window$Pelcro$user$r10;
21939
+ var _window$Pelcro$user$r7, _window$Pelcro$user$r8, _window$Pelcro$user$r9, _window$Pelcro$user$r10, _window$Pelcro$user$r11, _window$Pelcro$user$r12;
21931
21940
 
21932
21941
  const fields = [{
21933
21942
  type: SET_EMAIL,
21934
- payload: (_window$Pelcro$user$r6 = window.Pelcro.user.read()) === null || _window$Pelcro$user$r6 === void 0 ? void 0 : _window$Pelcro$user$r6.email
21943
+ payload: (_window$Pelcro$user$r7 = window.Pelcro.user.read()) === null || _window$Pelcro$user$r7 === void 0 ? void 0 : _window$Pelcro$user$r7.email
21935
21944
  }, {
21936
21945
  type: SET_FIRST_NAME,
21937
- payload: (_window$Pelcro$user$r7 = window.Pelcro.user.read()) === null || _window$Pelcro$user$r7 === void 0 ? void 0 : _window$Pelcro$user$r7.first_name
21946
+ payload: (_window$Pelcro$user$r8 = window.Pelcro.user.read()) === null || _window$Pelcro$user$r8 === void 0 ? void 0 : _window$Pelcro$user$r8.first_name
21938
21947
  }, {
21939
21948
  type: SET_LAST_NAME,
21940
- payload: (_window$Pelcro$user$r8 = window.Pelcro.user.read()) === null || _window$Pelcro$user$r8 === void 0 ? void 0 : _window$Pelcro$user$r8.last_name
21949
+ payload: (_window$Pelcro$user$r9 = window.Pelcro.user.read()) === null || _window$Pelcro$user$r9 === void 0 ? void 0 : _window$Pelcro$user$r9.last_name
21941
21950
  }, {
21942
21951
  type: SET_DISPLAY_NAME,
21943
- payload: (_window$Pelcro$user$r9 = window.Pelcro.user.read()) === null || _window$Pelcro$user$r9 === void 0 ? void 0 : _window$Pelcro$user$r9.display_name
21952
+ payload: (_window$Pelcro$user$r10 = window.Pelcro.user.read()) === null || _window$Pelcro$user$r10 === void 0 ? void 0 : _window$Pelcro$user$r10.display_name
21944
21953
  }, {
21945
21954
  type: SET_PHONE,
21946
- payload: (_window$Pelcro$user$r10 = window.Pelcro.user.read()) === null || _window$Pelcro$user$r10 === void 0 ? void 0 : _window$Pelcro$user$r10.phone
21955
+ payload: (_window$Pelcro$user$r11 = window.Pelcro.user.read()) === null || _window$Pelcro$user$r11 === void 0 ? void 0 : _window$Pelcro$user$r11.phone
21956
+ }, {
21957
+ type: SET_TIN,
21958
+ payload: (_window$Pelcro$user$r12 = window.Pelcro.user.read()) === null || _window$Pelcro$user$r12 === void 0 ? void 0 : _window$Pelcro$user$r12.tin
21947
21959
  }];
21948
21960
  fields.filter(field => Boolean(field.payload)).forEach(field => {
21949
21961
  dispatch(field);
@@ -21955,6 +21967,7 @@ const UserUpdateContainer = ({
21955
21967
  firstName,
21956
21968
  lastName,
21957
21969
  phone,
21970
+ tin,
21958
21971
  textFields,
21959
21972
  displayName
21960
21973
  }, dispatch) => {
@@ -21965,6 +21978,7 @@ const UserUpdateContainer = ({
21965
21978
  last_name: lastName,
21966
21979
  display_name: displayName,
21967
21980
  phone: phone,
21981
+ tin: tin,
21968
21982
  metadata: {
21969
21983
  updated: "updated",
21970
21984
  ...textFields
@@ -22053,6 +22067,11 @@ const UserUpdateContainer = ({
22053
22067
  phoneError: null
22054
22068
  });
22055
22069
 
22070
+ case SET_TIN:
22071
+ return lib_7({ ...state,
22072
+ tin: action.payload
22073
+ });
22074
+
22056
22075
  case SET_PHONE_ERROR:
22057
22076
  return lib_7({ ...state,
22058
22077
  phoneError: action.payload,
@@ -22237,6 +22256,66 @@ const UserUpdateProfilePic = ({
22237
22256
  })));
22238
22257
  };
22239
22258
 
22259
+ function Tin({
22260
+ initWithUserTin = true,
22261
+ store,
22262
+ ...otherProps
22263
+ }) {
22264
+ useTranslation$1("common");
22265
+ const {
22266
+ dispatch,
22267
+ state: {
22268
+ tin: stateTin
22269
+ }
22270
+ } = useContext(store);
22271
+ const [tin, setTin] = useState(stateTin);
22272
+ const [finishedTyping, setFinishedTyping] = useState(false);
22273
+ const handleInputChange = useCallback(value => {
22274
+ setTin(value);
22275
+
22276
+ if (finishedTyping) {
22277
+ dispatch({
22278
+ type: SET_TIN,
22279
+ payload: tin
22280
+ });
22281
+ }
22282
+ }, [dispatch, tin, finishedTyping]);
22283
+ useEffect(() => {
22284
+ handleInputChange(tin);
22285
+ }, [finishedTyping, tin, handleInputChange]); // Initialize tin field with user's tin (Tax Identification Number)
22286
+
22287
+ const loadTinIntoField = () => {
22288
+ handleInputChange(window.Pelcro.user.read().tin);
22289
+ dispatch({
22290
+ type: SET_TIN,
22291
+ payload: window.Pelcro.user.read().tin
22292
+ });
22293
+ };
22294
+
22295
+ useEffect(() => {
22296
+ if (initWithUserTin) {
22297
+ document.addEventListener("PelcroUserLoaded", () => {
22298
+ loadTinIntoField();
22299
+ });
22300
+ loadTinIntoField();
22301
+ return () => {
22302
+ document.removeEventListener("PelcroUserLoaded", handleInputChange);
22303
+ };
22304
+ }
22305
+ }, []);
22306
+ return /*#__PURE__*/React__default.createElement(Input, Object.assign({
22307
+ type: "text",
22308
+ value: tin,
22309
+ onChange: e => handleInputChange(e.target.value),
22310
+ onBlur: () => setFinishedTyping(true),
22311
+ onFocus: () => setFinishedTyping(false)
22312
+ }, otherProps));
22313
+ }
22314
+
22315
+ const UserUpdateTin = props => /*#__PURE__*/React__default.createElement(Tin, Object.assign({
22316
+ store: store$f
22317
+ }, props));
22318
+
22240
22319
  const UserUpdateView = props => {
22241
22320
  var _window$Pelcro$site$r;
22242
22321
 
@@ -22274,6 +22353,11 @@ const UserUpdateView = props => {
22274
22353
  errorId: "pelcro-input-phone-error",
22275
22354
  label: t("labels.phone"),
22276
22355
  required: supportsTap ? true : false
22356
+ })), /*#__PURE__*/React__default.createElement("div", {
22357
+ className: "plc-flex plc-items-start"
22358
+ }, /*#__PURE__*/React__default.createElement(UserUpdateTin, {
22359
+ id: "pelcro-input-tin",
22360
+ label: t("labels.tin")
22277
22361
  })), /*#__PURE__*/React__default.createElement(UserUpdateButton, {
22278
22362
  role: "submit",
22279
22363
  className: "plc-w-full plc-mt-2",
@@ -28325,14 +28409,14 @@ const SubscriptionsItems = ({
28325
28409
  onClick: onRenewClick,
28326
28410
  disabled: disableSubmit,
28327
28411
  "data-key": sub.id
28328
- }, t("labels.renew")), sub.shipments_suspended_until && sub.shipments_remaining > 0 && /*#__PURE__*/React__default.createElement(Button$1, {
28412
+ }, t("labels.renew")), sub.shipments_suspended_until && isDateAfterToday(sub.shipments_suspended_until) && sub.shipments_remaining > 0 && /*#__PURE__*/React__default.createElement(Button$1, {
28329
28413
  variant: "ghost",
28330
28414
  className: "plc-text-blue-400 pelcro-dashboard-sub-suspend-button",
28331
28415
  icon: /*#__PURE__*/React__default.createElement(SvgXIconSolid, null),
28332
28416
  onClick: onUnSuspendClick,
28333
28417
  disabled: disableSubmit,
28334
28418
  "data-key": sub.id
28335
- }, t("labels.unsuspend")), !sub.shipments_suspended_until && sub.shipments_remaining > 0 && /*#__PURE__*/React__default.createElement(Button$1, {
28419
+ }, t("labels.unsuspend")), (!sub.shipments_suspended_until && sub.shipments_remaining > 0 || sub.shipments_suspended_until && !isDateAfterToday(sub.shipments_suspended_until)) && /*#__PURE__*/React__default.createElement(Button$1, {
28336
28420
  variant: "ghost",
28337
28421
  className: "plc-text-red-500 focus:plc-ring-red-500 pelcro-dashboard-sub-suspend-button",
28338
28422
  icon: /*#__PURE__*/React__default.createElement(SvgCalendar, null),
@@ -28392,6 +28476,12 @@ function getNonDonationSubs() {
28392
28476
  return (_window$Pelcro$subscr = (_window$Pelcro$subscr2 = window.Pelcro.subscription) === null || _window$Pelcro$subscr2 === void 0 ? void 0 : (_window$Pelcro$subscr3 = _window$Pelcro$subscr2.list()) === null || _window$Pelcro$subscr3 === void 0 ? void 0 : _window$Pelcro$subscr3.filter(sub => !sub.plan.is_donation)) !== null && _window$Pelcro$subscr !== void 0 ? _window$Pelcro$subscr : [];
28393
28477
  }
28394
28478
 
28479
+ function isDateAfterToday(date) {
28480
+ const today = new Date().setHours(0, 0, 0, 0);
28481
+ const newDate = new Date(date).setHours(0, 0, 0, 0);
28482
+ return newDate === today ? true : newDate > today;
28483
+ }
28484
+
28395
28485
  /**
28396
28486
  * @typedef {Object} AccordionPropsType
28397
28487
  * @property {string} initialActiveMenu the initial active menu
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": "4.0.0-alpha.4",
4
+ "version": "4.0.0-alpha.6",
5
5
  "license": "MIT",
6
6
  "private": false,
7
7
  "main": "dist/index.cjs.js",