@bigbinary/neeto-thank-you-frontend 1.0.3 → 1.0.4

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.js CHANGED
@@ -2896,7 +2896,8 @@ var thankYou = {
2896
2896
  };
2897
2897
  var buttons = {
2898
2898
  saveChanges: "Save changes",
2899
- cancel: "Cancel"
2899
+ cancel: "Cancel",
2900
+ resetChanges: "Reset changes"
2900
2901
  };
2901
2902
  var en = {
2902
2903
  common: common,
@@ -3015,9 +3016,15 @@ var update = function update(_ref) {
3015
3016
  thankYouConfiguration: payload
3016
3017
  });
3017
3018
  };
3019
+ var resetToDefault = function resetToDefault(entityId) {
3020
+ return axios.put("".concat(baseUrl$1, "/reset_to_default"), {
3021
+ entityId: entityId
3022
+ });
3023
+ };
3018
3024
  var thankYouConfigurationApi = {
3019
3025
  show: show$1,
3020
- update: update
3026
+ update: update,
3027
+ resetToDefault: resetToDefault
3021
3028
  };
3022
3029
 
3023
3030
  var QUERY_KEYS = {
@@ -3043,12 +3050,21 @@ var useUpdateThankYouConfiguration = function useUpdateThankYouConfiguration(opt
3043
3050
  payload: payload
3044
3051
  });
3045
3052
  }, _objectSpread$3({
3046
- onSuccess: function onSuccess(_ref3) {
3047
- var entityId = _ref3.entityId;
3048
- queryClient.invalidateQueries([QUERY_KEYS.THANK_YOU_CONFIGURATION, entityId]);
3053
+ onSuccess: function onSuccess() {
3054
+ queryClient.invalidateQueries(QUERY_KEYS.THANK_YOU_CONFIGURATION);
3049
3055
  }
3050
3056
  }, options));
3051
3057
  };
3058
+ var useResetThankYouConfigurationToDefault = function useResetThankYouConfigurationToDefault(entityId) {
3059
+ var queryClient = useQueryClient();
3060
+ return useMutation(function () {
3061
+ return thankYouConfigurationApi.resetToDefault(entityId);
3062
+ }, {
3063
+ onSuccess: function onSuccess() {
3064
+ queryClient.invalidateQueries(QUERY_KEYS.THANK_YOU_CONFIGURATION);
3065
+ }
3066
+ });
3067
+ };
3052
3068
 
3053
3069
  function _arrayWithHoles$2(arr) {
3054
3070
  if (Array.isArray(arr)) return arr;
@@ -13538,7 +13554,8 @@ var ResubmissionWarningModal = function ResubmissionWarningModal(_ref) {
13538
13554
  var Customize = function Customize(_ref) {
13539
13555
  var uniqueSubmissionEnabled = _ref.uniqueSubmissionEnabled,
13540
13556
  hasImageUploader = _ref.hasImageUploader,
13541
- uniqueSubmissionLink = _ref.uniqueSubmissionLink;
13557
+ uniqueSubmissionLink = _ref.uniqueSubmissionLink,
13558
+ entityId = _ref.entityId;
13542
13559
  var _useState = useState(false),
13543
13560
  _useState2 = _slicedToArray$2(_useState, 2),
13544
13561
  isUniqueSubmissionWarningModalOpen = _useState2[0],
@@ -13551,6 +13568,20 @@ var Customize = function Customize(_ref) {
13551
13568
  var _useFormikContext = useFormikContext(),
13552
13569
  values = _useFormikContext.values,
13553
13570
  setFieldValue = _useFormikContext.setFieldValue;
13571
+ var _useShowThankYouConfi = useShowThankYouConfiguration({
13572
+ entityId: entityId
13573
+ }),
13574
+ _useShowThankYouConfi2 = _useShowThankYouConfi.data,
13575
+ _useShowThankYouConfi3 = _useShowThankYouConfi2 === void 0 ? {} : _useShowThankYouConfi2,
13576
+ thankYouConfiguration = _useShowThankYouConfi3.thankYouConfiguration,
13577
+ isFetching = _useShowThankYouConfi.isFetching;
13578
+ useEffect(function () {
13579
+ if (!isFetching) {
13580
+ var _editorRef$current;
13581
+ setFieldValue("message", thankYouConfiguration.message);
13582
+ (_editorRef$current = editorRef.current) === null || _editorRef$current === void 0 ? void 0 : _editorRef$current.editor.commands.setContent(thankYouConfiguration.message);
13583
+ }
13584
+ }, [isFetching]);
13554
13585
  var handleResubmitLinkChange = function handleResubmitLinkChange(event) {
13555
13586
  uniqueSubmissionEnabled ? setIsUniqueSubmissionWarningModalOpen(true) : setFieldValue("showResubmitLink", event.target.checked);
13556
13587
  };
@@ -13714,15 +13745,13 @@ var Preview = function Preview(_ref) {
13714
13745
  var ExternalLink = function ExternalLink() {
13715
13746
  var _useTranslation = useTranslation(),
13716
13747
  t = _useTranslation.t;
13717
- return /*#__PURE__*/React__default.createElement("div", {
13718
- className: "mb-6"
13719
- }, /*#__PURE__*/React__default.createElement(Input, {
13748
+ return /*#__PURE__*/React__default.createElement(Input, {
13720
13749
  autoFocus: true,
13721
13750
  label: t("thankYou.link"),
13722
13751
  name: "redirectUrl",
13723
13752
  placeholder: EXTERNAL_URL_PREFIX,
13724
13753
  prefix: /*#__PURE__*/React__default.createElement(Link, null)
13725
- }));
13754
+ });
13726
13755
  };
13727
13756
 
13728
13757
  var Label = function Label(_ref) {
@@ -13760,6 +13789,9 @@ var Form = function Form(_ref) {
13760
13789
  var _useUpdateThankYouCon = useUpdateThankYouConfiguration(),
13761
13790
  updateThankYouConfiguration = _useUpdateThankYouCon.mutate,
13762
13791
  isUpdatingForm = _useUpdateThankYouCon.isLoading;
13792
+ var _useResetThankYouConf = useResetThankYouConfigurationToDefault(entityId),
13793
+ resetToDefaultMessage = _useResetThankYouConf.mutate,
13794
+ isResetting = _useResetThankYouConf.isLoading;
13763
13795
  if (isLoading) {
13764
13796
  return /*#__PURE__*/React__default.createElement("div", {
13765
13797
  className: "flex h-full w-full items-center justify-center"
@@ -13802,17 +13834,25 @@ var Form = function Form(_ref) {
13802
13834
  })
13803
13835
  });
13804
13836
  }))), values.kind === FORM_OPTIONS.customize.kind ? /*#__PURE__*/React__default.createElement(Customize, {
13837
+ entityId: entityId,
13805
13838
  hasImageUploader: hasImageUploader,
13806
13839
  uniqueSubmissionEnabled: uniqueSubmissionEnabled,
13807
13840
  uniqueSubmissionLink: uniqueSubmissionLink
13808
13841
  }) : /*#__PURE__*/React__default.createElement(ExternalLink, null), /*#__PURE__*/React__default.createElement("div", {
13809
- className: "mt-6 flex flex-row items-center justify-start"
13842
+ className: "mt-6 flex items-center space-x-2"
13810
13843
  }, /*#__PURE__*/React__default.createElement(Button, {
13811
- className: "mr-3",
13812
13844
  disabled: !dirty,
13813
13845
  label: t("buttons.saveChanges"),
13814
13846
  loading: isUpdatingForm,
13815
13847
  type: "submit"
13848
+ }), values.kind === FORM_OPTIONS.customize.kind && /*#__PURE__*/React__default.createElement(Button, {
13849
+ disabled: isResetting,
13850
+ label: t("buttons.resetChanges"),
13851
+ loading: isResetting,
13852
+ style: "secondary",
13853
+ onClick: function onClick() {
13854
+ return resetToDefaultMessage();
13855
+ }
13816
13856
  }), /*#__PURE__*/React__default.createElement(Button, {
13817
13857
  label: t("buttons.cancel"),
13818
13858
  style: "text",