@mjhls/mjh-framework 1.0.1050-pdfGating-v2 → 1.0.1050-pdfGating-v4

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.
@@ -495,22 +495,27 @@ var PublicationLanding = function PublicationLanding(props) {
495
495
 
496
496
  var _useState15 = React.useState(false),
497
497
  _useState16 = slicedToArray._slicedToArray(_useState15, 2),
498
- isValidated = _useState16[0],
499
- SetIsValidated = _useState16[1];
498
+ checkBox = _useState16[0],
499
+ setCheckBox = _useState16[1];
500
+
501
+ var _useState17 = React.useState(false),
502
+ _useState18 = slicedToArray._slicedToArray(_useState17, 2),
503
+ isValidated = _useState18[0],
504
+ SetIsValidated = _useState18[1];
500
505
 
501
506
  var DL_PDF = React.useRef();
502
507
  var overLayRef = React.useRef([]);
503
508
  var pdfFormRef = React.useRef();
504
509
 
505
- var _useState17 = React.useState(false),
506
- _useState18 = slicedToArray._slicedToArray(_useState17, 2),
507
- sendingData = _useState18[0],
508
- setSendingData = _useState18[1];
509
-
510
- var _useState19 = React.useState(''),
510
+ var _useState19 = React.useState(true),
511
511
  _useState20 = slicedToArray._slicedToArray(_useState19, 2),
512
- errorMsg = _useState20[0],
513
- setErrorMsg = _useState20[1];
512
+ sendingData = _useState20[0],
513
+ setSendingData = _useState20[1];
514
+
515
+ var _useState21 = React.useState(''),
516
+ _useState22 = slicedToArray._slicedToArray(_useState21, 2),
517
+ errorMsg = _useState22[0],
518
+ setErrorMsg = _useState22[1];
514
519
 
515
520
  var triggerAction = 'click';
516
521
  var placementLocation = main.main_42 ? 'top' : 'top';
@@ -657,18 +662,17 @@ var PublicationLanding = function PublicationLanding(props) {
657
662
  case 'email':
658
663
  setEmail(e.currentTarget.value);
659
664
  break;
660
- default:
661
- console.log(e.currentTarget.dataset['key']);
662
- closeOverlay(e.currentTarget.dataset['key']);
665
+ case 'checkbox':
666
+ setCheckBox(e.currentTarget.checked);
663
667
  break;
664
668
  }
665
669
  };
666
670
 
667
- var closeOverlay = function closeOverlay(key) {
668
- console.dir(overLayRef);
669
- console.log(key);
670
- overLayRef.current[key].handleHide();
671
- };
671
+ React.useEffect(function () {
672
+ if (firstName.length > 3 && lastName.length > 3 && email.includes('@') && checkBox) {
673
+ setSendingData(false);
674
+ }
675
+ }, [firstName, lastName, email, checkBox]);
672
676
 
673
677
  var isGatedFormHandler = function () {
674
678
  var _ref = asyncToGenerator._asyncToGenerator( /*#__PURE__*/asyncToGenerator.regenerator.mark(function _callee(e) {
@@ -690,6 +694,7 @@ var PublicationLanding = function PublicationLanding(props) {
690
694
  return _context.abrupt('return');
691
695
 
692
696
  case 6:
697
+ console.dir(overLayRef);
693
698
  body = {};
694
699
 
695
700
  body['firstName'] = firstName;
@@ -700,56 +705,56 @@ var PublicationLanding = function PublicationLanding(props) {
700
705
  body['site'] = window.location.hostname;
701
706
  SetIsValidated(true);
702
707
 
703
- _context.prev = 14;
704
- _context.next = 17;
708
+ _context.prev = 15;
709
+ _context.next = 18;
705
710
  return fetch('/api/pdfGating/check', {
706
711
  method: 'POST',
707
712
  headers: { 'Content-Type': 'application/json' },
708
713
  body: stringify._JSON$stringify(body)
709
714
  });
710
715
 
711
- case 17:
716
+ case 18:
712
717
  res = _context.sent;
713
718
 
714
719
  if (!(res.status === 202)) {
715
- _context.next = 23;
720
+ _context.next = 24;
716
721
  break;
717
722
  }
718
723
 
719
724
  window.open(DL_PDF.current.dataset.pdf, '_blank');
720
- closeOverlay(DL_PDF.current.dataset.key);
721
- _context.next = 28;
725
+ closeAllOverlays();
726
+ _context.next = 29;
722
727
  break;
723
728
 
724
- case 23:
729
+ case 24:
725
730
  _context.t0 = Error;
726
- _context.next = 26;
731
+ _context.next = 27;
727
732
  return res.text();
728
733
 
729
- case 26:
734
+ case 27:
730
735
  _context.t1 = _context.sent;
731
736
  throw new _context.t0(_context.t1);
732
737
 
733
- case 28:
734
- _context.next = 33;
738
+ case 29:
739
+ _context.next = 34;
735
740
  break;
736
741
 
737
- case 30:
738
- _context.prev = 30;
739
- _context.t2 = _context['catch'](14);
742
+ case 31:
743
+ _context.prev = 31;
744
+ _context.t2 = _context['catch'](15);
740
745
 
741
746
  setErrorMsg(_context.t2.message);
742
747
 
743
- case 33:
748
+ case 34:
744
749
  setSendingData(false);
745
750
  SetIsValidated(false);
746
751
 
747
- case 35:
752
+ case 36:
748
753
  case 'end':
749
754
  return _context.stop();
750
755
  }
751
756
  }
752
- }, _callee, _this, [[14, 30]]);
757
+ }, _callee, _this, [[15, 31]]);
753
758
  }));
754
759
 
755
760
  return function isGatedFormHandler(_x) {
@@ -757,24 +762,24 @@ var PublicationLanding = function PublicationLanding(props) {
757
762
  };
758
763
  }();
759
764
 
765
+ var closeAllOverlays = function closeAllOverlays() {
766
+ overLayRef.current.forEach(function (element) {
767
+ try {
768
+ console.dir(element);
769
+ element.handleHide();
770
+ } catch (e) {
771
+ console.error(e.message);
772
+ }
773
+ });
774
+ };
775
+
760
776
  var isGatedPDFPopOver = function isGatedPDFPopOver(key) {
761
777
  return React__default["default"].createElement(
762
778
  Popover__default["default"],
763
- { id: 'popover-basic-' },
779
+ { id: 'popover-basic-' + key },
764
780
  React__default["default"].createElement(
765
781
  Popover__default["default"].Content,
766
782
  null,
767
- React__default["default"].createElement(
768
- 'div',
769
- { className: 'popoverClose' },
770
- React__default["default"].createElement(
771
- 'button',
772
- { 'data-key': key, onClick: function onClick(e) {
773
- return handleFormInput(e);
774
- } },
775
- 'X'
776
- )
777
- ),
778
783
  React__default["default"].createElement(
779
784
  Form__default["default"],
780
785
  { ref: pdfFormRef, validated: isValidated, onSubmit: isGatedFormHandler },
@@ -847,17 +852,38 @@ var PublicationLanding = function PublicationLanding(props) {
847
852
  'Please provide your email.'
848
853
  )
849
854
  ),
855
+ React__default["default"].createElement(
856
+ Form__default["default"].Group,
857
+ { className: 'mb-3', controlId: 'pdfPrivacyCheck' },
858
+ React__default["default"].createElement(
859
+ Form__default["default"].Check,
860
+ null,
861
+ React__default["default"].createElement(Form__default["default"].Check.Input, { required: true, onChange: function onChange(e) {
862
+ return handleFormInput(e);
863
+ }, type: 'checkbox', name: 'checkbox' }),
864
+ React__default["default"].createElement(
865
+ Form__default["default"].Check.Label,
866
+ null,
867
+ 'By clicking on \'Submit\', you accept our ',
868
+ React__default["default"].createElement(
869
+ 'a',
870
+ { href: 'https://www.dentalproductsreport.com/privacy', target: '_blank' },
871
+ 'Privacy Policy'
872
+ )
873
+ )
874
+ )
875
+ ),
850
876
  React__default["default"].createElement(
851
877
  Button__default["default"],
852
878
  { disabled: sendingData, className: 'btn btn-primary mb-3', type: 'submit' },
853
879
  'Submit'
854
- )
855
- ),
856
- errorMsg ? React__default["default"].createElement(
857
- 'div',
858
- { style: { color: 'red' } },
859
- errorMsg
860
- ) : null
880
+ ),
881
+ errorMsg ? React__default["default"].createElement(
882
+ 'div',
883
+ { style: { color: 'red' } },
884
+ errorMsg
885
+ ) : null
886
+ )
861
887
  )
862
888
  )
863
889
  );
@@ -993,9 +1019,12 @@ var PublicationLanding = function PublicationLanding(props) {
993
1019
  issue.isGatedPDF ? issue.pdf && issue.pdf.asset && issue.pdf.asset.url ? React__default["default"].createElement(
994
1020
  OverlayTrigger__default["default"],
995
1021
  {
1022
+ rootClose: true,
1023
+ rootCloseEvent: 'click',
996
1024
  key: key,
997
1025
  ref: function ref(el) {
998
- return overLayRef.current[key] = el;
1026
+ console.dir(el);
1027
+ overLayRef.current[key] = el;
999
1028
  },
1000
1029
  trigger: triggerAction,
1001
1030
  placement: placementLocation,
@@ -1072,6 +1101,8 @@ var PublicationLanding = function PublicationLanding(props) {
1072
1101
  issue.isGatedPDF ? issue.pdf && issue.pdf.asset && issue.pdf.asset.url ? React__default["default"].createElement(
1073
1102
  OverlayTrigger__default["default"],
1074
1103
  {
1104
+ rootClose: true,
1105
+ rootCloseEvent: 'click',
1075
1106
  key: key,
1076
1107
  ref: function ref(el) {
1077
1108
  return overLayRef.current[key] = el;
@@ -1102,7 +1133,7 @@ var PublicationLanding = function PublicationLanding(props) {
1102
1133
  React__default["default"].createElement(
1103
1134
  'style',
1104
1135
  { jsx: 'true' },
1105
- '\n .gatedPdfForm {\n display: flex;\n flex-direction: column;\n justify-content: center;\n padding: 0 2rem;\n }\n .popoverClose {\n display: flex;\n flex-direction: row;\n justify-content: flex-end;\n }\n .popoverClose button {\n border: none;\n background: transparent;\n color: #2780e3;\n }\n .card-footer button:not(:first-child) {\n color: #fff;\n margin-left: 1rem;\n }\n .issueCard.card:hover {\n cursor: default;\n }\n .content-category-label {\n margin: 0.5rem 0;\n display: block;\n }\n .sanityDisplayLabel {\n margin: 0.5rem 0;\n border: 1px solid black;\n display: inline;\n width: 100%;\n padding: 5px;\n color: #484848;\n border-radius: 2px;\n }\n .dropdown-toggle {\n min-width: 5rem;\n }\n .dropdown-toggle:empty:after {\n margin-left: 4rem;\n }\n .card-footer {\n background-color: transparent;\n border-top: 0;\n }\n .card-footer a:not(:first-child) {\n margin-left: 1rem;\n }\n '
1136
+ '\n .gatedPdfForm {\n justify-content: center;\n flex-direction: column;\n padding: 0 1.5rem;\n }\n .popoverClose {\n display: flex;\n flex-direction: row;\n justify-content: flex-end;\n }\n .popoverClose button {\n border: none;\n background: transparent;\n color: #2780e3;\n }\n .card-footer button:not(:first-child) {\n color: #fff;\n margin-left: 1rem;\n }\n .issueCard.card:hover {\n cursor: default;\n }\n .content-category-label {\n margin: 0.5rem 0;\n display: block;\n }\n .sanityDisplayLabel {\n margin: 0.5rem 0;\n border: 1px solid black;\n display: inline;\n width: 100%;\n padding: 5px;\n color: #484848;\n border-radius: 2px;\n }\n .dropdown-toggle {\n min-width: 5rem;\n }\n .dropdown-toggle:empty:after {\n margin-left: 4rem;\n }\n .card-footer {\n background-color: transparent;\n border-top: 0;\n }\n .card-footer a:not(:first-child) {\n margin-left: 1rem;\n }\n '
1106
1137
  )
1107
1138
  );
1108
1139
  };
@@ -481,22 +481,27 @@ var PublicationLanding = function PublicationLanding(props) {
481
481
 
482
482
  var _useState15 = useState(false),
483
483
  _useState16 = _slicedToArray(_useState15, 2),
484
- isValidated = _useState16[0],
485
- SetIsValidated = _useState16[1];
484
+ checkBox = _useState16[0],
485
+ setCheckBox = _useState16[1];
486
+
487
+ var _useState17 = useState(false),
488
+ _useState18 = _slicedToArray(_useState17, 2),
489
+ isValidated = _useState18[0],
490
+ SetIsValidated = _useState18[1];
486
491
 
487
492
  var DL_PDF = useRef();
488
493
  var overLayRef = useRef([]);
489
494
  var pdfFormRef = useRef();
490
495
 
491
- var _useState17 = useState(false),
492
- _useState18 = _slicedToArray(_useState17, 2),
493
- sendingData = _useState18[0],
494
- setSendingData = _useState18[1];
495
-
496
- var _useState19 = useState(''),
496
+ var _useState19 = useState(true),
497
497
  _useState20 = _slicedToArray(_useState19, 2),
498
- errorMsg = _useState20[0],
499
- setErrorMsg = _useState20[1];
498
+ sendingData = _useState20[0],
499
+ setSendingData = _useState20[1];
500
+
501
+ var _useState21 = useState(''),
502
+ _useState22 = _slicedToArray(_useState21, 2),
503
+ errorMsg = _useState22[0],
504
+ setErrorMsg = _useState22[1];
500
505
 
501
506
  var triggerAction = 'click';
502
507
  var placementLocation = main_42 ? 'top' : 'top';
@@ -643,18 +648,17 @@ var PublicationLanding = function PublicationLanding(props) {
643
648
  case 'email':
644
649
  setEmail(e.currentTarget.value);
645
650
  break;
646
- default:
647
- console.log(e.currentTarget.dataset['key']);
648
- closeOverlay(e.currentTarget.dataset['key']);
651
+ case 'checkbox':
652
+ setCheckBox(e.currentTarget.checked);
649
653
  break;
650
654
  }
651
655
  };
652
656
 
653
- var closeOverlay = function closeOverlay(key) {
654
- console.dir(overLayRef);
655
- console.log(key);
656
- overLayRef.current[key].handleHide();
657
- };
657
+ useEffect(function () {
658
+ if (firstName.length > 3 && lastName.length > 3 && email.includes('@') && checkBox) {
659
+ setSendingData(false);
660
+ }
661
+ }, [firstName, lastName, email, checkBox]);
658
662
 
659
663
  var isGatedFormHandler = function () {
660
664
  var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e) {
@@ -676,6 +680,7 @@ var PublicationLanding = function PublicationLanding(props) {
676
680
  return _context.abrupt('return');
677
681
 
678
682
  case 6:
683
+ console.dir(overLayRef);
679
684
  body = {};
680
685
 
681
686
  body['firstName'] = firstName;
@@ -686,56 +691,56 @@ var PublicationLanding = function PublicationLanding(props) {
686
691
  body['site'] = window.location.hostname;
687
692
  SetIsValidated(true);
688
693
 
689
- _context.prev = 14;
690
- _context.next = 17;
694
+ _context.prev = 15;
695
+ _context.next = 18;
691
696
  return fetch('/api/pdfGating/check', {
692
697
  method: 'POST',
693
698
  headers: { 'Content-Type': 'application/json' },
694
699
  body: _JSON$stringify(body)
695
700
  });
696
701
 
697
- case 17:
702
+ case 18:
698
703
  res = _context.sent;
699
704
 
700
705
  if (!(res.status === 202)) {
701
- _context.next = 23;
706
+ _context.next = 24;
702
707
  break;
703
708
  }
704
709
 
705
710
  window.open(DL_PDF.current.dataset.pdf, '_blank');
706
- closeOverlay(DL_PDF.current.dataset.key);
707
- _context.next = 28;
711
+ closeAllOverlays();
712
+ _context.next = 29;
708
713
  break;
709
714
 
710
- case 23:
715
+ case 24:
711
716
  _context.t0 = Error;
712
- _context.next = 26;
717
+ _context.next = 27;
713
718
  return res.text();
714
719
 
715
- case 26:
720
+ case 27:
716
721
  _context.t1 = _context.sent;
717
722
  throw new _context.t0(_context.t1);
718
723
 
719
- case 28:
720
- _context.next = 33;
724
+ case 29:
725
+ _context.next = 34;
721
726
  break;
722
727
 
723
- case 30:
724
- _context.prev = 30;
725
- _context.t2 = _context['catch'](14);
728
+ case 31:
729
+ _context.prev = 31;
730
+ _context.t2 = _context['catch'](15);
726
731
 
727
732
  setErrorMsg(_context.t2.message);
728
733
 
729
- case 33:
734
+ case 34:
730
735
  setSendingData(false);
731
736
  SetIsValidated(false);
732
737
 
733
- case 35:
738
+ case 36:
734
739
  case 'end':
735
740
  return _context.stop();
736
741
  }
737
742
  }
738
- }, _callee, _this, [[14, 30]]);
743
+ }, _callee, _this, [[15, 31]]);
739
744
  }));
740
745
 
741
746
  return function isGatedFormHandler(_x) {
@@ -743,24 +748,24 @@ var PublicationLanding = function PublicationLanding(props) {
743
748
  };
744
749
  }();
745
750
 
751
+ var closeAllOverlays = function closeAllOverlays() {
752
+ overLayRef.current.forEach(function (element) {
753
+ try {
754
+ console.dir(element);
755
+ element.handleHide();
756
+ } catch (e) {
757
+ console.error(e.message);
758
+ }
759
+ });
760
+ };
761
+
746
762
  var isGatedPDFPopOver = function isGatedPDFPopOver(key) {
747
763
  return React__default.createElement(
748
764
  Popover,
749
- { id: 'popover-basic-' },
765
+ { id: 'popover-basic-' + key },
750
766
  React__default.createElement(
751
767
  Popover.Content,
752
768
  null,
753
- React__default.createElement(
754
- 'div',
755
- { className: 'popoverClose' },
756
- React__default.createElement(
757
- 'button',
758
- { 'data-key': key, onClick: function onClick(e) {
759
- return handleFormInput(e);
760
- } },
761
- 'X'
762
- )
763
- ),
764
769
  React__default.createElement(
765
770
  Form,
766
771
  { ref: pdfFormRef, validated: isValidated, onSubmit: isGatedFormHandler },
@@ -833,17 +838,38 @@ var PublicationLanding = function PublicationLanding(props) {
833
838
  'Please provide your email.'
834
839
  )
835
840
  ),
841
+ React__default.createElement(
842
+ Form.Group,
843
+ { className: 'mb-3', controlId: 'pdfPrivacyCheck' },
844
+ React__default.createElement(
845
+ Form.Check,
846
+ null,
847
+ React__default.createElement(Form.Check.Input, { required: true, onChange: function onChange(e) {
848
+ return handleFormInput(e);
849
+ }, type: 'checkbox', name: 'checkbox' }),
850
+ React__default.createElement(
851
+ Form.Check.Label,
852
+ null,
853
+ 'By clicking on \'Submit\', you accept our ',
854
+ React__default.createElement(
855
+ 'a',
856
+ { href: 'https://www.dentalproductsreport.com/privacy', target: '_blank' },
857
+ 'Privacy Policy'
858
+ )
859
+ )
860
+ )
861
+ ),
836
862
  React__default.createElement(
837
863
  Button,
838
864
  { disabled: sendingData, className: 'btn btn-primary mb-3', type: 'submit' },
839
865
  'Submit'
840
- )
841
- ),
842
- errorMsg ? React__default.createElement(
843
- 'div',
844
- { style: { color: 'red' } },
845
- errorMsg
846
- ) : null
866
+ ),
867
+ errorMsg ? React__default.createElement(
868
+ 'div',
869
+ { style: { color: 'red' } },
870
+ errorMsg
871
+ ) : null
872
+ )
847
873
  )
848
874
  )
849
875
  );
@@ -979,9 +1005,12 @@ var PublicationLanding = function PublicationLanding(props) {
979
1005
  issue.isGatedPDF ? issue.pdf && issue.pdf.asset && issue.pdf.asset.url ? React__default.createElement(
980
1006
  OverlayTrigger,
981
1007
  {
1008
+ rootClose: true,
1009
+ rootCloseEvent: 'click',
982
1010
  key: key,
983
1011
  ref: function ref(el) {
984
- return overLayRef.current[key] = el;
1012
+ console.dir(el);
1013
+ overLayRef.current[key] = el;
985
1014
  },
986
1015
  trigger: triggerAction,
987
1016
  placement: placementLocation,
@@ -1058,6 +1087,8 @@ var PublicationLanding = function PublicationLanding(props) {
1058
1087
  issue.isGatedPDF ? issue.pdf && issue.pdf.asset && issue.pdf.asset.url ? React__default.createElement(
1059
1088
  OverlayTrigger,
1060
1089
  {
1090
+ rootClose: true,
1091
+ rootCloseEvent: 'click',
1061
1092
  key: key,
1062
1093
  ref: function ref(el) {
1063
1094
  return overLayRef.current[key] = el;
@@ -1088,7 +1119,7 @@ var PublicationLanding = function PublicationLanding(props) {
1088
1119
  React__default.createElement(
1089
1120
  'style',
1090
1121
  { jsx: 'true' },
1091
- '\n .gatedPdfForm {\n display: flex;\n flex-direction: column;\n justify-content: center;\n padding: 0 2rem;\n }\n .popoverClose {\n display: flex;\n flex-direction: row;\n justify-content: flex-end;\n }\n .popoverClose button {\n border: none;\n background: transparent;\n color: #2780e3;\n }\n .card-footer button:not(:first-child) {\n color: #fff;\n margin-left: 1rem;\n }\n .issueCard.card:hover {\n cursor: default;\n }\n .content-category-label {\n margin: 0.5rem 0;\n display: block;\n }\n .sanityDisplayLabel {\n margin: 0.5rem 0;\n border: 1px solid black;\n display: inline;\n width: 100%;\n padding: 5px;\n color: #484848;\n border-radius: 2px;\n }\n .dropdown-toggle {\n min-width: 5rem;\n }\n .dropdown-toggle:empty:after {\n margin-left: 4rem;\n }\n .card-footer {\n background-color: transparent;\n border-top: 0;\n }\n .card-footer a:not(:first-child) {\n margin-left: 1rem;\n }\n '
1122
+ '\n .gatedPdfForm {\n justify-content: center;\n flex-direction: column;\n padding: 0 1.5rem;\n }\n .popoverClose {\n display: flex;\n flex-direction: row;\n justify-content: flex-end;\n }\n .popoverClose button {\n border: none;\n background: transparent;\n color: #2780e3;\n }\n .card-footer button:not(:first-child) {\n color: #fff;\n margin-left: 1rem;\n }\n .issueCard.card:hover {\n cursor: default;\n }\n .content-category-label {\n margin: 0.5rem 0;\n display: block;\n }\n .sanityDisplayLabel {\n margin: 0.5rem 0;\n border: 1px solid black;\n display: inline;\n width: 100%;\n padding: 5px;\n color: #484848;\n border-radius: 2px;\n }\n .dropdown-toggle {\n min-width: 5rem;\n }\n .dropdown-toggle:empty:after {\n margin-left: 4rem;\n }\n .card-footer {\n background-color: transparent;\n border-top: 0;\n }\n .card-footer a:not(:first-child) {\n margin-left: 1rem;\n }\n '
1092
1123
  )
1093
1124
  );
1094
1125
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mjhls/mjh-framework",
3
- "version": "1.0.1050-pdfGating-v2",
3
+ "version": "1.0.1050-pdfGating-v4",
4
4
  "description": "Foundation Framework",
5
5
  "author": "mjh-framework",
6
6
  "license": "MIT",