@capillarytech/creatives-library 7.17.82-alpha.0 → 7.17.82
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/Cap/sagas.js +7 -5
- package/containers/Cap/tests/saga.test.js +81 -1
- package/package.json +2 -2
- package/v2Components/CapWhatsappQuickReply/index.js +96 -83
- package/v2Components/CapWhatsappQuickReply/index.scss +4 -1
- package/v2Components/CapWhatsappQuickReply/messages.js +4 -0
- package/v2Components/TemplatePreview/_templatePreview.scss +3 -0
- package/v2Components/TemplatePreview/index.js +10 -25
- package/v2Components/TemplatePreview/tests/__snapshots__/index.test.js.snap +0 -14
- package/v2Containers/CreativesContainer/index.js +18 -2
- package/v2Containers/CreativesContainer/tests/__snapshots__/SlideBoxContent.test.js.snap +4 -4
- package/v2Containers/Templates/index.js +3 -3
- package/v2Containers/Whatsapp/constants.js +2 -1
- package/v2Containers/Whatsapp/index.js +280 -251
- package/v2Containers/Whatsapp/index.scss +6 -1
- package/v2Containers/Whatsapp/messages.js +5 -0
- package/v2Containers/Whatsapp/styles.scss +6 -3
- package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +4586 -53228
- package/v2Containers/Whatsapp/tests/__snapshots__/utils.test.js.snap +20 -20
- package/v2Containers/Whatsapp/utils.js +13 -13
- package/v2Containers/mockdata.js +8 -18
package/containers/Cap/sagas.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { fork, take, call, put, cancelled, cancel, takeLatest } from 'redux-saga/effects';
|
|
2
|
+
import { getRedirectionUrl } from '@capillarytech/cap-ui-utils/utils/logoutUtil';
|
|
2
3
|
import { LOCATION_CHANGE } from 'react-router-redux';
|
|
3
4
|
// import { normalize } from 'normalizr';
|
|
4
5
|
import * as Api from '../../services/api';
|
|
@@ -51,18 +52,19 @@ export function* loginFlow() {
|
|
|
51
52
|
}
|
|
52
53
|
}
|
|
53
54
|
|
|
54
|
-
function* logoutFlow() {
|
|
55
|
+
export function* logoutFlow() {
|
|
55
56
|
try {
|
|
56
57
|
const serverLogout = yield call(Api.logout);
|
|
57
58
|
if (serverLogout.success && serverLogout.success === true) {
|
|
58
|
-
const
|
|
59
|
-
|
|
59
|
+
const redirectUrl = getRedirectionUrl({
|
|
60
|
+
redirectUri: serverLogout?.redirectUri,
|
|
61
|
+
});
|
|
60
62
|
yield [put({type: types.LOGOUT_SUCCESS})];
|
|
61
63
|
yield call(LocalStorage.clearItem, 'token');
|
|
62
64
|
yield call(LocalStorage.clearItem, 'orgID');
|
|
63
65
|
yield call(LocalStorage.clearItem, 'user');
|
|
64
66
|
yield call(LocalStorage.clearItem, 'isLoggedIn');
|
|
65
|
-
window.location.href =
|
|
67
|
+
window.location.href = redirectUrl;
|
|
66
68
|
}
|
|
67
69
|
} catch (error) {
|
|
68
70
|
yield put({ type: types.LOGOUT_FAILURE, error });
|
|
@@ -128,7 +130,7 @@ function* watchForOrgChange() {
|
|
|
128
130
|
yield takeLatest(types.SWITCH_ORG_REQUEST, switchOrg);
|
|
129
131
|
}
|
|
130
132
|
|
|
131
|
-
function* watchForLogoutFlow() {
|
|
133
|
+
export function* watchForLogoutFlow() {
|
|
132
134
|
yield takeLatest(types.LOGOUT_REQUEST, logoutFlow);
|
|
133
135
|
}
|
|
134
136
|
|
|
@@ -1,10 +1,18 @@
|
|
|
1
|
+
import { expectSaga } from 'redux-saga-test-plan';
|
|
2
|
+
import { throwError } from 'redux-saga-test-plan/providers';
|
|
3
|
+
import * as matchers from 'redux-saga-test-plan/matchers';
|
|
1
4
|
import { authorize, loginFlow } from '../sagas';
|
|
2
|
-
import
|
|
5
|
+
import * as api from '../../../services/api';
|
|
6
|
+
import { take, fork, cancel, takeLatest } from 'redux-saga/effects';
|
|
3
7
|
import {
|
|
4
8
|
LOGIN_REQUEST,
|
|
5
9
|
LOGIN_FAILURE,
|
|
6
10
|
LOGOUT_REQUEST,
|
|
11
|
+
LOGOUT_SUCCESS,
|
|
12
|
+
LOGOUT_FAILURE,
|
|
7
13
|
} from '../constants';
|
|
14
|
+
import {logoutFlow, watchForLogoutFlow } from '../sagas';
|
|
15
|
+
const error = new Error('error');
|
|
8
16
|
describe('loginFlow', () => {
|
|
9
17
|
it('should handle the login flow', () => {
|
|
10
18
|
const generator = loginFlow();
|
|
@@ -28,4 +36,76 @@ describe('loginFlow', () => {
|
|
|
28
36
|
}
|
|
29
37
|
catch{}
|
|
30
38
|
});
|
|
39
|
+
});
|
|
40
|
+
describe('logoutFlow [Unit Test]', () => {
|
|
41
|
+
describe('logoutFlow saga', () => {
|
|
42
|
+
it('handle valid response from api', async () => {
|
|
43
|
+
expectSaga(logoutFlow)
|
|
44
|
+
.provide([
|
|
45
|
+
[
|
|
46
|
+
matchers.call.fn(api.logout),
|
|
47
|
+
{
|
|
48
|
+
success: true,
|
|
49
|
+
message: 'message',
|
|
50
|
+
},
|
|
51
|
+
],
|
|
52
|
+
])
|
|
53
|
+
.put({
|
|
54
|
+
type: LOGOUT_SUCCESS,
|
|
55
|
+
result: 'message',
|
|
56
|
+
})
|
|
57
|
+
.run();
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it('handle invalid response from api', async () => {
|
|
61
|
+
expectSaga(logoutFlow)
|
|
62
|
+
.provide([
|
|
63
|
+
[
|
|
64
|
+
matchers.call.fn(api.logout),
|
|
65
|
+
{
|
|
66
|
+
success: false,
|
|
67
|
+
message: 'message',
|
|
68
|
+
},
|
|
69
|
+
],
|
|
70
|
+
])
|
|
71
|
+
.run();
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it('handle error response from api', async () => {
|
|
75
|
+
expectSaga(logoutFlow)
|
|
76
|
+
.provide([
|
|
77
|
+
[
|
|
78
|
+
matchers.call.fn(api.logout),
|
|
79
|
+
{
|
|
80
|
+
success: false,
|
|
81
|
+
error,
|
|
82
|
+
},
|
|
83
|
+
],
|
|
84
|
+
])
|
|
85
|
+
.put({
|
|
86
|
+
type: LOGOUT_FAILURE,
|
|
87
|
+
error,
|
|
88
|
+
})
|
|
89
|
+
.run();
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
it('handles error thrown from api', async () => {
|
|
93
|
+
expectSaga(logoutFlow)
|
|
94
|
+
.provide([[matchers.call.fn(api.logout), throwError(error)]])
|
|
95
|
+
.put({
|
|
96
|
+
type: LOGOUT_FAILURE,
|
|
97
|
+
error,
|
|
98
|
+
})
|
|
99
|
+
.run();
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
describe('watchForLogoutFlow saga', () => {
|
|
104
|
+
const generator = watchForLogoutFlow();
|
|
105
|
+
it('should call watchers functions', async () => {
|
|
106
|
+
expect(generator.next().value).toEqual(
|
|
107
|
+
takeLatest(LOGOUT_REQUEST, logoutFlow),
|
|
108
|
+
);
|
|
109
|
+
});
|
|
110
|
+
});
|
|
31
111
|
});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capillarytech/creatives-library",
|
|
3
3
|
"author": "meharaj",
|
|
4
|
-
"version": "7.17.82
|
|
4
|
+
"version": "7.17.82",
|
|
5
5
|
"description": "Capillary creatives ui",
|
|
6
6
|
"main": "./index.js",
|
|
7
7
|
"module": "./index.es.js",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"@babel/polyfill": "7.4.3",
|
|
16
16
|
"@bugsnag/js": "^7.2.1",
|
|
17
17
|
"@bugsnag/plugin-react": "^7.2.1",
|
|
18
|
-
"@capillarytech/cap-ui-utils": "1.4.
|
|
18
|
+
"@capillarytech/cap-ui-utils": "1.4.24",
|
|
19
19
|
"@mailupinc/bee-plugin": "^1.2.0",
|
|
20
20
|
"babel-cli": "^6.26.0",
|
|
21
21
|
"chalk": "1.1.3",
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { injectIntl, intlShape } from "react-intl";
|
|
3
4
|
import cloneDeep from "lodash/cloneDeep";
|
|
4
5
|
import CapRow from "@capillarytech/cap-ui-library/CapRow";
|
|
5
6
|
import CapHeader from "@capillarytech/cap-ui-library/CapHeader";
|
|
@@ -12,44 +13,43 @@ import CapButton from "@capillarytech/cap-ui-library/CapButton";
|
|
|
12
13
|
import CapColumn from "@capillarytech/cap-ui-library/CapColumn";
|
|
13
14
|
import CapIcon from "@capillarytech/cap-ui-library/CapIcon";
|
|
14
15
|
import CapLabel from "@capillarytech/cap-ui-library/CapLabel";
|
|
15
|
-
import { CAP_SPACE_04 } from "@capillarytech/cap-ui-library/styled/variables";
|
|
16
16
|
import messages from "./messages";
|
|
17
17
|
import "./index.scss";
|
|
18
18
|
import globalMessages from "../../v2Containers/Cap/messages";
|
|
19
|
-
import { INITIAL_QUICK_REPLY_DATA } from "../../v2Containers/Whatsapp/constants";
|
|
19
|
+
import { BUTTON_TEXT, INITIAL_QUICK_REPLY_DATA } from "../../v2Containers/Whatsapp/constants";
|
|
20
20
|
import ctaMessages from "../CapWhatsappCTA/messages";
|
|
21
21
|
|
|
22
|
-
const CapWhatsappQuickReply = ({
|
|
23
|
-
quickReplyData,
|
|
24
|
-
renderMessageLength,
|
|
25
|
-
setQuickReplyData,
|
|
26
|
-
isEditFlow,
|
|
27
|
-
intl,
|
|
28
|
-
}) => {
|
|
22
|
+
export const CapWhatsappQuickReply = (props) => {
|
|
23
|
+
const { quickReplyData = [], renderMessageLength, setQuickReplyData, isEditFlow, intl } = props;
|
|
29
24
|
const { TextArea } = CapInput;
|
|
30
25
|
const { formatMessage } = intl;
|
|
31
|
-
|
|
32
|
-
|
|
26
|
+
const quickReplyDataLength = quickReplyData?.length;
|
|
27
|
+
//this function is used for handle text field value change
|
|
28
|
+
const handleTextChange = ({target: {value = ''} = {}}, index) => {
|
|
33
29
|
let error = false;
|
|
34
|
-
const {
|
|
35
|
-
target: { value },
|
|
36
|
-
} = e;
|
|
37
30
|
if (value?.length > 20) {
|
|
38
31
|
error = formatMessage(messages.templateButtonTextLengthError);
|
|
39
32
|
}
|
|
33
|
+
//this check is for same repeated value is not allowed in another text field of quick reply
|
|
34
|
+
const checkIsValueAvailable = quickReplyData?.find((reply) => reply?.text === value);
|
|
35
|
+
if (checkIsValueAvailable) {
|
|
36
|
+
error = formatMessage(messages.templateButtonTextSameValue);
|
|
37
|
+
}
|
|
40
38
|
setQuickReplyData(
|
|
41
|
-
quickReplyData
|
|
39
|
+
quickReplyData?.map((quickReply) => {
|
|
42
40
|
if (quickReply?.index === index) {
|
|
43
41
|
return {
|
|
44
42
|
...quickReply,
|
|
45
43
|
text: value,
|
|
46
|
-
error
|
|
44
|
+
error,
|
|
47
45
|
};
|
|
48
|
-
}
|
|
46
|
+
}
|
|
47
|
+
return quickReply;
|
|
49
48
|
})
|
|
50
49
|
);
|
|
51
50
|
};
|
|
52
51
|
|
|
52
|
+
//this function is used for save the quick reply text field data and same edit the data
|
|
53
53
|
const handleSaveAndEditBtn = (index, value) => {
|
|
54
54
|
setQuickReplyData(
|
|
55
55
|
quickReplyData.map((quickReply) => {
|
|
@@ -58,26 +58,28 @@ const CapWhatsappQuickReply = ({
|
|
|
58
58
|
...quickReply,
|
|
59
59
|
isSaved: value,
|
|
60
60
|
};
|
|
61
|
-
}
|
|
61
|
+
}
|
|
62
|
+
return quickReply;
|
|
62
63
|
})
|
|
63
64
|
);
|
|
64
65
|
};
|
|
65
66
|
|
|
67
|
+
//This function is used for delete the quick reply data for a row
|
|
66
68
|
const handleDelete = (index) => {
|
|
67
69
|
setQuickReplyData((prevState) => {
|
|
68
70
|
const clonedQuickReplyData = cloneDeep(prevState);
|
|
69
71
|
const filteredQuickReplyData = clonedQuickReplyData.filter(
|
|
70
|
-
(i) => i
|
|
72
|
+
(i) => i?.index !== index
|
|
71
73
|
);
|
|
72
|
-
return filteredQuickReplyData.map((quickReply,
|
|
73
|
-
quickReply
|
|
74
|
-
|
|
75
|
-
});
|
|
74
|
+
return filteredQuickReplyData.map((quickReply, i) => ({
|
|
75
|
+
...quickReply,
|
|
76
|
+
index: i,
|
|
77
|
+
}));
|
|
76
78
|
});
|
|
77
79
|
};
|
|
78
80
|
|
|
79
81
|
const addQuickReply = () => {
|
|
80
|
-
INITIAL_QUICK_REPLY_DATA[0].index =
|
|
82
|
+
INITIAL_QUICK_REPLY_DATA[0].index = quickReplyDataLength || 0;
|
|
81
83
|
const clonedQuickReplyData = [
|
|
82
84
|
...quickReplyData,
|
|
83
85
|
...INITIAL_QUICK_REPLY_DATA,
|
|
@@ -85,14 +87,15 @@ const CapWhatsappQuickReply = ({
|
|
|
85
87
|
setQuickReplyData(clonedQuickReplyData);
|
|
86
88
|
};
|
|
87
89
|
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
+
const isQuickReplyDisable =
|
|
91
|
+
quickReplyDataLength === 1 && !quickReplyData?.[0]?.isSaved;
|
|
90
92
|
return (
|
|
91
93
|
<>
|
|
92
|
-
{
|
|
94
|
+
{quickReplyDataLength > 0 && !isEditFlow && (
|
|
93
95
|
<CapRow>
|
|
94
96
|
{quickReplyData?.map(({ index, isSaved, text, error }) => {
|
|
95
97
|
if (!isSaved) {
|
|
98
|
+
//this section is render textfield when its not saved or in edit condition
|
|
96
99
|
return (
|
|
97
100
|
<CapRow className="cap-whatsapp-quick-reply">
|
|
98
101
|
<CapRow
|
|
@@ -106,42 +109,40 @@ const CapWhatsappQuickReply = ({
|
|
|
106
109
|
className="whatsapp-button-text-heading"
|
|
107
110
|
>
|
|
108
111
|
{formatMessage(messages.buttonText)}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
}}
|
|
114
|
-
autoAdjustOverflow
|
|
112
|
+
<CapTooltipWithInfo
|
|
113
|
+
placement="right"
|
|
114
|
+
className="whatsapp-button-text-tooltip"
|
|
115
|
+
autoAdjustOverflow
|
|
115
116
|
/>
|
|
116
117
|
</CapHeading>
|
|
117
118
|
}
|
|
118
119
|
/>
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
120
|
+
<CapRow className="whatsapp-button-text-input">
|
|
121
|
+
<TextArea
|
|
122
|
+
autosize={{ minRows: 1, maxRows: 5 }}
|
|
123
|
+
placeholder={formatMessage(
|
|
123
124
|
messages.buttonTextPlaceholder
|
|
124
125
|
)}
|
|
125
|
-
|
|
126
|
-
|
|
126
|
+
onChange={(e) => handleTextChange(e, index)}
|
|
127
|
+
errorMessage={
|
|
127
128
|
error && (
|
|
128
129
|
<CapError className="whatsapp-template-message-error">
|
|
129
130
|
{error}
|
|
130
131
|
</CapError>
|
|
131
132
|
)
|
|
132
133
|
}
|
|
133
|
-
|
|
134
|
+
value={text || ""}
|
|
134
135
|
/>
|
|
135
|
-
|
|
136
|
-
{renderMessageLength(
|
|
137
|
-
|
|
138
|
-
<
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
136
|
+
</CapRow>
|
|
137
|
+
{renderMessageLength(BUTTON_TEXT, text?.length || 0)}
|
|
138
|
+
{/* it render save and delete button */}
|
|
139
|
+
<CapRow className="whatsapp-cta-save-delete-btn">
|
|
140
|
+
<CapTooltip
|
|
141
|
+
title={
|
|
142
|
+
(text === "" || error)
|
|
143
|
+
&& formatMessage(ctaMessages.ctaSaveDisabled)
|
|
143
144
|
}
|
|
144
|
-
|
|
145
|
+
placement={"bottom"}
|
|
145
146
|
>
|
|
146
147
|
<div className="button-disabled-tooltip-wrapper">
|
|
147
148
|
<CapButton
|
|
@@ -154,57 +155,61 @@ const CapWhatsappQuickReply = ({
|
|
|
154
155
|
{formatMessage(globalMessages.save)}
|
|
155
156
|
</CapButton>
|
|
156
157
|
</div>
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
158
|
+
</CapTooltip>
|
|
159
|
+
<CapButton
|
|
160
|
+
onClick={() => {
|
|
161
|
+
handleDelete(index);
|
|
162
|
+
}}
|
|
163
|
+
className="whatsapp-cta-delete-btn whatsapp-quick-reply-delete-button"
|
|
164
|
+
type="secondary"
|
|
164
165
|
>
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
166
|
+
{formatMessage(globalMessages.delete)}
|
|
167
|
+
</CapButton>
|
|
168
|
+
</CapRow>
|
|
168
169
|
</CapRow>
|
|
169
170
|
</CapRow>
|
|
170
171
|
);
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
172
|
+
}
|
|
173
|
+
return (
|
|
174
|
+
//this section render when data is saved and user can edit it
|
|
175
|
+
<CapRow className="cap-whatsapp-quick-reply">
|
|
176
|
+
<CapRow className="whatsapp-quick-reply-save-container">
|
|
177
|
+
<CapColumn>
|
|
178
|
+
<CapIcon type="six-dots" />
|
|
179
|
+
</CapColumn>
|
|
178
180
|
<CapColumn className="text-conatiner">{text}</CapColumn>
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
181
|
+
<CapColumn className="quick-reply-icon">
|
|
182
|
+
<CapIcon
|
|
183
|
+
onClick={() => handleSaveAndEditBtn(index, false)}
|
|
184
|
+
type="edit"
|
|
185
|
+
data-testid="quick-reply-edit"
|
|
183
186
|
/>
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
+
<CapIcon
|
|
188
|
+
onClick={() => handleDelete(index)}
|
|
189
|
+
type="delete"
|
|
190
|
+
data-testid="quick-reply-delete"
|
|
187
191
|
/>
|
|
188
|
-
|
|
189
|
-
</CapRow>
|
|
192
|
+
</CapColumn>
|
|
190
193
|
</CapRow>
|
|
194
|
+
</CapRow>
|
|
191
195
|
);
|
|
192
|
-
}
|
|
193
196
|
})}
|
|
194
197
|
</CapRow>
|
|
195
198
|
)}
|
|
196
|
-
{
|
|
199
|
+
{/* this section render in edit mode from campaign side */}
|
|
200
|
+
{quickReplyDataLength > 0 && isEditFlow &&
|
|
197
201
|
quickReplyData.map(({text, index}) => (
|
|
198
|
-
<CapRow className=
|
|
199
|
-
<CapLabel type=
|
|
202
|
+
<CapRow className="cap-whatsapp-quick-reply whatsapp-quick-reply-edit-container" key={index}>
|
|
203
|
+
<CapLabel type="label16">{text}</CapLabel>
|
|
200
204
|
</CapRow>
|
|
201
205
|
))
|
|
202
206
|
}
|
|
203
|
-
{
|
|
207
|
+
{/* this section render add button section with condition */}
|
|
208
|
+
{quickReplyDataLength < 3 && !isEditFlow && (
|
|
204
209
|
<CapRow>
|
|
205
210
|
<CapTooltip
|
|
206
211
|
title={
|
|
207
|
-
|
|
212
|
+
isQuickReplyDisable ? formatMessage(ctaMessages.ctaAddDisabled) : ""
|
|
208
213
|
}
|
|
209
214
|
placement={"right"}
|
|
210
215
|
>
|
|
@@ -212,7 +217,7 @@ const CapWhatsappQuickReply = ({
|
|
|
212
217
|
<CapButton
|
|
213
218
|
type="flat"
|
|
214
219
|
id="whatsapp-quick-reply-add-button"
|
|
215
|
-
disabled={
|
|
220
|
+
disabled={isQuickReplyDisable}
|
|
216
221
|
className="margin-t-12 margin-l-24"
|
|
217
222
|
isAddBtn
|
|
218
223
|
onClick={addQuickReply}
|
|
@@ -227,4 +232,12 @@ const CapWhatsappQuickReply = ({
|
|
|
227
232
|
);
|
|
228
233
|
};
|
|
229
234
|
|
|
235
|
+
CapWhatsappQuickReply.propTypes = {
|
|
236
|
+
quickReplyData: PropTypes.array,
|
|
237
|
+
renderMessageLength: PropTypes.func,
|
|
238
|
+
setQuickReplyData: PropTypes.func,
|
|
239
|
+
isEditFlow: PropTypes.func,
|
|
240
|
+
intl: intlShape.isRequired,
|
|
241
|
+
};
|
|
242
|
+
|
|
230
243
|
export default injectIntl(CapWhatsappQuickReply);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
@import "~@capillarytech/cap-ui-library/styles/_variables";
|
|
2
2
|
|
|
3
3
|
.cap-whatsapp-quick-reply {
|
|
4
|
-
border: solid
|
|
4
|
+
border: solid 0.063rem $CAP_G06;
|
|
5
5
|
margin-left: $CAP_SPACE_24;
|
|
6
6
|
margin-top: $CAP_SPACE_24;
|
|
7
7
|
border-radius: 0.285rem;
|
|
@@ -31,6 +31,9 @@
|
|
|
31
31
|
right: $CAP_SPACE_12;
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
|
+
.whatsapp-button-text-tooltip {
|
|
35
|
+
margin-left: $CAP_SPACE_04;
|
|
36
|
+
}
|
|
34
37
|
}
|
|
35
38
|
|
|
36
39
|
.whatsapp-quick-reply-edit-container {
|
|
@@ -17,4 +17,8 @@ export default defineMessages({
|
|
|
17
17
|
id: `${prefix}.templateButtonTextLengthError`,
|
|
18
18
|
defaultMessage: 'Text field length cannot exceed 20',
|
|
19
19
|
},
|
|
20
|
+
templateButtonTextSameValue: {
|
|
21
|
+
id: `${prefix}.templateButtonTextSameValue`,
|
|
22
|
+
defaultMessage: 'Text field value cannot be same with other text fields',
|
|
23
|
+
},
|
|
20
24
|
});
|
|
@@ -53,6 +53,8 @@ import {
|
|
|
53
53
|
import { TEMPLATE, IMAGE_CAROUSEL, IMAGE, STICKER, TEXT, IMAGE_MAP, VIDEO } from '../../v2Containers/Line/Container/constants';
|
|
54
54
|
import CapFacebookPreview from '../../v2Containers/CapFacebookPreview';
|
|
55
55
|
import WhatsappStatusContainer from '../WhatsappStatusContainer';
|
|
56
|
+
import { getWhatsappQuickReply } from '../../v2Containers/Whatsapp/utils';
|
|
57
|
+
import { QUICK_REPLY } from '../../v2Containers/Whatsapp/constants';
|
|
56
58
|
|
|
57
59
|
export class TemplatePreview extends React.Component { // eslint-disable-line react/prefer-stateless-function
|
|
58
60
|
onPreviewContentClicked = (channel) => {
|
|
@@ -319,7 +321,6 @@ export class TemplatePreview extends React.Component { // eslint-disable-line re
|
|
|
319
321
|
(ctaType || type) === 'PHONE_NUMBER' ? 'call' : 'launch'
|
|
320
322
|
}
|
|
321
323
|
size="xs"
|
|
322
|
-
svgProps={{ style: { marginRight: '4px' } }}
|
|
323
324
|
/>
|
|
324
325
|
{text}
|
|
325
326
|
</CapLabel>,
|
|
@@ -331,31 +332,15 @@ export class TemplatePreview extends React.Component { // eslint-disable-line re
|
|
|
331
332
|
};
|
|
332
333
|
|
|
333
334
|
const renderQuickReplyPreview = () => {
|
|
334
|
-
const renderArray = [];
|
|
335
335
|
const { quickReplyData = [] } = content || {};
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
type='small-link'
|
|
345
|
-
size="xs"
|
|
346
|
-
svgProps={{ style: { marginRight: '4px' } }}
|
|
347
|
-
/>
|
|
348
|
-
{text}
|
|
349
|
-
</CapLabel>
|
|
350
|
-
)
|
|
351
|
-
}
|
|
352
|
-
if (index < quickReplyData.length -1) {
|
|
353
|
-
renderArray.push(<CapDivider className="whatsapp-divider" />);
|
|
354
|
-
}
|
|
355
|
-
})
|
|
356
|
-
}
|
|
357
|
-
return renderArray;
|
|
358
|
-
}
|
|
336
|
+
return getWhatsappQuickReply(
|
|
337
|
+
{
|
|
338
|
+
buttons: quickReplyData,
|
|
339
|
+
buttonType: QUICK_REPLY,
|
|
340
|
+
},
|
|
341
|
+
true
|
|
342
|
+
);
|
|
343
|
+
};
|
|
359
344
|
|
|
360
345
|
const handlePreview = () => {
|
|
361
346
|
const {templatePreviewUrl = ''} = templateData;
|
|
@@ -98,13 +98,6 @@ exports[`Test Templates container Should render correct preview component for wh
|
|
|
98
98
|
>
|
|
99
99
|
<CapIcon
|
|
100
100
|
size="xs"
|
|
101
|
-
svgProps={
|
|
102
|
-
Object {
|
|
103
|
-
"style": Object {
|
|
104
|
-
"marginRight": "4px",
|
|
105
|
-
},
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
101
|
type="call"
|
|
109
102
|
/>
|
|
110
103
|
Call
|
|
@@ -115,13 +108,6 @@ exports[`Test Templates container Should render correct preview component for wh
|
|
|
115
108
|
>
|
|
116
109
|
<CapIcon
|
|
117
110
|
size="xs"
|
|
118
|
-
svgProps={
|
|
119
|
-
Object {
|
|
120
|
-
"style": Object {
|
|
121
|
-
"marginRight": "4px",
|
|
122
|
-
},
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
111
|
type="launch"
|
|
126
112
|
/>
|
|
127
113
|
Visit
|
|
@@ -414,7 +414,7 @@ export class Creatives extends React.Component {
|
|
|
414
414
|
} = {},
|
|
415
415
|
} = templateData;
|
|
416
416
|
const mediaParams = {};
|
|
417
|
-
const { url = '', previewUrl = '', docParams = {}} = whatsappMedia;
|
|
417
|
+
const { url = '', previewUrl = '', docParams = {}, footer = '', headerVarMapped = {}, headerTemplate = ''} = whatsappMedia;
|
|
418
418
|
switch (mediaType) {
|
|
419
419
|
case (WHATSAPP_MEDIA_TYPES.IMAGE):
|
|
420
420
|
mediaParams.imageUrl = url;
|
|
@@ -462,6 +462,11 @@ export class Creatives extends React.Component {
|
|
|
462
462
|
...mediaParams,
|
|
463
463
|
buttonType,
|
|
464
464
|
buttons: modifiedButtons,
|
|
465
|
+
whatsappMedia: {
|
|
466
|
+
header: headerTemplate,
|
|
467
|
+
footer,
|
|
468
|
+
headerVarMapped,
|
|
469
|
+
},
|
|
465
470
|
languages: [
|
|
466
471
|
{
|
|
467
472
|
language,
|
|
@@ -667,6 +672,12 @@ export class Creatives extends React.Component {
|
|
|
667
672
|
documentUrl = '',
|
|
668
673
|
videoPreviewImg = '',
|
|
669
674
|
whatsappDocParams = {},
|
|
675
|
+
whatsappMedia: {
|
|
676
|
+
header = '',
|
|
677
|
+
headerVarMapped = {},
|
|
678
|
+
footer = '',
|
|
679
|
+
headerTemplate = '',
|
|
680
|
+
} = {}
|
|
670
681
|
} = cloneDeep(versions.base.content.whatsapp);
|
|
671
682
|
|
|
672
683
|
const modifiedButtons = cloneDeep(buttons).map((btn) => {
|
|
@@ -691,7 +702,12 @@ export class Creatives extends React.Component {
|
|
|
691
702
|
varMapped[`{{${Object.keys(varMapped).length + 1}}}_unsubscribe`] =
|
|
692
703
|
"{{unsubscribe}}";
|
|
693
704
|
}
|
|
694
|
-
const whatsappMedia = {
|
|
705
|
+
const whatsappMedia = {
|
|
706
|
+
header,
|
|
707
|
+
footer,
|
|
708
|
+
headerVarMapped,
|
|
709
|
+
headerTemplate
|
|
710
|
+
};
|
|
695
711
|
const {
|
|
696
712
|
whatsappDocName = '', whatsappDocSize, whatsappDocPages, whatsappDocImg = ''
|
|
697
713
|
} = whatsappDocParams;
|
|
@@ -710,7 +710,8 @@ exports[`Test SlideBoxContent container Should render correct component for what
|
|
|
710
710
|
charCounterEnabled={false}
|
|
711
711
|
content={
|
|
712
712
|
Object {
|
|
713
|
-
"
|
|
713
|
+
"charCount": 151,
|
|
714
|
+
"ctaData": Array [
|
|
714
715
|
Object {
|
|
715
716
|
"index": 0,
|
|
716
717
|
"phone_number": "+919738752617",
|
|
@@ -724,9 +725,8 @@ exports[`Test SlideBoxContent container Should render correct component for what
|
|
|
724
725
|
"url": "https://docs.google.com/{{1}}",
|
|
725
726
|
},
|
|
726
727
|
],
|
|
727
|
-
"
|
|
728
|
-
"
|
|
729
|
-
"headerMsg": "",
|
|
728
|
+
"templateFooterPreview": "",
|
|
729
|
+
"templateHeaderPreview": "",
|
|
730
730
|
"templateMsg": <CapLabel
|
|
731
731
|
type="label5"
|
|
732
732
|
>
|