@capillarytech/creatives-library 7.10.39 → 7.10.40
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/containers/Assets/Gallery/tests/__snapshots__/reducer.test.js.snap +0 -2
- package/containers/Email/index.js +2 -3
- package/index.js +6 -0
- package/package.json +1 -1
- package/routes.js +5 -0
- package/services/api.js +6 -1
- package/v2Components/TemplatePreview/_templatePreview.scss +7 -0
- package/v2Components/TemplatePreview/assets/images/whatsapp_mobile_android.svg +2041 -0
- package/v2Components/TemplatePreview/index.js +57 -3
- package/v2Components/TemplatePreview/messages.js +8 -0
- package/v2Containers/Assets/Gallery/tests/__snapshots__/reducer.test.js.snap +0 -2
- package/v2Containers/Assets/images/whatsappIllustration.png +0 -0
- package/v2Containers/CreativesContainer/SlideBoxContent.js +24 -2
- package/v2Containers/CreativesContainer/SlideBoxHeader.js +1 -0
- package/v2Containers/CreativesContainer/constants.js +1 -0
- package/v2Containers/Email/index.js +1 -3
- package/v2Containers/Line/Container/index.js +1 -1
- package/v2Containers/Templates/_templates.scss +43 -0
- package/v2Containers/Templates/actions.js +18 -10
- package/v2Containers/Templates/constants.js +3 -1
- package/v2Containers/Templates/index.js +259 -43
- package/v2Containers/Templates/messages.js +32 -0
- package/v2Containers/Templates/reducer.js +2 -0
- package/v2Containers/TemplatesV2/index.js +2 -0
- package/v2Containers/TemplatesV2/messages.js +4 -0
- package/v2Containers/Whatsapp/actions.js +17 -0
- package/v2Containers/Whatsapp/constants.js +98 -0
- package/v2Containers/Whatsapp/index.js +469 -0
- package/v2Containers/Whatsapp/index.scss +36 -0
- package/v2Containers/Whatsapp/messages.js +184 -0
- package/v2Containers/Whatsapp/reducer.js +39 -0
- package/v2Containers/Whatsapp/sagas.js +48 -0
- package/v2Containers/Whatsapp/selectors.js +25 -0
- package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +123185 -0
- package/v2Containers/Whatsapp/tests/index.test.js +132 -0
- package/v2Containers/Whatsapp/tests/mockData.js +10 -0
- package/v2Containers/Whatsapp/utils.js +106 -0
|
@@ -0,0 +1,184 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { fromJS } from 'immutable';
|
|
2
|
+
import {
|
|
3
|
+
WHATSAPP_TEMPLATE_CREATE_REQUEST,
|
|
4
|
+
WHATSAPP_TEMPLATE_CREATE_SUCCESS,
|
|
5
|
+
WHATSAPP_TEMPLATE_CREATE_FAILURE,
|
|
6
|
+
CLEAR_WHATSAPP_TEMPLATE_REQUEST,
|
|
7
|
+
} from './constants';
|
|
8
|
+
|
|
9
|
+
const initialState = fromJS({ createTemplateInProgress: false });
|
|
10
|
+
|
|
11
|
+
function whatsappReducer(state = initialState, action) {
|
|
12
|
+
switch (action.type) {
|
|
13
|
+
case WHATSAPP_TEMPLATE_CREATE_REQUEST:
|
|
14
|
+
return state
|
|
15
|
+
.set('createTemplateInProgress', true)
|
|
16
|
+
.set('createTemplateError', false)
|
|
17
|
+
.set('createTemplateErrorMessage', fromJS(''));
|
|
18
|
+
case WHATSAPP_TEMPLATE_CREATE_SUCCESS:
|
|
19
|
+
return state
|
|
20
|
+
.set('createTemplateInProgress', false)
|
|
21
|
+
.set('response', action.data)
|
|
22
|
+
.set(
|
|
23
|
+
'createTemplateError',
|
|
24
|
+
action.statusCode !== undefined && action.statusCode > 300,
|
|
25
|
+
)
|
|
26
|
+
.set('createTemplateErrorMessage', fromJS(action.errorMsg));
|
|
27
|
+
case WHATSAPP_TEMPLATE_CREATE_FAILURE:
|
|
28
|
+
return state
|
|
29
|
+
.set('createTemplateInProgress', false)
|
|
30
|
+
.set('createTemplateError', true)
|
|
31
|
+
.set('createTemplateErrorMessage', fromJS(action.errorMsg));
|
|
32
|
+
case CLEAR_WHATSAPP_TEMPLATE_REQUEST:
|
|
33
|
+
return state.set('response', {});
|
|
34
|
+
default:
|
|
35
|
+
return state;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export default whatsappReducer;
|
|
@@ -0,0 +1,48 @@
|
|
|
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
|
+
WHATSAPP_TEMPLATE_CREATE_REQUEST,
|
|
6
|
+
WHATSAPP_TEMPLATE_CREATE_SUCCESS,
|
|
7
|
+
WHATSAPP_TEMPLATE_CREATE_FAILURE,
|
|
8
|
+
} from './constants';
|
|
9
|
+
|
|
10
|
+
export function* sendForApprovalCreate({ payload, callback }) {
|
|
11
|
+
let errorMsg;
|
|
12
|
+
try {
|
|
13
|
+
const result = yield call(Api.createWhatsappTemplate, { payload });
|
|
14
|
+
if (result?.status?.code && result.status.code >= 400) {
|
|
15
|
+
errorMsg = result?.message || result.status.code;
|
|
16
|
+
throw errorMsg;
|
|
17
|
+
}
|
|
18
|
+
yield put({
|
|
19
|
+
type: WHATSAPP_TEMPLATE_CREATE_SUCCESS,
|
|
20
|
+
data: result.response,
|
|
21
|
+
statusCode: result.status ? result.status.code : '',
|
|
22
|
+
errorMsg,
|
|
23
|
+
});
|
|
24
|
+
if (callback) {
|
|
25
|
+
callback(result.response);
|
|
26
|
+
}
|
|
27
|
+
} catch (error) {
|
|
28
|
+
yield put({
|
|
29
|
+
type: WHATSAPP_TEMPLATE_CREATE_FAILURE,
|
|
30
|
+
error,
|
|
31
|
+
errorMsg,
|
|
32
|
+
});
|
|
33
|
+
if (callback) {
|
|
34
|
+
callback(null, errorMsg);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function* watchCreateTemplate() {
|
|
40
|
+
const watcher = yield takeLatest(
|
|
41
|
+
WHATSAPP_TEMPLATE_CREATE_REQUEST,
|
|
42
|
+
sendForApprovalCreate,
|
|
43
|
+
);
|
|
44
|
+
yield take(LOCATION_CHANGE);
|
|
45
|
+
yield cancel(watcher);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export default [watchCreateTemplate];
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { createSelector } from 'reselect';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Direct selector to the whatsapp state domain
|
|
5
|
+
*/
|
|
6
|
+
const selectWhatsappDomain = () => (state) => state.get('whatsapp');
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Other specific selectors
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Default selector used by Whatsapp
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
const makeSelectWhatsapp = () => createSelector(
|
|
18
|
+
selectWhatsappDomain(),
|
|
19
|
+
(substate) => substate.toJS()
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
export default makeSelectWhatsapp;
|
|
23
|
+
export {
|
|
24
|
+
selectWhatsappDomain,
|
|
25
|
+
};
|