@bigbinary/neeto-thank-you-frontend 1.1.4 → 1.1.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.
Files changed (61) hide show
  1. package/README.md +34 -14
  2. package/dist/BrandingInfo-da0b773a.js +32 -0
  3. package/dist/BrandingInfo-da0b773a.js.map +1 -0
  4. package/dist/ConfigureThankYou.js +534 -0
  5. package/dist/ConfigureThankYou.js.map +1 -0
  6. package/dist/ShowThankYou.js +81 -0
  7. package/dist/ShowThankYou.js.map +1 -0
  8. package/dist/SocialShare-d2986d0d.js +40 -0
  9. package/dist/SocialShare-d2986d0d.js.map +1 -0
  10. package/dist/cjs/BrandingInfo-cdb9a379.js +38 -0
  11. package/dist/cjs/BrandingInfo-cdb9a379.js.map +1 -0
  12. package/dist/cjs/ConfigureThankYou.js +573 -0
  13. package/dist/cjs/ConfigureThankYou.js.map +1 -0
  14. package/dist/cjs/ShowThankYou.js +89 -0
  15. package/dist/cjs/ShowThankYou.js.map +1 -0
  16. package/dist/cjs/SocialShare-99170cdb.js +47 -0
  17. package/dist/cjs/SocialShare-99170cdb.js.map +1 -0
  18. package/dist/cjs/commons.js +42 -0
  19. package/dist/cjs/commons.js.map +1 -0
  20. package/dist/cjs/constants.js +19 -0
  21. package/dist/cjs/constants.js.map +1 -0
  22. package/dist/cjs/index.js +52 -0
  23. package/dist/cjs/index.js.map +1 -0
  24. package/dist/cjs/query-95d5312e.js +12 -0
  25. package/dist/cjs/query-95d5312e.js.map +1 -0
  26. package/dist/cjs/useShowThankYouConfiguration.js +12 -0
  27. package/dist/cjs/useShowThankYouConfiguration.js.map +1 -0
  28. package/dist/cjs/useShowThankYouPage.js +11 -0
  29. package/dist/cjs/useShowThankYouPage.js.map +1 -0
  30. package/dist/cjs/useThankYouConfigurationApi-d04d9e79.js +55 -0
  31. package/dist/cjs/useThankYouConfigurationApi-d04d9e79.js.map +1 -0
  32. package/dist/cjs/useThankYouPageApi-8ed1dad1.js +40 -0
  33. package/dist/cjs/useThankYouPageApi-8ed1dad1.js.map +1 -0
  34. package/dist/cjs/utils.js +16 -0
  35. package/dist/cjs/utils.js.map +1 -0
  36. package/dist/commons.js +33 -0
  37. package/dist/commons.js.map +1 -0
  38. package/dist/constants.js +13 -0
  39. package/dist/constants.js.map +1 -0
  40. package/dist/index.js +41 -851
  41. package/dist/index.js.map +1 -1
  42. package/dist/query-ab526f47.js +9 -0
  43. package/dist/query-ab526f47.js.map +1 -0
  44. package/dist/useShowThankYouConfiguration.js +7 -0
  45. package/dist/useShowThankYouConfiguration.js.map +1 -0
  46. package/dist/useShowThankYouPage.js +6 -0
  47. package/dist/useShowThankYouPage.js.map +1 -0
  48. package/dist/useThankYouConfigurationApi-4d803194.js +48 -0
  49. package/dist/useThankYouConfigurationApi-4d803194.js.map +1 -0
  50. package/dist/useThankYouPageApi-14742993.js +34 -0
  51. package/dist/useThankYouPageApi-14742993.js.map +1 -0
  52. package/dist/utils.js +12 -0
  53. package/dist/utils.js.map +1 -0
  54. package/package.json +20 -12
  55. package/types/ConfigureThankYou.d.ts +49 -0
  56. package/types/ShowThankYou.d.ts +28 -0
  57. package/types/useShowThankYouConfiguration.d.ts +8 -0
  58. package/types/useShowThankYouPage.d.ts +17 -0
  59. package/types.d.ts +4 -75
  60. package/dist/index.cjs.js +0 -898
  61. package/dist/index.cjs.js.map +0 -1
package/README.md CHANGED
@@ -108,20 +108,31 @@ application.
108
108
  - `thankYouTextAlignment` - Set alignment of the "Thank You" text in "Thank You"
109
109
  page
110
110
  - `customHeader` - Accepts a React Node & replaces the default Header.
111
- - `appName` - Accepts `appName`, which will be used for generating the sign up URL in the branding text.
111
+ - `appName` - Accepts `appName`, which will be used for generating the sign up
112
+ URL in the branding text.
112
113
  - `disableSubmitAnotherResponse` - Removes the toggle for submitting another
113
114
  response, incase of neetoForm [default: false].
114
115
  - `disableRadioSelection` - Removes the radio selector for
115
116
  `Customize thank you page` & `Redirect to external link` [default: false]
116
117
  - `blockNavigation` - Boolean to show the block navigation alert in the thank
117
118
  you configuration page when there are unsaved changes [default: false]
119
+ - `editorProps` - Accepts props that needs to be passed to the editor component.
120
+ - `preview` - An optional React component to render a custom preview instead of
121
+ the default one.
122
+ - `allowEmptyCustomMessage` - A boolean flag that, when set to true, skips the
123
+ frontend validation for submitting an empty message. [default: false]
118
124
  - `onConfigUpdateSuccess`: The callback function to be triggered when the
119
125
  configuration is updated. The function's first argument corresponds to the
120
126
  parameters passed to the `onSuccess` callback of React Query mutations, while
121
127
  the second argument represents the previous configuration object.
122
- - `brandingInfo` - Accepts an object that specifies the branding details. It can have 2 keys:
123
- 1. `displayText` - Specifies the translation key for the branding text to be displayed. The app name should be wrapped with `<signUpLink>` to set the redirection to neeto-auth properly.
124
- 2. `additionalComponents` - Accepts an optional object that specifies the additional components for styling the display text. This will be passed to the `components` prop of `Trans` component.
128
+ - `brandingInfo` - Accepts an object that specifies the branding details. It can
129
+ have 2 keys:
130
+ 1. `displayText` - Specifies the translation key for the branding text to be
131
+ displayed. The app name should be wrapped with `<signUpLink>` to set the
132
+ redirection to neeto-auth properly.
133
+ 2. `additionalComponents` - Accepts an optional object that specifies the
134
+ additional components for styling the display text. This will be passed to
135
+ the `components` prop of `Trans` component.
125
136
 
126
137
  ##### Configuration
127
138
 
@@ -156,9 +167,7 @@ const App = () => {
156
167
  // "Build your own form using <signUpLink><span>neetoForm.</span></signUpLink> It’s free. <Link>Learn more</Link>."
157
168
  displayText: "form.settings.thankyou.brandingText",
158
169
  additionalComponents: {
159
- Link: (
160
- <a href={WEBSITE_URL} rel="noreferrer" target="_blank" />
161
- ),
170
+ Link: <a href={WEBSITE_URL} rel="noreferrer" target="_blank" />,
162
171
  },
163
172
  };
164
173
 
@@ -193,6 +202,13 @@ export default App;
193
202
  This component displays the "Thank You" page after submission as per the
194
203
  configurations set in the host application.
195
204
 
205
+ Note: `dompurify` is required in ShowThankYou. Use the below command to install
206
+ `dompurify`.
207
+
208
+ ```bash
209
+ yarn add dompurify
210
+ ```
211
+
196
212
  ##### Props
197
213
 
198
214
  - `entityId` - Set the entity ID associated with the "Thank You" page
@@ -202,10 +218,16 @@ configurations set in the host application.
202
218
  - `isThankYouPageLoading` - Boolean value to show the loading state
203
219
  - `customPageLoader` - Specify a custom loader component to replace the default
204
220
  page loader.
205
- - `appName` - Accepts `appName`, which will be used for generating the sign up URL in the branding text.
206
- - `brandingInfo` - Accepts an object that specifies the branding details. It can have 2 keys:
207
- 1. `displayText` - Specifies the translation key for the branding text to be displayed. The app name should be wrapped with `<signUpLink>` to set the redirection to neeto-auth properly.
208
- 2. `additionalComponents` - Accepts an optional object that specifies the additional components for styling the display text. This will be passed to the `components` prop of `Trans` component.
221
+ - `appName` - Accepts `appName`, which will be used for generating the sign up
222
+ URL in the branding text.
223
+ - `brandingInfo` - Accepts an object that specifies the branding details. It can
224
+ have 2 keys:
225
+ 1. `displayText` - Specifies the translation key for the branding text to be
226
+ displayed. The app name should be wrapped with `<signUpLink>` to set the
227
+ redirection to neeto-auth properly.
228
+ 2. `additionalComponents` - Accepts an optional object that specifies the
229
+ additional components for styling the display text. This will be passed to
230
+ the `components` prop of `Trans` component.
209
231
 
210
232
  ##### Usage
211
233
 
@@ -226,9 +248,7 @@ const App = () => {
226
248
  // "Build your own form using <signUpLink><span>neetoForm.</span></signUpLink> It’s free. <Link>Learn more</Link>."
227
249
  displayText: "form.settings.thankyou.brandingText",
228
250
  additionalComponents: {
229
- Link: (
230
- <a href={WEBSITE_URL} rel="noreferrer" target="_blank" />
231
- ),
251
+ Link: <a href={WEBSITE_URL} rel="noreferrer" target="_blank" />,
232
252
  },
233
253
  };
234
254
 
@@ -0,0 +1,32 @@
1
+ import React__default from 'react';
2
+ import { Trans } from 'react-i18next';
3
+ import { buildSignUpUrl } from './utils.js';
4
+
5
+ const BrandingInfo = _ref => {
6
+ let {
7
+ brandingInfo,
8
+ appName
9
+ } = _ref;
10
+ return /*#__PURE__*/React__default.createElement("div", {
11
+ className: "neeto-thank-you-configuration__branding-wrap"
12
+ }, /*#__PURE__*/React__default.createElement("div", {
13
+ className: "neeto-thank-you-configuration__nav"
14
+ }, /*#__PURE__*/React__default.createElement("div", {
15
+ className: "neeto-thank-you-configuration__nav-footer"
16
+ }, /*#__PURE__*/React__default.createElement(Trans, {
17
+ i18nKey: brandingInfo.displayText,
18
+ components: {
19
+ signUpLink: /*#__PURE__*/React__default.createElement("a", {
20
+ className: "neeto-thank-you-configuration__link",
21
+ href: buildSignUpUrl(appName),
22
+ rel: "noreferrer",
23
+ target: "_blank"
24
+ }),
25
+ span: /*#__PURE__*/React__default.createElement("span", null),
26
+ ...(brandingInfo.additionalComponents ?? {})
27
+ }
28
+ }))));
29
+ };
30
+
31
+ export { BrandingInfo as B };
32
+ //# sourceMappingURL=BrandingInfo-da0b773a.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BrandingInfo-da0b773a.js","sources":["../app/javascript/src/components/commons/BrandingInfo.jsx"],"sourcesContent":["import React from \"react\";\n\nimport { Trans } from \"react-i18next\";\n\nimport { buildSignUpUrl } from \"components/utils\";\n\nconst BrandingInfo = ({ brandingInfo, appName }) => (\n <div className=\"neeto-thank-you-configuration__branding-wrap\">\n <div className=\"neeto-thank-you-configuration__nav\">\n <div className=\"neeto-thank-you-configuration__nav-footer\">\n <Trans\n i18nKey={brandingInfo.displayText}\n components={{\n signUpLink: (\n <a\n className=\"neeto-thank-you-configuration__link\"\n href={buildSignUpUrl(appName)}\n rel=\"noreferrer\"\n target=\"_blank\"\n />\n ),\n span: <span />,\n ...(brandingInfo.additionalComponents ?? {}),\n }}\n />\n </div>\n </div>\n </div>\n);\n\nexport default BrandingInfo;\n"],"names":["BrandingInfo","_ref","brandingInfo","appName","React","createElement","className","Trans","i18nKey","displayText","components","signUpLink","href","buildSignUpUrl","rel","target","span","additionalComponents"],"mappings":";;;;AAMMA,MAAAA,YAAY,GAAGC,IAAA,IAAA;EAAA,IAAC;IAAEC,YAAY;AAAEC,IAAAA,OAAAA;AAAQ,GAAC,GAAAF,IAAA,CAAA;EAAA,oBAC7CG,cAAA,CAAAC,aAAA,CAAA,KAAA,EAAA;AAAKC,IAAAA,SAAS,EAAC,8CAAA;GACbF,eAAAA,cAAA,CAAAC,aAAA,CAAA,KAAA,EAAA;AAAKC,IAAAA,SAAS,EAAC,oCAAA;GACbF,eAAAA,cAAA,CAAAC,aAAA,CAAA,KAAA,EAAA;AAAKC,IAAAA,SAAS,EAAC,2CAAA;AAA2C,GAAA,eACxDF,cAAA,CAAAC,aAAA,CAACE,KAAK,EAAA;IACJC,OAAO,EAAEN,YAAY,CAACO,WAAY;AAClCC,IAAAA,UAAU,EAAE;MACVC,UAAU,eACRP,cAAA,CAAAC,aAAA,CAAA,GAAA,EAAA;AACEC,QAAAA,SAAS,EAAC,qCAAqC;AAC/CM,QAAAA,IAAI,EAAEC,cAAc,CAACV,OAAO,CAAE;AAC9BW,QAAAA,GAAG,EAAC,YAAY;AAChBC,QAAAA,MAAM,EAAC,QAAA;AAAQ,OAChB,CACF;AACDC,MAAAA,IAAI,eAAEZ,cAAA,CAAAC,aAAA,aAAO,CAAC;AACd,MAAA,IAAIH,YAAY,CAACe,oBAAoB,IAAI,EAAE,CAAA;AAC7C,KAAA;GACD,CACE,CACF,CACF,CAAC,CAAA;AAAA;;;;"}
@@ -0,0 +1,534 @@
1
+ import * as React from 'react';
2
+ import React__default, { useState, useEffect, useRef } from 'react';
3
+ import { hyphenate, noop } from '@bigbinary/neeto-cist';
4
+ import Scrollable from '@bigbinary/neeto-molecules/Scrollable';
5
+ import { n, S as SocialShare } from './SocialShare-d2986d0d.js';
6
+ import { t } from 'i18next';
7
+ import classNames from 'classnames';
8
+ import PageLoader from '@bigbinary/neeto-molecules/PageLoader';
9
+ import ActionBlock from '@bigbinary/neetoui/formik/ActionBlock';
10
+ import BlockNavigation from '@bigbinary/neetoui/formik/BlockNavigation';
11
+ import NeetoUIForm from '@bigbinary/neetoui/formik/Form';
12
+ import Radio from '@bigbinary/neetoui/formik/Radio';
13
+ import { isEmpty } from 'ramda';
14
+ import { u as useShowThankYouConfiguration, a as useUpdateThankYouConfiguration } from './useThankYouConfigurationApi-4d803194.js';
15
+ import { useFormikContext } from 'formik';
16
+ import { FormikEditor, EditorContent, isEditorEmpty } from '@bigbinary/neeto-editor';
17
+ import Label$1 from '@bigbinary/neetoui/Label';
18
+ import Input from '@bigbinary/neetoui/formik/Input';
19
+ import Switch from '@bigbinary/neetoui/formik/Switch';
20
+ import { useTranslation } from 'react-i18next';
21
+ import { ImageUploader } from '@bigbinary/neeto-image-uploader-frontend';
22
+ import { withT } from '@bigbinary/neeto-commons-frontend/react-utils';
23
+ import Button from '@bigbinary/neetoui/Button';
24
+ import Typography from '@bigbinary/neetoui/Typography';
25
+ import Modal from '@bigbinary/neetoui/Modal';
26
+ import { B as BrandingInfo } from './BrandingInfo-da0b773a.js';
27
+ import { Link } from '@bigbinary/neeto-icons';
28
+ import * as yup from 'yup';
29
+ import NeetoUIHeader from '@bigbinary/neeto-molecules/Header';
30
+ import 'react-query';
31
+ import 'axios';
32
+ import './query-ab526f47.js';
33
+ import './utils.js';
34
+ import '@bigbinary/neeto-commons-frontend/utils';
35
+ import './constants.js';
36
+ import '@bigbinary/neeto-commons-frontend/initializers';
37
+
38
+ var css = ".neeto-thank-you-configuration-radio__item{align-items:flex-start;background-color:rgb(var(--neeto-ui-white));border:1px solid rgb(var(--neeto-ui-gray-300));border-radius:var(--neeto-ui-rounded);padding:12px 16px}.neeto-thank-you-configuration-radio__item.neeto-ui-radio__item:not(:last-child){margin-right:0!important}.neeto-thank-you-configuration-radio__item.neeto-ui-radio__item{align-items:start!important}.neeto-thank-you-configuration-radio__item.neeto-ui-radio__item .neeto-ui-radio{margin-top:3px}.neeto-thank-you-configuration-radio__item.active{background-color:rgb(var(--neeto-ui-primary-100));border:1.5px solid rgb(var(--neeto-ui-primary-800))}";
39
+ n(css,{});
40
+
41
+ const FORM_OPTIONS = {
42
+ customize: {
43
+ label: t("neetoThankYou.thankYou.customize"),
44
+ description: t("neetoThankYou.thankYou.customizeDescription"),
45
+ kind: "custom_message"
46
+ },
47
+ externalLink: {
48
+ label: t("neetoThankYou.thankYou.externalLink"),
49
+ description: t("neetoThankYou.thankYou.externalLinkDescription"),
50
+ kind: "redirect_to_url"
51
+ }
52
+ };
53
+ const DEFAULT_IMAGE_PROPERTIES = {
54
+ imageSignedId: null,
55
+ imageUrl: ""
56
+ };
57
+ const EXTERNAL_URL_PREFIX = "https://";
58
+ const THANK_YOU_TEXT_ALIGNMENTS = {
59
+ left: "left",
60
+ center: "center"
61
+ };
62
+
63
+ function _extends$1() {
64
+ _extends$1 = Object.assign ? Object.assign.bind() : function (target) {
65
+ for (var i = 1; i < arguments.length; i++) {
66
+ var source = arguments[i];
67
+ for (var key in source) {
68
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
69
+ target[key] = source[key];
70
+ }
71
+ }
72
+ }
73
+ return target;
74
+ };
75
+ return _extends$1.apply(this, arguments);
76
+ }
77
+
78
+ const IMAGE_SIZE_LIMIT = 1; // MB
79
+ const IMAGE_UPLOADER_CONFIG = {
80
+ maxImageSize: IMAGE_SIZE_LIMIT
81
+ };
82
+
83
+ const Image = () => {
84
+ const {
85
+ setFieldValue,
86
+ values
87
+ } = useFormikContext();
88
+ const handleImageChange = image => {
89
+ if (isEmpty(image.signedId)) {
90
+ setFieldValue("imageUrl", "");
91
+ setFieldValue("imageSignedId", null);
92
+ return;
93
+ }
94
+ setFieldValue("imageUrl", image.url);
95
+ setFieldValue("imageSignedId", image.signedId);
96
+ };
97
+ return /*#__PURE__*/React__default.createElement(ImageUploader, {
98
+ className: "h-60",
99
+ key: values.imageUrl,
100
+ src: values.imageUrl,
101
+ uploadConfig: IMAGE_UPLOADER_CONFIG,
102
+ onUploadComplete: handleImageChange
103
+ });
104
+ };
105
+
106
+ const ResubmissionWarningModal = withT(_ref => {
107
+ let {
108
+ t,
109
+ isOpen,
110
+ setIsOpen,
111
+ uniqueSubmissionLink
112
+ } = _ref;
113
+ return /*#__PURE__*/React__default.createElement(Modal, {
114
+ isOpen,
115
+ onClose: () => setIsOpen(false)
116
+ }, /*#__PURE__*/React__default.createElement(Modal.Header, null, /*#__PURE__*/React__default.createElement(Typography, {
117
+ style: "h3",
118
+ weight: "semibold"
119
+ }, t("neetoThankYou.common.alert"), "!")), /*#__PURE__*/React__default.createElement(Modal.Body, null, t("neetoThankYou.thankYou.resubmissionWarning")), /*#__PURE__*/React__default.createElement(Modal.Footer, {
120
+ className: "space-x-2"
121
+ }, /*#__PURE__*/React__default.createElement(Button, {
122
+ label: t("neetoThankYou.common.ok"),
123
+ style: "tertiary",
124
+ onClick: () => setIsOpen(false)
125
+ }), /*#__PURE__*/React__default.createElement(Button, {
126
+ label: t("neetoThankYou.thankYou.uniqueSubmissionLinkText"),
127
+ to: uniqueSubmissionLink
128
+ })));
129
+ });
130
+
131
+ const Customize = _ref => {
132
+ let {
133
+ editorRef,
134
+ uniqueSubmissionEnabled,
135
+ hasImageUploader,
136
+ uniqueSubmissionLink,
137
+ entityId,
138
+ disableSocialShare,
139
+ disableSubmitAnotherResponse,
140
+ editorProps
141
+ } = _ref;
142
+ const [isUniqueSubmissionWarningModalOpen, setIsUniqueSubmissionWarningModalOpen] = useState(false);
143
+ const {
144
+ t
145
+ } = useTranslation();
146
+ const {
147
+ values,
148
+ setFieldValue
149
+ } = useFormikContext();
150
+ const {
151
+ data: {
152
+ thankYouConfiguration
153
+ } = {},
154
+ isFetching
155
+ } = useShowThankYouConfiguration({
156
+ entityId
157
+ });
158
+ useEffect(() => {
159
+ if (isFetching) return;
160
+ setFieldValue("message", thankYouConfiguration.message);
161
+ editorRef.current.editor?.commands.setContent(thankYouConfiguration.message);
162
+ }, [isFetching]);
163
+ const handleResubmitLinkChange = event => {
164
+ uniqueSubmissionEnabled ? setIsUniqueSubmissionWarningModalOpen(true) : setFieldValue("showResubmitLink", event.target.checked);
165
+ };
166
+ return /*#__PURE__*/React__default.createElement("div", {
167
+ className: "flex flex-col gap-4"
168
+ }, hasImageUploader && /*#__PURE__*/React__default.createElement("div", {
169
+ className: "flex flex-col gap-2"
170
+ }, /*#__PURE__*/React__default.createElement(Label$1, null, t("neetoThankYou.thankYou.imageLabel")), /*#__PURE__*/React__default.createElement(Image, null)), /*#__PURE__*/React__default.createElement("div", {
171
+ className: "flex flex-col gap-2"
172
+ }, /*#__PURE__*/React__default.createElement(FormikEditor, _extends$1({
173
+ required: true,
174
+ "data-cy": "thank-you-message-editor",
175
+ label: t("neetoThankYou.thankYou.messageLabel"),
176
+ name: "message",
177
+ ref: editorRef
178
+ }, editorProps))), !disableSocialShare && /*#__PURE__*/React__default.createElement(Switch, {
179
+ label: t("neetoThankYou.thankYou.socialShareIcons"),
180
+ name: "socialSharingEnabled"
181
+ }), !disableSubmitAnotherResponse && /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(Switch, {
182
+ label: t("neetoThankYou.thankYou.showResubmitLink"),
183
+ name: "showResubmitLink",
184
+ className: classNames({
185
+ "neeto-ui-switch--disabled": uniqueSubmissionEnabled
186
+ }),
187
+ onChange: handleResubmitLinkChange
188
+ }), values.showResubmitLink && /*#__PURE__*/React__default.createElement(Input, {
189
+ required: true,
190
+ label: t("neetoThankYou.thankYou.resubmitLinkText"),
191
+ name: "resubmitLinkText"
192
+ })), /*#__PURE__*/React__default.createElement(ResubmissionWarningModal, {
193
+ uniqueSubmissionLink,
194
+ isOpen: isUniqueSubmissionWarningModalOpen,
195
+ setIsOpen: setIsUniqueSubmissionWarningModalOpen
196
+ }));
197
+ };
198
+
199
+ var _ellipse, _ellipse2, _ellipse3;
200
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
201
+ const SvgBrowserControls = props => /*#__PURE__*/React.createElement("svg", _extends({
202
+ xmlns: "http://www.w3.org/2000/svg",
203
+ width: 43,
204
+ height: 13,
205
+ fill: "none"
206
+ }, props), _ellipse || (_ellipse = /*#__PURE__*/React.createElement("ellipse", {
207
+ cx: 6.405,
208
+ cy: 6.644,
209
+ fill: "#FFEFED",
210
+ rx: 5.745,
211
+ ry: 5.859
212
+ })), _ellipse2 || (_ellipse2 = /*#__PURE__*/React.createElement("ellipse", {
213
+ cx: 37.044,
214
+ cy: 6.644,
215
+ fill: "#98F3F4",
216
+ rx: 5.745,
217
+ ry: 5.859
218
+ })), _ellipse3 || (_ellipse3 = /*#__PURE__*/React.createElement("ellipse", {
219
+ cx: 21.725,
220
+ cy: 6.644,
221
+ fill: "#FFF2D7",
222
+ rx: 5.745,
223
+ ry: 5.859
224
+ })));
225
+
226
+ const MemoizedEditorContent = /*#__PURE__*/React__default.memo(EditorContent);
227
+ const Preview = _ref => {
228
+ let {
229
+ socialHandles,
230
+ thankYouTextAlignment,
231
+ resubmitLink,
232
+ publicLinkId,
233
+ isPublished,
234
+ appName,
235
+ brandingInfo
236
+ } = _ref;
237
+ const {
238
+ values
239
+ } = useFormikContext();
240
+ const {
241
+ t
242
+ } = useTranslation();
243
+ return /*#__PURE__*/React__default.createElement("div", {
244
+ className: "flex flex-col"
245
+ }, /*#__PURE__*/React__default.createElement(Typography, {
246
+ className: "mb-3 block md:hidden",
247
+ lineHeight: "normal",
248
+ style: "h3",
249
+ weight: "semibold"
250
+ }, t("neetoThankYou.thankYou.preview")), /*#__PURE__*/React__default.createElement("div", {
251
+ className: classNames("neeto-thank-you-configuration-preview", {
252
+ "neeto-thank-you-configuration-alignment--left": thankYouTextAlignment === THANK_YOU_TEXT_ALIGNMENTS.left,
253
+ "neeto-thank-you-configuration-alignment--center": thankYouTextAlignment === THANK_YOU_TEXT_ALIGNMENTS.center,
254
+ "pointer-events-none": !isPublished
255
+ })
256
+ }, /*#__PURE__*/React__default.createElement("div", {
257
+ className: "neeto-thank-you-configuration-preview__browser-header"
258
+ }, /*#__PURE__*/React__default.createElement(SvgBrowserControls, null)), /*#__PURE__*/React__default.createElement("div", {
259
+ className: "neeto-thank-you-configuration"
260
+ }, /*#__PURE__*/React__default.createElement("main", {
261
+ className: "neeto-thank-you-configuration__main"
262
+ }, /*#__PURE__*/React__default.createElement("div", {
263
+ className: "neeto-thank-you-configuration__box"
264
+ }, !isEmpty(values?.imageUrl) && /*#__PURE__*/React__default.createElement("div", {
265
+ className: "neeto-thank-you-configuration__img"
266
+ }, /*#__PURE__*/React__default.createElement("img", {
267
+ alt: "",
268
+ src: values.imageUrl
269
+ })), values?.message && /*#__PURE__*/React__default.createElement("div", {
270
+ className: "neeto-thank-you-configuration__description"
271
+ }, /*#__PURE__*/React__default.createElement(MemoizedEditorContent, {
272
+ content: values.message,
273
+ "data-cy": "preview-editor-content"
274
+ })), values?.showResubmitLink && /*#__PURE__*/React__default.createElement("a", {
275
+ className: "neeto-thank-you-configuration__resubmit",
276
+ href: resubmitLink
277
+ }, values?.resubmitLinkText ?? t("neetoThankYou.thankYou.resubmit")), values?.socialSharingEnabled && /*#__PURE__*/React__default.createElement(SocialShare, {
278
+ publicLinkId,
279
+ socialHandles
280
+ })))), values?.brandingEnabled && /*#__PURE__*/React__default.createElement(BrandingInfo, {
281
+ appName,
282
+ brandingInfo
283
+ })));
284
+ };
285
+
286
+ const ExternalLink = () => {
287
+ const {
288
+ t
289
+ } = useTranslation();
290
+ return /*#__PURE__*/React__default.createElement(Input, {
291
+ autoFocus: true,
292
+ required: true,
293
+ label: t("neetoThankYou.thankYou.link"),
294
+ name: "redirectUrl",
295
+ placeholder: EXTERNAL_URL_PREFIX,
296
+ prefix: /*#__PURE__*/React__default.createElement(Link, null)
297
+ });
298
+ };
299
+
300
+ const Label = _ref => {
301
+ let {
302
+ label,
303
+ description,
304
+ kind
305
+ } = _ref;
306
+ return /*#__PURE__*/React__default.createElement(Typography, {
307
+ className: "neeto-ui-text-gray-700",
308
+ "data-cy": `neeto-thank-you-configuration-${hyphenate(kind)}-label`,
309
+ style: "body2",
310
+ weight: "semibold"
311
+ }, label, /*#__PURE__*/React__default.createElement("span", {
312
+ className: "block text-xs font-normal leading-snug",
313
+ "data-cy": `neeto-thank-you-configuration-${hyphenate(kind)}-description`
314
+ }, description));
315
+ };
316
+
317
+ const buildValidationSchema = function () {
318
+ let allowEmptyCustomMessage = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
319
+ return yup.object().shape({
320
+ kind: yup.string().required(),
321
+ message: yup.string().test("message", t("neetoThankYou.thankYou.validations.messageRequired"), value => allowEmptyCustomMessage || !isEditorEmpty(value)),
322
+ socialSharingEnabled: yup.bool(),
323
+ showResubmitLink: yup.bool(),
324
+ resubmitLinkText: yup.string().when("showResubmitLink", {
325
+ is: true,
326
+ then: yup.string().required(t("neetoThankYou.thankYou.validations.resubmitLinkTextIsRequired"))
327
+ }),
328
+ redirectUrl: yup.string().when("kind", {
329
+ is: FORM_OPTIONS.externalLink.kind,
330
+ then: yup.string().url(t("neetoThankYou.thankYou.validations.invalidLink")).required(t("neetoThankYou.thankYou.validations.invalidLink")).when("kind", {
331
+ is: FORM_OPTIONS.customize.kind,
332
+ then: yup.string()
333
+ })
334
+ })
335
+ });
336
+ };
337
+
338
+ const Form = _ref => {
339
+ let {
340
+ socialHandles,
341
+ entityId,
342
+ publicLinkId,
343
+ hasImageUploader,
344
+ uniqueSubmissionEnabled,
345
+ uniqueSubmissionLink,
346
+ redirectToOnCancel,
347
+ thankYouTextAlignment,
348
+ resubmitLink,
349
+ isPublished,
350
+ disableSubmitAnotherResponse,
351
+ disableRadioSelection,
352
+ appName,
353
+ blockNavigation,
354
+ onConfigUpdateSuccess,
355
+ brandingInfo,
356
+ editorProps,
357
+ preview: CustomPreview,
358
+ allowEmptyCustomMessage
359
+ } = _ref;
360
+ const {
361
+ data: {
362
+ thankYouConfiguration
363
+ } = {},
364
+ isLoading
365
+ } = useShowThankYouConfiguration({
366
+ entityId
367
+ });
368
+ const {
369
+ mutate: updateThankYouConfiguration,
370
+ isLoading: isUpdatingForm
371
+ } = useUpdateThankYouConfiguration();
372
+ const editorRef = useRef({
373
+ editor: {}
374
+ });
375
+ if (isLoading) {
376
+ return /*#__PURE__*/React__default.createElement("div", {
377
+ className: "flex h-full w-full items-center justify-center"
378
+ }, /*#__PURE__*/React__default.createElement(PageLoader, null));
379
+ }
380
+ const resetEditor = () => editorRef.current.editor?.commands.setContent(thankYouConfiguration.message);
381
+ return /*#__PURE__*/React__default.createElement(NeetoUIForm, {
382
+ formikProps: {
383
+ enableReinitialize: true,
384
+ initialValues: {
385
+ ...DEFAULT_IMAGE_PROPERTIES,
386
+ ...thankYouConfiguration
387
+ },
388
+ validationSchema: buildValidationSchema(allowEmptyCustomMessage),
389
+ onSubmit: values => updateThankYouConfiguration({
390
+ entityId,
391
+ payload: {
392
+ ...values,
393
+ image: values.imageSignedId
394
+ }
395
+ }, {
396
+ onSuccess: function () {
397
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
398
+ args[_key] = arguments[_key];
399
+ }
400
+ return onConfigUpdateSuccess(args, thankYouConfiguration);
401
+ }
402
+ })
403
+ }
404
+ }, _ref2 => {
405
+ let {
406
+ values
407
+ } = _ref2;
408
+ return /*#__PURE__*/React__default.createElement("div", {
409
+ className: "grid grid-cols-1 gap-10 pb-6 md:grid-cols-2 md:gap-6"
410
+ }, /*#__PURE__*/React__default.createElement("div", {
411
+ className: "flex flex-col"
412
+ }, blockNavigation && /*#__PURE__*/React__default.createElement(BlockNavigation, null), !disableRadioSelection && /*#__PURE__*/React__default.createElement("div", {
413
+ className: "mb-6 w-full"
414
+ }, /*#__PURE__*/React__default.createElement(Radio, {
415
+ containerClassName: "grid grid-cols-1 sm:grid-cols-2 gap-6 items-stretch w-full",
416
+ name: "kind"
417
+ }, Object.values(FORM_OPTIONS).map(option => /*#__PURE__*/React__default.createElement(Radio.Item, {
418
+ key: option.kind,
419
+ label: /*#__PURE__*/React__default.createElement(Label, option),
420
+ name: "kind",
421
+ value: option.kind,
422
+ className: classNames("neeto-thank-you-configuration-radio__item", {
423
+ active: values.kind === option.kind
424
+ })
425
+ })))), values.kind === FORM_OPTIONS.customize.kind ? /*#__PURE__*/React__default.createElement(Customize, {
426
+ disableSubmitAnotherResponse,
427
+ editorProps,
428
+ editorRef,
429
+ entityId,
430
+ hasImageUploader,
431
+ uniqueSubmissionEnabled,
432
+ uniqueSubmissionLink,
433
+ disableSocialShare: isEmpty(socialHandles)
434
+ }) : /*#__PURE__*/React__default.createElement(ExternalLink, null), /*#__PURE__*/React__default.createElement(ActionBlock, {
435
+ className: "mt-6",
436
+ isSubmitting: isUpdatingForm,
437
+ cancelButtonProps: {
438
+ "data-cy": "neeto-thank-you-configuration-cancel-button",
439
+ ...(redirectToOnCancel ? {
440
+ to: redirectToOnCancel,
441
+ onClick: noop
442
+ } : {
443
+ type: "reset",
444
+ onClick: resetEditor
445
+ })
446
+ },
447
+ submitButtonProps: {
448
+ "data-cy": "neeto-thank-you-configuration-save-button"
449
+ }
450
+ })), values.kind === FORM_OPTIONS.customize.kind && (CustomPreview ? /*#__PURE__*/React__default.createElement(CustomPreview, {
451
+ values
452
+ }) : /*#__PURE__*/React__default.createElement(Preview, {
453
+ appName,
454
+ brandingInfo,
455
+ isPublished,
456
+ publicLinkId,
457
+ resubmitLink,
458
+ socialHandles,
459
+ thankYouTextAlignment
460
+ })));
461
+ });
462
+ };
463
+
464
+ const Header = _ref => {
465
+ let {
466
+ breadcrumbs
467
+ } = _ref;
468
+ const {
469
+ t
470
+ } = useTranslation();
471
+ return /*#__PURE__*/React__default.createElement("div", {
472
+ className: "w-full px-6"
473
+ }, /*#__PURE__*/React__default.createElement(NeetoUIHeader, {
474
+ breadcrumbs: breadcrumbs,
475
+ size: "small",
476
+ title: t("neetoThankYou.common.thankYou")
477
+ }));
478
+ };
479
+
480
+ const ConfigureThankYou = _ref => {
481
+ let {
482
+ breadcrumbs,
483
+ isPublished,
484
+ entityId,
485
+ publicLinkId,
486
+ resubmitLink,
487
+ redirectToOnCancel,
488
+ socialHandles = [],
489
+ uniqueSubmissionLink = "",
490
+ uniqueSubmissionEnabled = false,
491
+ hasImageUploader = false,
492
+ disableSubmitAnotherResponse = false,
493
+ disableRadioSelection = false,
494
+ thankYouTextAlignment = THANK_YOU_TEXT_ALIGNMENTS.center,
495
+ customHeader,
496
+ appName,
497
+ blockNavigation = false,
498
+ onConfigUpdateSuccess = noop,
499
+ brandingInfo,
500
+ editorProps = {},
501
+ preview,
502
+ allowEmptyCustomMessage = false
503
+ } = _ref;
504
+ return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, customHeader || /*#__PURE__*/React__default.createElement(Header, {
505
+ breadcrumbs
506
+ }), /*#__PURE__*/React__default.createElement(Scrollable, {
507
+ className: "w-full p-6 pt-0"
508
+ }, /*#__PURE__*/React__default.createElement("div", {
509
+ className: "mx-auto h-full max-w-7xl"
510
+ }, /*#__PURE__*/React__default.createElement(Form, {
511
+ allowEmptyCustomMessage,
512
+ appName,
513
+ blockNavigation,
514
+ brandingInfo,
515
+ disableRadioSelection,
516
+ disableSubmitAnotherResponse,
517
+ editorProps,
518
+ entityId,
519
+ hasImageUploader,
520
+ isPublished,
521
+ onConfigUpdateSuccess,
522
+ preview,
523
+ publicLinkId,
524
+ redirectToOnCancel,
525
+ resubmitLink,
526
+ socialHandles,
527
+ thankYouTextAlignment,
528
+ uniqueSubmissionEnabled,
529
+ uniqueSubmissionLink
530
+ }))));
531
+ };
532
+
533
+ export { ConfigureThankYou as default };
534
+ //# sourceMappingURL=ConfigureThankYou.js.map