@bigbinary/neeto-thank-you-frontend 1.0.28 → 1.0.30
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 +125 -49
- package/app/javascript/src/translations/en.json +0 -1
- package/dist/index.cjs.js +19 -15
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.js +18 -15
- package/dist/index.js.map +1 -1
- package/package.json +11 -11
- package/types.d.ts +4 -0
package/README.md
CHANGED
|
@@ -1,59 +1,76 @@
|
|
|
1
1
|
[](https://neeto-engineering.neetoci.com/projects/neeto-thank-you-nano)
|
|
2
2
|
|
|
3
3
|
# neeto-thank-you-nano
|
|
4
|
-
|
|
4
|
+
|
|
5
|
+
The `neeto-thank-you-nano` manages the "Thank You" configuration page across
|
|
6
|
+
neeto applications. The nano exports the `@bigbinary/neeto-thank-you-frontend`
|
|
7
|
+
NPM package and `neeto-thank-you-engine` Rails engine for development.
|
|
5
8
|
|
|
6
9
|
# Contents
|
|
10
|
+
|
|
7
11
|
1. [Development with Host Application](#development-with-host-application)
|
|
8
12
|
- [Engine](#engine)
|
|
9
|
-
|
|
10
|
-
|
|
13
|
+
- [Installation](#installation)
|
|
14
|
+
- [Usage](#usage)
|
|
11
15
|
- [Frontend package](#frontend-package)
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
16
|
+
- [Installation](#installation-1)
|
|
17
|
+
- [Components](#components)
|
|
18
|
+
- [Hooks](#hooks)
|
|
15
19
|
2. [Instructions for Publishing](#instructions-for-publishing)
|
|
16
20
|
|
|
17
21
|
# Development with Host Application
|
|
22
|
+
|
|
18
23
|
## Engine
|
|
19
|
-
|
|
24
|
+
|
|
25
|
+
The engine is used to manage "Thank you" page configurations within an
|
|
26
|
+
organization.
|
|
20
27
|
|
|
21
28
|
### Installation
|
|
29
|
+
|
|
22
30
|
1. Add this line to your application's Gemfile:
|
|
23
|
-
```ruby
|
|
24
|
-
source "NEETO_GEM_SERVER_URL" do
|
|
25
|
-
# ..existing gems
|
|
26
31
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
32
|
+
```ruby
|
|
33
|
+
source "NEETO_GEM_SERVER_URL" do
|
|
34
|
+
# ..existing gems
|
|
35
|
+
|
|
36
|
+
gem 'neeto-thank-you-engine'
|
|
37
|
+
end
|
|
38
|
+
```
|
|
39
|
+
|
|
30
40
|
2. And then execute:
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
41
|
+
```ruby
|
|
42
|
+
bundle install
|
|
43
|
+
```
|
|
34
44
|
3. Add this line to your application's `config/routes.rb` file:
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
4. Run the following command to copy the migrations from the engine to the host
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
45
|
+
```ruby
|
|
46
|
+
mount NeetoThankYouEngine::Engine => "/neeto_thank_you_engine"
|
|
47
|
+
```
|
|
48
|
+
4. Run the following command to copy the migrations from the engine to the host
|
|
49
|
+
application:
|
|
50
|
+
```ruby
|
|
51
|
+
bundle exec rails neeto_thank_you_engine:install:migrations
|
|
52
|
+
```
|
|
42
53
|
5. Add the migrations to the database:
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
54
|
+
```ruby
|
|
55
|
+
bundle exec rails db:migrate
|
|
56
|
+
```
|
|
57
|
+
|
|
46
58
|
### Usage
|
|
59
|
+
|
|
47
60
|
You can learn more about the setup and usage here:
|
|
61
|
+
|
|
48
62
|
1. [Models](/docs/engine/models.md)
|
|
49
63
|
2. [Controllers](/docs/engine/controllers.md)
|
|
50
64
|
|
|
51
65
|
## Frontend package
|
|
66
|
+
|
|
52
67
|
The package exports two components: `ConfigureThankYou` and `ShowThankYou`.
|
|
53
68
|
|
|
54
|
-
The package also exports two hooks: `useShowThankYouPage` and
|
|
69
|
+
The package also exports two hooks: `useShowThankYouPage` and
|
|
70
|
+
`useShowThankYouConfiguration`
|
|
55
71
|
|
|
56
72
|
### Installation
|
|
73
|
+
|
|
57
74
|
Install the latest `neeto-thank-you-nano` package using the below command:
|
|
58
75
|
|
|
59
76
|
```zsh
|
|
@@ -61,34 +78,57 @@ yarn add @bigbinary/neeto-thank-you-frontend
|
|
|
61
78
|
```
|
|
62
79
|
|
|
63
80
|
### Instructions for development
|
|
64
|
-
|
|
81
|
+
|
|
82
|
+
Check the
|
|
83
|
+
[Frontend package development guide](https://neeto-engineering.neetokb.com/p/a-d34cb4b0)
|
|
84
|
+
for step-by-step instructions to develop the frontend package.
|
|
65
85
|
|
|
66
86
|
### Components
|
|
87
|
+
|
|
67
88
|
#### `ConfigureThankYou` ([source code](https://github.com/bigbinary/neeto-thank-you-nano/blob/f7c53e11319268eac4de3bd5642e228063d431fb/app/javascript/src/components/ConfigureThankYou/index.jsx))
|
|
68
|
-
|
|
89
|
+
|
|
90
|
+
This component manages the configuration of the "Thank You" page in the host
|
|
91
|
+
application.
|
|
69
92
|
|
|
70
93
|
##### Props
|
|
94
|
+
|
|
71
95
|
- `breadcrumbs` - Set the header component's breadcrumbs
|
|
72
96
|
- `socialHandles` - Set the URLs for sharing to social media
|
|
73
|
-
- `isPublished` - Boolean to manage pointer events in the "Thank You" page
|
|
97
|
+
- `isPublished` - Boolean to manage pointer events in the "Thank You" page
|
|
98
|
+
configuration preview
|
|
74
99
|
- `entityId` - Set the entity ID associated with the "Thank You" page
|
|
75
|
-
- `publicLinkId` - Set the public link ID of the entity associated with the
|
|
76
|
-
|
|
100
|
+
- `publicLinkId` - Set the public link ID of the entity associated with the
|
|
101
|
+
thank you configuration for social media sharing
|
|
102
|
+
- `hasImageUploader` - Boolean to show the image uploader section in the thank
|
|
103
|
+
you configuration page
|
|
77
104
|
- `uniqueSubmissionEnabled` - Boolean to show link for unique submission
|
|
78
105
|
- `uniqueSubmissionLink` - Set link for unique submission
|
|
79
106
|
- `resubmitLink` - Set link for resubmission
|
|
80
107
|
- `redirectToOnCancel` - Set path to redirect to after cancelling submission
|
|
81
|
-
- `thankYouTextAlignment` - Set alignment of the "Thank You" text in "Thank You"
|
|
108
|
+
- `thankYouTextAlignment` - Set alignment of the "Thank You" text in "Thank You"
|
|
109
|
+
page
|
|
82
110
|
- `customHeader` - Accepts a React Node & replaces the default Header.
|
|
83
|
-
- `appName` - Accepts appName, which will be used for branding
|
|
84
|
-
|
|
85
|
-
- `
|
|
86
|
-
|
|
111
|
+
- `appName` - Accepts appName, which will be used for branding
|
|
112
|
+
`Made with {{appName}}` [default: "neetoForm"].
|
|
113
|
+
- `disableSubmitAnotherResponse` - Removes the toggle for submitting another
|
|
114
|
+
response, incase of neetoForm [default: false].
|
|
115
|
+
- `disableRadioSelection` - Removes the radio selector for
|
|
116
|
+
`Customize thank you page` & `Redirect to external link` [default: false]
|
|
117
|
+
- `blockNavigation` - Boolean to show the block navigation alert in the thank
|
|
118
|
+
you configuration page when there are unsaved changes [default: false]
|
|
119
|
+
- `onConfigUpdateSuccess`: The callback function to be triggered when the
|
|
120
|
+
configuration is updated. The function's first argument corresponds to the
|
|
121
|
+
parameters passed to the `onSuccess` callback of React Query mutations, while
|
|
122
|
+
the second argument represents the previous configuration object.
|
|
87
123
|
|
|
88
124
|
##### Configuration
|
|
89
|
-
|
|
125
|
+
|
|
126
|
+
Refer to the [ConfigureThankYou](/docs/frontend/configure_thank_you.md) section
|
|
127
|
+
for detailed information on the available configurations for the
|
|
128
|
+
`ConfigureThankYou` component.
|
|
90
129
|
|
|
91
130
|
##### Usage
|
|
131
|
+
|
|
92
132
|
```jsx
|
|
93
133
|
import React from "react";
|
|
94
134
|
|
|
@@ -96,7 +136,19 @@ import { ConfigureThankYou } from "@bigbinary/neeto-thank-you-frontend";
|
|
|
96
136
|
|
|
97
137
|
const App = () => {
|
|
98
138
|
const breadcrumbs = [{ text: "Configure", link: "/configure" }];
|
|
99
|
-
const socialHandles = [
|
|
139
|
+
const socialHandles = [
|
|
140
|
+
{
|
|
141
|
+
icon: Facebook,
|
|
142
|
+
generateShareUrl: entityId => `https://www.facebook.com/${entityId}`,
|
|
143
|
+
},
|
|
144
|
+
];
|
|
145
|
+
|
|
146
|
+
const handleConfigUpdateSuccess = (
|
|
147
|
+
onSuccessCallbackParams,
|
|
148
|
+
previousConfiguration
|
|
149
|
+
) => {
|
|
150
|
+
// Add your logic here
|
|
151
|
+
};
|
|
100
152
|
|
|
101
153
|
return (
|
|
102
154
|
<>
|
|
@@ -114,33 +166,44 @@ const App = () => {
|
|
|
114
166
|
redirectToOnCancel={redirectToOnCancel}
|
|
115
167
|
thankYouTextAlignment={thankYouTextAlignment}
|
|
116
168
|
appName="neetoForm"
|
|
117
|
-
|
|
169
|
+
onConfigUpdateSuccess={handleConfigUpdateSuccess}
|
|
170
|
+
/>
|
|
118
171
|
</>
|
|
119
|
-
)
|
|
172
|
+
);
|
|
120
173
|
};
|
|
121
174
|
|
|
122
175
|
export default App;
|
|
123
176
|
```
|
|
124
177
|
|
|
125
178
|
#### `ShowThankYou` ([source code](https://github.com/bigbinary/neeto-thank-you-nano/blob/f7c53e11319268eac4de3bd5642e228063d431fb/app/javascript/src/components/ShowThankYou/index.jsx))
|
|
126
|
-
|
|
179
|
+
|
|
180
|
+
This component displays the "Thank You" page after submission as per the
|
|
181
|
+
configurations set in the host application.
|
|
127
182
|
|
|
128
183
|
##### Props
|
|
184
|
+
|
|
129
185
|
- `entityId` - Set the entity ID associated with the "Thank You" page
|
|
130
186
|
- `socialHandles` - Set the URLs for sharing to social media
|
|
131
187
|
- `isDraftPreview` - Boolean to generate the draft resubmission URL
|
|
132
188
|
- `resubmitLink` - Set link for resubmission
|
|
133
189
|
- `isThankYouPageLoading` - Boolean value to show the loading state
|
|
134
|
-
- `customPageLoader` - Specify a custom loader component to replace the default
|
|
190
|
+
- `customPageLoader` - Specify a custom loader component to replace the default
|
|
191
|
+
page loader.
|
|
135
192
|
|
|
136
193
|
##### Usage
|
|
194
|
+
|
|
137
195
|
```jsx
|
|
138
196
|
import React from "react";
|
|
139
197
|
|
|
140
198
|
import { ShowThankYou } from "@bigbinary/neeto-thank-you-frontend";
|
|
141
199
|
|
|
142
200
|
const App = () => {
|
|
143
|
-
const socialHandles = [
|
|
201
|
+
const socialHandles = [
|
|
202
|
+
{
|
|
203
|
+
icon: Facebook,
|
|
204
|
+
generateShareUrl: entityId => `https://www.facebook.com/${entityId}`,
|
|
205
|
+
},
|
|
206
|
+
];
|
|
144
207
|
|
|
145
208
|
return (
|
|
146
209
|
<>
|
|
@@ -152,7 +215,7 @@ const App = () => {
|
|
|
152
215
|
isThankYouPageLoading={isThankYouPageLoading}
|
|
153
216
|
/>
|
|
154
217
|
</>
|
|
155
|
-
)
|
|
218
|
+
);
|
|
156
219
|
};
|
|
157
220
|
|
|
158
221
|
export default App;
|
|
@@ -161,16 +224,21 @@ export default App;
|
|
|
161
224
|
### Hooks
|
|
162
225
|
|
|
163
226
|
#### `useShowThankYouPage` ([source code](https://github.com/bigbinary/neeto-thank-you-nano/blob/fd519090a7b0ce63db912bdf795872bbdb6f9194/app/javascript/src/hooks/reactQuery/useThankYouPageApi.js#L6))
|
|
227
|
+
|
|
164
228
|
This hook is used to fetch the "Thank You" page of the entity.
|
|
165
229
|
|
|
166
230
|
##### Props
|
|
231
|
+
|
|
167
232
|
- `entityId` - ID of the entity to load the thank you configuration
|
|
168
233
|
- `isTemplateView` - Boolean to check if the current page is the template view
|
|
169
234
|
|
|
170
235
|
##### Return value
|
|
171
|
-
|
|
236
|
+
|
|
237
|
+
Returns the `data` object which includes the `thankYouConfiguration` object
|
|
238
|
+
containing the thank you configuration for the entity.
|
|
172
239
|
|
|
173
240
|
##### Usage
|
|
241
|
+
|
|
174
242
|
```js
|
|
175
243
|
import { useShowThankYouPage } from "@bigbinary/neeto-thank-you-frontend";
|
|
176
244
|
|
|
@@ -181,19 +249,24 @@ const { data: { thankYouConfiguration } = {} } = useShowThankYouPage({
|
|
|
181
249
|
```
|
|
182
250
|
|
|
183
251
|
#### `useShowThankYouConfiguration` ([source code](https://github.com/bigbinary/neeto-thank-you-nano/blob/fd519090a7b0ce63db912bdf795872bbdb6f9194/app/javascript/src/hooks/reactQuery/useThankYouConfigurationApi.js#L6))
|
|
252
|
+
|
|
184
253
|
This hook is used to fetch the thank you configuration of the entity.
|
|
185
254
|
|
|
186
255
|
##### Props
|
|
256
|
+
|
|
187
257
|
- `entityId` - ID of the entity to load the thank you configuration
|
|
188
258
|
|
|
189
259
|
##### Return value
|
|
190
|
-
|
|
260
|
+
|
|
261
|
+
Returns the `data` object which includes the `thankYouConfiguration` object
|
|
262
|
+
containing the thank you configuration for the entity, and an `isLoading`
|
|
263
|
+
boolean.
|
|
191
264
|
|
|
192
265
|
##### Usage
|
|
266
|
+
|
|
193
267
|
```js
|
|
194
268
|
import { useShowThankYouConfiguration } from "@bigbinary/neeto-thank-you-frontend";
|
|
195
269
|
|
|
196
|
-
|
|
197
270
|
const {
|
|
198
271
|
isLoading: isThankYouActionLoading,
|
|
199
272
|
data: { thankYouConfiguration } = {},
|
|
@@ -201,4 +274,7 @@ const {
|
|
|
201
274
|
```
|
|
202
275
|
|
|
203
276
|
# Instructions for Publishing
|
|
204
|
-
|
|
277
|
+
|
|
278
|
+
Consult the
|
|
279
|
+
[building and releasing packages](https://neeto-engineering.neetokb.com/articles/building-and-releasing-packages)
|
|
280
|
+
guide for details on how to publish.
|
|
@@ -27,7 +27,6 @@
|
|
|
27
27
|
"socialShareHeading": "Share this neetoForm on social media",
|
|
28
28
|
"resubmissionWarning": "You have enabled unique submission for this form, please disable unique submission before enabling the resubmit link.",
|
|
29
29
|
"uniqueSubmissionLinkText": "Go to Unique submissions settings",
|
|
30
|
-
"poweredBy": "Powered by <strong>{{appName, anyCase}}</strong>",
|
|
31
30
|
"formBranding": "Build your own form using <a><span>neetoForm.</span></a> It’s free.",
|
|
32
31
|
"draftVersionForm": "You are using the draft version of the form. The data will not be submitted.",
|
|
33
32
|
"preview": "Preview",
|
package/dist/index.cjs.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var React = require('react');
|
|
6
|
+
var neetoCist = require('@bigbinary/neeto-cist');
|
|
6
7
|
var Scrollable = require('@bigbinary/neeto-molecules/Scrollable');
|
|
7
8
|
var i18next = require('i18next');
|
|
8
9
|
var neetoEditor = require('@bigbinary/neeto-editor');
|
|
@@ -17,8 +18,8 @@ var reactQuery = require('react-query');
|
|
|
17
18
|
var axios = require('axios');
|
|
18
19
|
var formik = require('formik');
|
|
19
20
|
var neetoImageUploaderFrontend = require('@bigbinary/neeto-image-uploader-frontend');
|
|
21
|
+
var MadeWith = require('@bigbinary/neeto-molecules/MadeWith');
|
|
20
22
|
var neetoIcons = require('@bigbinary/neeto-icons');
|
|
21
|
-
var neetoCist = require('@bigbinary/neeto-cist');
|
|
22
23
|
var NeetoUIHeader = require('@bigbinary/neeto-molecules/Header');
|
|
23
24
|
|
|
24
25
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
@@ -48,6 +49,7 @@ var yup__namespace = /*#__PURE__*/_interopNamespace(yup);
|
|
|
48
49
|
var classNames__default = /*#__PURE__*/_interopDefaultLegacy(classNames);
|
|
49
50
|
var PageLoader__default = /*#__PURE__*/_interopDefaultLegacy(PageLoader);
|
|
50
51
|
var axios__default = /*#__PURE__*/_interopDefaultLegacy(axios);
|
|
52
|
+
var MadeWith__default = /*#__PURE__*/_interopDefaultLegacy(MadeWith);
|
|
51
53
|
var NeetoUIHeader__default = /*#__PURE__*/_interopDefaultLegacy(NeetoUIHeader);
|
|
52
54
|
|
|
53
55
|
var FORM_OPTIONS = {
|
|
@@ -512,18 +514,9 @@ var Preview = function Preview(_ref) {
|
|
|
512
514
|
}
|
|
513
515
|
})))), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
514
516
|
className: "neeto-ui-bg-gray-100 flex w-full items-center justify-center px-4 py-1.5"
|
|
515
|
-
}, /*#__PURE__*/React__default["default"].createElement(
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
}, /*#__PURE__*/React__default["default"].createElement(reactI18next.Trans, {
|
|
519
|
-
components: {
|
|
520
|
-
strong: /*#__PURE__*/React__default["default"].createElement("strong", null)
|
|
521
|
-
},
|
|
522
|
-
i18nKey: "neetoThankYou.thankYou.poweredBy",
|
|
523
|
-
values: {
|
|
524
|
-
appName: appName || DEFAULT_APP_NAME
|
|
525
|
-
}
|
|
526
|
-
})))));
|
|
517
|
+
}, /*#__PURE__*/React__default["default"].createElement(MadeWith__default["default"], {
|
|
518
|
+
productName: appName || DEFAULT_APP_NAME
|
|
519
|
+
}))));
|
|
527
520
|
};
|
|
528
521
|
|
|
529
522
|
var ExternalLink = function ExternalLink() {
|
|
@@ -570,7 +563,8 @@ var Form = function Form(_ref) {
|
|
|
570
563
|
disableSubmitAnotherResponse = _ref.disableSubmitAnotherResponse,
|
|
571
564
|
disableRadioSelection = _ref.disableRadioSelection,
|
|
572
565
|
appName = _ref.appName,
|
|
573
|
-
blockNavigation = _ref.blockNavigation
|
|
566
|
+
blockNavigation = _ref.blockNavigation,
|
|
567
|
+
onConfigUpdateSuccess = _ref.onConfigUpdateSuccess;
|
|
574
568
|
var _useTranslation = reactI18next.useTranslation(),
|
|
575
569
|
t = _useTranslation.t;
|
|
576
570
|
var _useShowThankYouConfi = useShowThankYouConfiguration({
|
|
@@ -609,6 +603,13 @@ var Form = function Form(_ref) {
|
|
|
609
603
|
payload: _objectSpread(_objectSpread({}, values), {}, {
|
|
610
604
|
image: values.imageSignedId
|
|
611
605
|
})
|
|
606
|
+
}, {
|
|
607
|
+
onSuccess: function onSuccess() {
|
|
608
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
609
|
+
args[_key] = arguments[_key];
|
|
610
|
+
}
|
|
611
|
+
return onConfigUpdateSuccess(args, thankYouConfiguration);
|
|
612
|
+
}
|
|
612
613
|
});
|
|
613
614
|
}
|
|
614
615
|
}
|
|
@@ -716,7 +717,9 @@ var ConfigureThankYou = function ConfigureThankYou(_ref) {
|
|
|
716
717
|
customHeader = _ref.customHeader,
|
|
717
718
|
appName = _ref.appName,
|
|
718
719
|
_ref$blockNavigation = _ref.blockNavigation,
|
|
719
|
-
blockNavigation = _ref$blockNavigation === void 0 ? false : _ref$blockNavigation
|
|
720
|
+
blockNavigation = _ref$blockNavigation === void 0 ? false : _ref$blockNavigation,
|
|
721
|
+
_ref$onConfigUpdateSu = _ref.onConfigUpdateSuccess,
|
|
722
|
+
onConfigUpdateSuccess = _ref$onConfigUpdateSu === void 0 ? neetoCist.noop : _ref$onConfigUpdateSu;
|
|
720
723
|
return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, customHeader || /*#__PURE__*/React__default["default"].createElement(Header, {
|
|
721
724
|
breadcrumbs: breadcrumbs
|
|
722
725
|
}), /*#__PURE__*/React__default["default"].createElement(Scrollable__default["default"], {
|
|
@@ -731,6 +734,7 @@ var ConfigureThankYou = function ConfigureThankYou(_ref) {
|
|
|
731
734
|
entityId: entityId,
|
|
732
735
|
hasImageUploader: hasImageUploader,
|
|
733
736
|
isPublished: isPublished,
|
|
737
|
+
onConfigUpdateSuccess: onConfigUpdateSuccess,
|
|
734
738
|
publicLinkId: publicLinkId,
|
|
735
739
|
redirectToOnCancel: redirectToOnCancel,
|
|
736
740
|
resubmitLink: resubmitLink,
|