@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/README.md CHANGED
@@ -1,7 +1,7 @@
1
+ [![BuildStatus](https://neeto-engineering.neetoci.com/badges/neeto-thank-you-nano/workflows/branch.svg)](https://neeto-engineering.neetoci.com/projects/neeto-thank-you-nano)
1
2
  # neeto-thank-you-nano
2
3
 
3
- This repo acts as the source of truth for the new nano's structure, configs,
4
- data etc.
4
+ Nano to manage thank you configuration page on neeto applications.
5
5
 
6
6
  # Local Development Setup
7
7
 
@@ -17,20 +17,3 @@ data etc.
17
17
 
18
18
  1. [Engine and package installation](./docs/engine-and-package-installation.md)
19
19
  2. [Building and releasing](./docs/building-and-releasing.md)
20
-
21
- # Replace NeetoThankYounano with your project name
22
-
23
- Let's say that the project name is `NeetoBigFish`. Execute the below script to
24
- replace it.
25
-
26
- - [Script to replace project name](./docs/replace-project-name-script.md)
27
-
28
- # How to setup neetoCI.
29
-
30
- 1. Go to https://neeto-engineering.neetoci.net/projects.
31
- 2. Click `Add new project`.
32
- 3. ```
33
- Project name: neeto-thank-you-nano
34
- Namespace: bigbinary
35
- Repository: bigbinary/neeto-thank-you-nano
36
- ```
package/dist/index.cjs.js CHANGED
@@ -2928,7 +2928,8 @@ var thankYou = {
2928
2928
  };
2929
2929
  var buttons = {
2930
2930
  saveChanges: "Save changes",
2931
- cancel: "Cancel"
2931
+ cancel: "Cancel",
2932
+ resetChanges: "Reset changes"
2932
2933
  };
2933
2934
  var en = {
2934
2935
  common: common,
@@ -3047,9 +3048,15 @@ var update = function update(_ref) {
3047
3048
  thankYouConfiguration: payload
3048
3049
  });
3049
3050
  };
3051
+ var resetToDefault = function resetToDefault(entityId) {
3052
+ return axios__default["default"].put("".concat(baseUrl$1, "/reset_to_default"), {
3053
+ entityId: entityId
3054
+ });
3055
+ };
3050
3056
  var thankYouConfigurationApi = {
3051
3057
  show: show$1,
3052
- update: update
3058
+ update: update,
3059
+ resetToDefault: resetToDefault
3053
3060
  };
3054
3061
 
3055
3062
  var QUERY_KEYS = {
@@ -3075,12 +3082,21 @@ var useUpdateThankYouConfiguration = function useUpdateThankYouConfiguration(opt
3075
3082
  payload: payload
3076
3083
  });
3077
3084
  }, _objectSpread$3({
3078
- onSuccess: function onSuccess(_ref3) {
3079
- var entityId = _ref3.entityId;
3080
- queryClient.invalidateQueries([QUERY_KEYS.THANK_YOU_CONFIGURATION, entityId]);
3085
+ onSuccess: function onSuccess() {
3086
+ queryClient.invalidateQueries(QUERY_KEYS.THANK_YOU_CONFIGURATION);
3081
3087
  }
3082
3088
  }, options));
3083
3089
  };
3090
+ var useResetThankYouConfigurationToDefault = function useResetThankYouConfigurationToDefault(entityId) {
3091
+ var queryClient = reactQuery.useQueryClient();
3092
+ return reactQuery.useMutation(function () {
3093
+ return thankYouConfigurationApi.resetToDefault(entityId);
3094
+ }, {
3095
+ onSuccess: function onSuccess() {
3096
+ queryClient.invalidateQueries(QUERY_KEYS.THANK_YOU_CONFIGURATION);
3097
+ }
3098
+ });
3099
+ };
3084
3100
 
3085
3101
  function _arrayWithHoles$2(arr) {
3086
3102
  if (Array.isArray(arr)) return arr;
@@ -13570,7 +13586,8 @@ var ResubmissionWarningModal = function ResubmissionWarningModal(_ref) {
13570
13586
  var Customize = function Customize(_ref) {
13571
13587
  var uniqueSubmissionEnabled = _ref.uniqueSubmissionEnabled,
13572
13588
  hasImageUploader = _ref.hasImageUploader,
13573
- uniqueSubmissionLink = _ref.uniqueSubmissionLink;
13589
+ uniqueSubmissionLink = _ref.uniqueSubmissionLink,
13590
+ entityId = _ref.entityId;
13574
13591
  var _useState = React.useState(false),
13575
13592
  _useState2 = _slicedToArray$2(_useState, 2),
13576
13593
  isUniqueSubmissionWarningModalOpen = _useState2[0],
@@ -13583,6 +13600,20 @@ var Customize = function Customize(_ref) {
13583
13600
  var _useFormikContext = formik.useFormikContext(),
13584
13601
  values = _useFormikContext.values,
13585
13602
  setFieldValue = _useFormikContext.setFieldValue;
13603
+ var _useShowThankYouConfi = useShowThankYouConfiguration({
13604
+ entityId: entityId
13605
+ }),
13606
+ _useShowThankYouConfi2 = _useShowThankYouConfi.data,
13607
+ _useShowThankYouConfi3 = _useShowThankYouConfi2 === void 0 ? {} : _useShowThankYouConfi2,
13608
+ thankYouConfiguration = _useShowThankYouConfi3.thankYouConfiguration,
13609
+ isFetching = _useShowThankYouConfi.isFetching;
13610
+ React.useEffect(function () {
13611
+ if (!isFetching) {
13612
+ var _editorRef$current;
13613
+ setFieldValue("message", thankYouConfiguration.message);
13614
+ (_editorRef$current = editorRef.current) === null || _editorRef$current === void 0 ? void 0 : _editorRef$current.editor.commands.setContent(thankYouConfiguration.message);
13615
+ }
13616
+ }, [isFetching]);
13586
13617
  var handleResubmitLinkChange = function handleResubmitLinkChange(event) {
13587
13618
  uniqueSubmissionEnabled ? setIsUniqueSubmissionWarningModalOpen(true) : setFieldValue("showResubmitLink", event.target.checked);
13588
13619
  };
@@ -13746,15 +13777,13 @@ var Preview = function Preview(_ref) {
13746
13777
  var ExternalLink = function ExternalLink() {
13747
13778
  var _useTranslation = useTranslation(),
13748
13779
  t = _useTranslation.t;
13749
- return /*#__PURE__*/React__default["default"].createElement("div", {
13750
- className: "mb-6"
13751
- }, /*#__PURE__*/React__default["default"].createElement(formik$1.Input, {
13780
+ return /*#__PURE__*/React__default["default"].createElement(formik$1.Input, {
13752
13781
  autoFocus: true,
13753
13782
  label: t("thankYou.link"),
13754
13783
  name: "redirectUrl",
13755
13784
  placeholder: EXTERNAL_URL_PREFIX,
13756
13785
  prefix: /*#__PURE__*/React__default["default"].createElement(neetoIcons.Link, null)
13757
- }));
13786
+ });
13758
13787
  };
13759
13788
 
13760
13789
  var Label = function Label(_ref) {
@@ -13792,6 +13821,9 @@ var Form = function Form(_ref) {
13792
13821
  var _useUpdateThankYouCon = useUpdateThankYouConfiguration(),
13793
13822
  updateThankYouConfiguration = _useUpdateThankYouCon.mutate,
13794
13823
  isUpdatingForm = _useUpdateThankYouCon.isLoading;
13824
+ var _useResetThankYouConf = useResetThankYouConfigurationToDefault(entityId),
13825
+ resetToDefaultMessage = _useResetThankYouConf.mutate,
13826
+ isResetting = _useResetThankYouConf.isLoading;
13795
13827
  if (isLoading) {
13796
13828
  return /*#__PURE__*/React__default["default"].createElement("div", {
13797
13829
  className: "flex h-full w-full items-center justify-center"
@@ -13834,17 +13866,25 @@ var Form = function Form(_ref) {
13834
13866
  })
13835
13867
  });
13836
13868
  }))), values.kind === FORM_OPTIONS.customize.kind ? /*#__PURE__*/React__default["default"].createElement(Customize, {
13869
+ entityId: entityId,
13837
13870
  hasImageUploader: hasImageUploader,
13838
13871
  uniqueSubmissionEnabled: uniqueSubmissionEnabled,
13839
13872
  uniqueSubmissionLink: uniqueSubmissionLink
13840
13873
  }) : /*#__PURE__*/React__default["default"].createElement(ExternalLink, null), /*#__PURE__*/React__default["default"].createElement("div", {
13841
- className: "mt-6 flex flex-row items-center justify-start"
13874
+ className: "mt-6 flex items-center space-x-2"
13842
13875
  }, /*#__PURE__*/React__default["default"].createElement(neetoui.Button, {
13843
- className: "mr-3",
13844
13876
  disabled: !dirty,
13845
13877
  label: t("buttons.saveChanges"),
13846
13878
  loading: isUpdatingForm,
13847
13879
  type: "submit"
13880
+ }), values.kind === FORM_OPTIONS.customize.kind && /*#__PURE__*/React__default["default"].createElement(neetoui.Button, {
13881
+ disabled: isResetting,
13882
+ label: t("buttons.resetChanges"),
13883
+ loading: isResetting,
13884
+ style: "secondary",
13885
+ onClick: function onClick() {
13886
+ return resetToDefaultMessage();
13887
+ }
13848
13888
  }), /*#__PURE__*/React__default["default"].createElement(neetoui.Button, {
13849
13889
  label: t("buttons.cancel"),
13850
13890
  style: "text",