@capillarytech/creatives-library 7.10.39 → 7.10.41

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 (38) hide show
  1. package/containers/Assets/Gallery/tests/__snapshots__/reducer.test.js.snap +0 -2
  2. package/containers/Email/index.js +2 -3
  3. package/index.js +6 -0
  4. package/package.json +1 -1
  5. package/routes.js +5 -0
  6. package/services/api.js +6 -1
  7. package/v2Components/TemplatePreview/_templatePreview.scss +7 -0
  8. package/v2Components/TemplatePreview/assets/images/whatsapp_mobile_android.svg +2041 -0
  9. package/v2Components/TemplatePreview/index.js +57 -3
  10. package/v2Components/TemplatePreview/messages.js +8 -0
  11. package/v2Containers/Assets/Gallery/tests/__snapshots__/reducer.test.js.snap +0 -2
  12. package/v2Containers/Assets/images/whatsappIllustration.png +0 -0
  13. package/v2Containers/CreativesContainer/SlideBoxContent.js +31 -2
  14. package/v2Containers/CreativesContainer/SlideBoxHeader.js +31 -3
  15. package/v2Containers/CreativesContainer/constants.js +1 -0
  16. package/v2Containers/CreativesContainer/messages.js +4 -0
  17. package/v2Containers/Email/index.js +1 -3
  18. package/v2Containers/Line/Container/index.js +1 -1
  19. package/v2Containers/Templates/_templates.scss +43 -0
  20. package/v2Containers/Templates/actions.js +18 -10
  21. package/v2Containers/Templates/constants.js +3 -1
  22. package/v2Containers/Templates/index.js +296 -44
  23. package/v2Containers/Templates/messages.js +32 -0
  24. package/v2Containers/Templates/reducer.js +3 -1
  25. package/v2Containers/TemplatesV2/index.js +2 -0
  26. package/v2Containers/TemplatesV2/messages.js +4 -0
  27. package/v2Containers/Whatsapp/actions.js +34 -0
  28. package/v2Containers/Whatsapp/constants.js +125 -0
  29. package/v2Containers/Whatsapp/index.js +831 -0
  30. package/v2Containers/Whatsapp/index.scss +56 -0
  31. package/v2Containers/Whatsapp/messages.js +221 -0
  32. package/v2Containers/Whatsapp/reducer.js +54 -0
  33. package/v2Containers/Whatsapp/sagas.js +77 -0
  34. package/v2Containers/Whatsapp/selectors.js +12 -0
  35. package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +120831 -0
  36. package/v2Containers/Whatsapp/tests/index.test.js +132 -0
  37. package/v2Containers/Whatsapp/tests/mockData.js +10 -0
  38. package/v2Containers/Whatsapp/utils.js +106 -0
@@ -0,0 +1,56 @@
1
+ @import '~@capillarytech/cap-ui-library/styles/_variables';
2
+
3
+ .whatsapp-render-heading {
4
+ margin-top: $CAP_SPACE_16;
5
+ margin-bottom: 6px;
6
+ }
7
+ .whatsapp-template-name-desc {
8
+ margin-bottom: 6px;
9
+ }
10
+ .whatsapp-create-render-unsubscribe-text {
11
+ color: $FONT_COLOR_02;
12
+ margin: $CAP_SPACE_08 0px $CAP_SPACE_08 16px;
13
+ }
14
+ .whatsapp-edit-render-unsubscribe-text {
15
+ color: $FONT_COLOR_02;
16
+ }
17
+ .whatsapp-render-message-length {
18
+ text-align: right;
19
+ }
20
+ .whatsapp-create-template-message-input {
21
+ background-color: #fafbfc;
22
+ padding-top: $CAP_SPACE_16;
23
+ }
24
+ .whatsapp-template-message-error {
25
+ margin-left: $CAP_SPACE_16;
26
+ margin-right: $CAP_SPACE_16;
27
+ }
28
+ .whatsapp-scroll-div {
29
+ margin-bottom: 250px;
30
+ }
31
+ .whatsapp-category-tag {
32
+ margin-left: 8px;
33
+ }
34
+ .whatsapp-edit-alert-margin {
35
+ margin-top: 46px;
36
+ }
37
+ .whatsapp-edit-template-message-input {
38
+ background-color: #fafbfc;
39
+ padding: 0 $CAP_SPACE_16;
40
+ }
41
+ .whatsapp-edit-template-message-heading {
42
+ margin-top: $CAP_SPACE_16;
43
+ margin-bottom: $CAP_SPACE_08;
44
+ }
45
+ .whatsapp-edit-disabled {
46
+ cursor: not-allowed;
47
+ opacity: 0.4;
48
+ }
49
+ #whatsapp-create-template-message-input {
50
+ margin-left: $CAP_SPACE_16;
51
+ margin-right: $CAP_SPACE_16;
52
+ width: 95%;
53
+ }
54
+ #select-whatsapp-category {
55
+ width: 100%;
56
+ }
@@ -0,0 +1,221 @@
1
+ import { defineMessages } from 'react-intl';
2
+ const prefix = `creatives.containersV2.Whatsapp`;
3
+ export default defineMessages({
4
+ templateNameLabel: {
5
+ id: `${prefix}.templateNameLabel`,
6
+ defaultMessage: 'Template name',
7
+ },
8
+ templateNameDesc: {
9
+ id: `${prefix}.templateNameDesc`,
10
+ defaultMessage:
11
+ 'Must be a unique name and can only contain lowercase alphanumeric characters and underscores.',
12
+ },
13
+ templateNamePlaceholder: {
14
+ id: `${prefix}.templateNamePlaceholder`,
15
+ defaultMessage: 'Enter template name',
16
+ },
17
+ templateNameTooltip: {
18
+ id: `${prefix}.templateNameTooltip`,
19
+ defaultMessage: `Tip : Use a name that helps WhatsApp's reviewer understand the purpose of your message, for example "order_delivery" rather than "template_1"`,
20
+ },
21
+ emptyTemplateNameErrorMessage: {
22
+ id: `${prefix}.emptyTemplateNameErrorMessage`,
23
+ defaultMessage: 'Template name cannot be empty',
24
+ },
25
+ templateNameRegexErrorMessage: {
26
+ id: `${prefix}.templateNameRegexErrorMessage`,
27
+ defaultMessage:
28
+ 'Template name can only contain lowercase alphanumeric characters and underscores',
29
+ },
30
+ templateCategoryLabel: {
31
+ id: `${prefix}.templateCategoryLabel`,
32
+ defaultMessage: 'Template category',
33
+ },
34
+ select: {
35
+ id: `${prefix}.select`,
36
+ defaultMessage: 'Select',
37
+ },
38
+ accountUpdate: {
39
+ id: `${prefix}.accountUpdate`,
40
+ defaultMessage: 'Account update',
41
+ },
42
+ accountUpdateTooltip: {
43
+ id: `${prefix}.accountUpdateTooltip`,
44
+ defaultMessage:
45
+ 'Let customers know about updates or changes to their accounts.',
46
+ },
47
+ alertUpdate: {
48
+ id: `${prefix}.alertUpdate`,
49
+ defaultMessage: 'Alert update',
50
+ },
51
+ alertUpdateTooltip: {
52
+ id: `${prefix}.alertUpdateTooltip`,
53
+ defaultMessage: 'Send important updates or news to customers.',
54
+ },
55
+ appointmentUpdate: {
56
+ id: `${prefix}.appointmentUpdate`,
57
+ defaultMessage: 'Appointment update',
58
+ },
59
+ appointmentUpdateTooltip: {
60
+ id: `${prefix}.appointmentUpdateTooltip`,
61
+ defaultMessage:
62
+ 'Send confirmations, reminders, or other updates to customers about their appointments.',
63
+ },
64
+ paymentUpdate: {
65
+ id: `${prefix}.paymentUpdate`,
66
+ defaultMessage: 'Payment update',
67
+ },
68
+ paymentUpdateTooltip: {
69
+ id: `${prefix}.paymentUpdateTooltip`,
70
+ defaultMessage: 'Send a message to customers about their payment.',
71
+ },
72
+ reservationUpdate: {
73
+ id: `${prefix}.reservationUpdate`,
74
+ defaultMessage: 'Reservation update',
75
+ },
76
+ reservationUpdateTooltip: {
77
+ id: `${prefix}.reservationUpdateTooltip`,
78
+ defaultMessage:
79
+ 'Send confirmations, reminders, or other updates to customers about their reservations.',
80
+ },
81
+ messageLanguageLabel: {
82
+ id: `${prefix}.messageLanguageLabel`,
83
+ defaultMessage: 'Message language',
84
+ },
85
+ templateLanguageEnglish: {
86
+ id: `${prefix}.templateLanguageEnglish`,
87
+ defaultMessage: 'English',
88
+ },
89
+ mediaLabel: {
90
+ id: `${prefix}.mediaLabel`,
91
+ defaultMessage: 'Media',
92
+ },
93
+ mediaTextMessage: {
94
+ id: `${prefix}.mediaTextMessage`,
95
+ defaultMessage: 'Text Message',
96
+ },
97
+ mediaImage: {
98
+ id: `${prefix}.mediaImage`,
99
+ defaultMessage: 'Image',
100
+ },
101
+ mediaVideo: {
102
+ id: `${prefix}.mediaVideo`,
103
+ defaultMessage: 'Video',
104
+ },
105
+ disabledMediaTooltip: {
106
+ id: `${prefix}.disabledMediaTooltip`,
107
+ defaultMessage: 'Not yet enabled. Coming soon!',
108
+ },
109
+ templateMessageLabel: {
110
+ id: `${prefix}.templateMessageLabel`,
111
+ defaultMessage: 'Message',
112
+ },
113
+ templateMessageTooltip: {
114
+ id: `${prefix}.templateMessageTooltip`,
115
+ defaultMessage:
116
+ 'You can write variables by adding two curly brackets before the variable name and two curly brackets after the variable name.{br}{br}Tip :{br}It looks something like this: Hi {var},{br}so 1 is the variable name here.',
117
+ },
118
+ emptyTemplateMessageErrorMessage: {
119
+ id: `${prefix}.emptyTemplateMessageErrorMessage`,
120
+ defaultMessage: 'Template message cannot be empty',
121
+ },
122
+ templateMessagePlaceholder: {
123
+ id: `${prefix}.templateMessagePlaceholder`,
124
+ defaultMessage: 'Enter message with variable',
125
+ },
126
+ templateMessageLength: {
127
+ id: `${prefix}.templateMessageLength`,
128
+ defaultMessage: 'Characters count: {currentLength}/{maxLength}',
129
+ },
130
+ templateMessageLengthError: {
131
+ id: `${prefix}.templateMessageLengthError`,
132
+ defaultMessage: 'Template message length cannot exceed 1024',
133
+ },
134
+ templateMessageUnsubscribeText: {
135
+ id: `${prefix}.templateMessageUnsubscribeText`,
136
+ defaultMessage: 'Click {{unsubscribe}} to unsubscribe',
137
+ },
138
+ unsubscribeTextTooltip: {
139
+ id: `${prefix}.unsubscribeTextTooltip`,
140
+ defaultMessage: 'This is non-editable',
141
+ },
142
+ repetativeVars: {
143
+ id: `${prefix}.repetativeVars`,
144
+ defaultMessage: 'Variables cannot be repeated',
145
+ },
146
+ unknownVars: {
147
+ id: `${prefix}.unknownVars`,
148
+ defaultMessage:
149
+ 'Variable name should be numeric value from {{1}} to {{19}}',
150
+ },
151
+ noContentBetweenVars: {
152
+ id: `${prefix}.noContentBetweenVars`,
153
+ defaultMessage: 'Add atleast 1 character between 2 variables',
154
+ },
155
+ sequenceVars: {
156
+ id: `${prefix}.sequenceVars`,
157
+ defaultMessage:
158
+ 'Variable name should start from {{1}} and it should be in sequential order',
159
+ },
160
+ sendForApprovalButtonLabel: {
161
+ id: `${prefix}.sendForApprovalButtonLabel`,
162
+ defaultMessage: 'Send for approval',
163
+ },
164
+ cancelButtonLabel: {
165
+ id: `${prefix}.cancelButtonLabel`,
166
+ defaultMessage: 'Cancel',
167
+ },
168
+ whatsappCreateNotification: {
169
+ id: `${prefix}.whatsappCreateNotification`,
170
+ defaultMessage: '{name} has been sent for approval',
171
+ },
172
+ awaitingApproval: {
173
+ id: `${prefix}.awaitingApproval`,
174
+ defaultMessage: 'Awaiting approval',
175
+ },
176
+ approved: {
177
+ id: `${prefix}.approved`,
178
+ defaultMessage: 'Approved',
179
+ },
180
+ rejected: {
181
+ id: `${prefix}.rejected`,
182
+ defaultMessage: 'Rejected',
183
+ },
184
+ languageLabel: {
185
+ id: `${prefix}.languageLabel`,
186
+ defaultMessage: 'Language',
187
+ },
188
+ labelSeperator: {
189
+ id: `${prefix}.labelSeperator`,
190
+ defaultMessage: '|',
191
+ },
192
+ approvedStatusMsg: {
193
+ id: `${prefix}.approvedStatusMsg`,
194
+ defaultMessage: 'This template has been approved',
195
+ },
196
+ rejectedStatusMsg: {
197
+ id: `${prefix}.rejectedStatusMsg`,
198
+ defaultMessage: 'This template has been rejected',
199
+ },
200
+ awaitingStatusMsg: {
201
+ id: `${prefix}.awaitingStatusMsg`,
202
+ defaultMessage: 'This template is awaiting approval',
203
+ },
204
+ awaitingStatusDesc: {
205
+ id: `${prefix}.awaitingStatusDesc`,
206
+ defaultMessage:
207
+ 'The template has been sent for approval at {date}, {time}. It takes up to 48 hrs to get approved.',
208
+ },
209
+ addLabels: {
210
+ id: `${prefix}.addLabels`,
211
+ defaultMessage: 'Add labels',
212
+ },
213
+ inputplaceHolderText: {
214
+ id: `${prefix}.inputplaceHolderText`,
215
+ defaultMessage: '{value} Add labels or text or combination of both',
216
+ },
217
+ disabledEditTooltip: {
218
+ id: `${prefix}.disabledEditTooltip`,
219
+ defaultMessage: 'This template is non-editable as this is {status}',
220
+ },
221
+ });
@@ -0,0 +1,54 @@
1
+ import { fromJS } from 'immutable';
2
+ import {
3
+ TEMPLATE_CREATE_REQUEST,
4
+ TEMPLATE_CREATE_SUCCESS,
5
+ TEMPLATE_CREATE_FAILURE,
6
+ CLEAR_CREATE_RESPONSE_REQUEST,
7
+ GET_TEMPLATE_DETAILS_REQUEST,
8
+ GET_TEMPLATE_DETAILS_SUCCESS,
9
+ GET_TEMPLATE_DETAILS_FAILURE,
10
+ RESET_EDIT_TEMPLATE,
11
+ } from './constants';
12
+
13
+ const initialState = fromJS({ createTemplateInProgress: false });
14
+
15
+ function whatsappReducer(state = initialState, action) {
16
+ switch (action.type) {
17
+ case TEMPLATE_CREATE_REQUEST:
18
+ return state
19
+ .set('createTemplateInProgress', true)
20
+ .set('createTemplateError', false)
21
+ .set('createTemplateErrorMessage', fromJS(''));
22
+ case TEMPLATE_CREATE_SUCCESS:
23
+ return state
24
+ .set('createTemplateInProgress', false)
25
+ .set('response', action.data)
26
+ .set(
27
+ 'createTemplateError',
28
+ action.statusCode !== undefined && action.statusCode > 300,
29
+ )
30
+ .set('createTemplateErrorMessage', fromJS(action.errorMsg));
31
+ case TEMPLATE_CREATE_FAILURE:
32
+ return state
33
+ .set('createTemplateInProgress', false)
34
+ .set('createTemplateError', true)
35
+ .set('createTemplateErrorMessage', fromJS(action.errorMsg));
36
+ case CLEAR_CREATE_RESPONSE_REQUEST:
37
+ return state.set('response', {});
38
+ // FOR EDIT
39
+ case GET_TEMPLATE_DETAILS_REQUEST:
40
+ return state.set('getTemplateDetailsInProgress', true);
41
+ case GET_TEMPLATE_DETAILS_SUCCESS:
42
+ return state
43
+ .set('getTemplateDetailsInProgress', false)
44
+ .set('templateDetails', action.data);
45
+ case GET_TEMPLATE_DETAILS_FAILURE:
46
+ return state.set('getTemplateDetailsInProgress', false);
47
+ case RESET_EDIT_TEMPLATE:
48
+ return state.set('templateDetails', {});
49
+ default:
50
+ return state;
51
+ }
52
+ }
53
+
54
+ export default whatsappReducer;
@@ -0,0 +1,77 @@
1
+ import { take, cancel, call, put, takeLatest } from 'redux-saga/effects';
2
+ import { LOCATION_CHANGE } from 'react-router-redux';
3
+ import * as Api from '../../services/api';
4
+ import {
5
+ TEMPLATE_CREATE_REQUEST,
6
+ TEMPLATE_CREATE_SUCCESS,
7
+ TEMPLATE_CREATE_FAILURE,
8
+ WHATSAPP,
9
+ GET_TEMPLATE_DETAILS_REQUEST,
10
+ GET_TEMPLATE_DETAILS_SUCCESS,
11
+ GET_TEMPLATE_DETAILS_FAILURE,
12
+ } from './constants';
13
+
14
+ export function* sendForApprovalCreate({ payload, callback }) {
15
+ let errorMsg;
16
+ try {
17
+ const result = yield call(Api.createWhatsappTemplate, { payload });
18
+ if (result?.status?.code && result.status.code >= 400) {
19
+ errorMsg = result?.message || result.status.code;
20
+ throw errorMsg;
21
+ }
22
+ yield put({
23
+ type: TEMPLATE_CREATE_SUCCESS,
24
+ data: result.response,
25
+ statusCode: result.status ? result.status.code : '',
26
+ errorMsg,
27
+ });
28
+ if (callback) {
29
+ callback(result.response);
30
+ }
31
+ } catch (error) {
32
+ yield put({
33
+ type: TEMPLATE_CREATE_FAILURE,
34
+ error,
35
+ errorMsg,
36
+ });
37
+ if (callback) {
38
+ callback(null, errorMsg);
39
+ }
40
+ }
41
+ }
42
+
43
+ function* watchCreateTemplate() {
44
+ const watcher = yield takeLatest(
45
+ TEMPLATE_CREATE_REQUEST,
46
+ sendForApprovalCreate,
47
+ );
48
+ yield take(LOCATION_CHANGE);
49
+ yield cancel(watcher);
50
+ }
51
+
52
+ // FOR EDIT
53
+ export function* getTemplateDetails({ id }) {
54
+ try {
55
+ const result = yield call(Api.getTemplateDetails, {
56
+ id,
57
+ channel: WHATSAPP,
58
+ });
59
+ yield put({
60
+ type: GET_TEMPLATE_DETAILS_SUCCESS,
61
+ data: result.response,
62
+ });
63
+ } catch (error) {
64
+ yield put({ type: GET_TEMPLATE_DETAILS_FAILURE, error });
65
+ }
66
+ }
67
+
68
+ function* watchGetTemplateDetails() {
69
+ const watcher = yield takeLatest(
70
+ GET_TEMPLATE_DETAILS_REQUEST,
71
+ getTemplateDetails,
72
+ );
73
+ yield take(LOCATION_CHANGE);
74
+ yield cancel(watcher);
75
+ }
76
+
77
+ export default [watchCreateTemplate, watchGetTemplateDetails];
@@ -0,0 +1,12 @@
1
+ import { createSelector } from 'reselect';
2
+
3
+ const selectWhatsappDomain = () => (state) => state.get('whatsapp');
4
+ const selectAccountDomain = () => (state) => state.get('templates');
5
+
6
+ const makeSelectWhatsapp = () =>
7
+ createSelector(selectWhatsappDomain(), (substate) => substate.toJS());
8
+
9
+ const makeSelectAccount = () =>
10
+ createSelector(selectAccountDomain(), (substate) => substate.toJS());
11
+
12
+ export { makeSelectWhatsapp, makeSelectAccount };