@capillarytech/creatives-library 7.17.82-alpha.0 → 7.17.82-alpha.1

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 (32) hide show
  1. package/containers/Cap/sagas.js +7 -5
  2. package/containers/Cap/tests/saga.test.js +81 -1
  3. package/package.json +2 -2
  4. package/services/api.js +5 -0
  5. package/services/tests/api.test.js +9 -1
  6. package/v2Components/CapWhatsappQuickReply/index.js +96 -83
  7. package/v2Components/CapWhatsappQuickReply/index.scss +4 -1
  8. package/v2Components/CapWhatsappQuickReply/messages.js +4 -0
  9. package/v2Components/TemplatePreview/_templatePreview.scss +23 -0
  10. package/v2Components/TemplatePreview/index.js +43 -23
  11. package/v2Components/TemplatePreview/messages.js +4 -0
  12. package/v2Components/TemplatePreview/tests/__snapshots__/index.test.js.snap +0 -14
  13. package/v2Containers/CreativesContainer/index.js +22 -2
  14. package/v2Containers/CreativesContainer/tests/__snapshots__/SlideBoxContent.test.js.snap +4 -4
  15. package/v2Containers/Templates/index.js +3 -3
  16. package/v2Containers/Whatsapp/actions.js +16 -0
  17. package/v2Containers/Whatsapp/constants.js +8 -1
  18. package/v2Containers/Whatsapp/index.js +347 -253
  19. package/v2Containers/Whatsapp/index.scss +12 -1
  20. package/v2Containers/Whatsapp/messages.js +10 -1
  21. package/v2Containers/Whatsapp/reducer.js +19 -0
  22. package/v2Containers/Whatsapp/sagas.js +40 -1
  23. package/v2Containers/Whatsapp/styles.scss +6 -3
  24. package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +12145 -51281
  25. package/v2Containers/Whatsapp/tests/__snapshots__/utils.test.js.snap +20 -20
  26. package/v2Containers/Whatsapp/tests/actions.test.js +21 -0
  27. package/v2Containers/Whatsapp/tests/index.test.js +8 -0
  28. package/v2Containers/Whatsapp/tests/mockData.js +6 -0
  29. package/v2Containers/Whatsapp/tests/reducer.test.js +67 -0
  30. package/v2Containers/Whatsapp/tests/saga.test.js +90 -0
  31. package/v2Containers/Whatsapp/utils.js +13 -13
  32. package/v2Containers/mockdata.js +8 -18
@@ -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 loginUrl = (process.env.NODE_ENV === 'production') ?
59
- `${config.production.login_url}` : `${config.development.login_url}`;
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 = `${window.location.origin}${loginUrl}`;
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 { take, fork, cancel } from 'redux-saga/effects';
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-alpha.0",
4
+ "version": "7.17.82-alpha.1",
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.2",
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",
package/services/api.js CHANGED
@@ -504,3 +504,8 @@ export const getTemplateInfoById = ({id, username, oa_id, token}) => {
504
504
  const url = `${API_ENDPOINT}/templates/${id}/Zalo?username=${username}&oa_id=${oa_id}&token=${token}`;
505
505
  return request(url, getAPICallObject('GET'));
506
506
  };
507
+
508
+ export const getMetaTags = ({previewUrl}) => {
509
+ const url = `${API_ENDPOINT}/common/getMetaTags?url=${previewUrl}`;
510
+ return request(url, getAPICallObject('GET'));
511
+ };
@@ -2,7 +2,8 @@ import {
2
2
  getSenderDetails,
3
3
  uploadFile,
4
4
  getCdnTransformationConfig,
5
- createWhatsappTemplate
5
+ createWhatsappTemplate,
6
+ getMetaTags,
6
7
  } from '../api';
7
8
  import { mockData } from './mockData';
8
9
  const sampleFile = require('../../assets/line.png');
@@ -44,3 +45,10 @@ describe('createWhatsappTemplate -- Test with valid responses', () => {
44
45
  createWhatsappTemplate(sampleFile, mockData.createWhatsappPayload),
45
46
  ).toEqual(Promise.resolve()));
46
47
  });
48
+
49
+ describe('getMetaTags -- Test with valid responses', () => {
50
+ it('Should return correct response', () =>
51
+ expect(
52
+ getMetaTags({previewUrl: 'https://capillarytech.com'}),
53
+ ).toEqual(Promise.resolve()));
54
+ });
@@ -1,5 +1,6 @@
1
1
  import React from "react";
2
- import { injectIntl } from "react-intl";
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
- const handleTextChange = (e, index) => {
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.map((quickReply) => {
39
+ quickReplyData?.map((quickReply) => {
42
40
  if (quickReply?.index === index) {
43
41
  return {
44
42
  ...quickReply,
45
43
  text: value,
46
- error: error,
44
+ error,
47
45
  };
48
- } else return quickReply;
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
- } else return quickReply;
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.index !== index
72
+ (i) => i?.index !== index
71
73
  );
72
- return filteredQuickReplyData.map((quickReply, index) => {
73
- quickReply.index = index;
74
- return quickReply;
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 = quickReplyData?.length || 0;
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 quickReplyDisable =
89
- quickReplyData?.length === 1 && !quickReplyData?.[0].isSaved;
90
+ const isQuickReplyDisable =
91
+ quickReplyDataLength === 1 && !quickReplyData?.[0]?.isSaved;
90
92
  return (
91
93
  <>
92
- {quickReplyData?.length > 0 && !isEditFlow && (
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
- <CapTooltipWithInfo
110
- placement="right"
111
- infoIconProps={{
112
- style: { marginLeft: CAP_SPACE_04 },
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
- <CapRow className="whatsapp-button-text-input">
120
- <TextArea
121
- autosize={{ minRows: 1, maxRows: 5 }}
122
- placeholder={formatMessage(
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
- onChange={(e) => handleTextChange(e, index)}
126
- errorMessage={
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
- value={text || ""}
134
+ value={text || ""}
134
135
  />
135
- </CapRow>
136
- {renderMessageLength("buttonText", text?.length || 0)}
137
- <CapRow className="whatsapp-cta-save-delete-btn">
138
- <CapTooltip
139
- title={
140
- text === "" || error
141
- ? formatMessage(ctaMessages.ctaSaveDisabled)
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
- placement={"bottom"}
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
- </CapTooltip>
158
- <CapButton
159
- onClick={() => {
160
- handleDelete(index);
161
- }}
162
- className="whatsapp-cta-delete-btn whatsapp-quick-reply-delete-button"
163
- type="secondary"
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
- {formatMessage(globalMessages.delete)}
166
- </CapButton>
167
- </CapRow>
166
+ {formatMessage(globalMessages.delete)}
167
+ </CapButton>
168
+ </CapRow>
168
169
  </CapRow>
169
170
  </CapRow>
170
171
  );
171
- } else {
172
- return (
173
- <CapRow className="cap-whatsapp-quick-reply">
174
- <CapRow className="whatsapp-quick-reply-save-container">
175
- <CapColumn>
176
- <CapIcon type="six-dots" />
177
- </CapColumn>
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
- <CapColumn className="quick-reply-icon">
180
- <CapIcon
181
- onClick={() => handleSaveAndEditBtn(index, false)}
182
- type="edit"
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
- <CapIcon
185
- onClick={() => handleDelete(index)}
186
- type="delete"
187
+ <CapIcon
188
+ onClick={() => handleDelete(index)}
189
+ type="delete"
190
+ data-testid="quick-reply-delete"
187
191
  />
188
- </CapColumn>
189
- </CapRow>
192
+ </CapColumn>
190
193
  </CapRow>
194
+ </CapRow>
191
195
  );
192
- }
193
196
  })}
194
197
  </CapRow>
195
198
  )}
196
- {quickReplyData?.length > 0 && isEditFlow &&
199
+ {/* this section render in edit mode from campaign side */}
200
+ {quickReplyDataLength > 0 && isEditFlow &&
197
201
  quickReplyData.map(({text, index}) => (
198
- <CapRow className='cap-whatsapp-quick-reply whatsapp-quick-reply-edit-container' key={index}>
199
- <CapLabel type='label16'>{text}</CapLabel>
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
- {quickReplyData?.length < 3 && !isEditFlow && (
207
+ {/* this section render add button section with condition */}
208
+ {quickReplyDataLength < 3 && !isEditFlow && (
204
209
  <CapRow>
205
210
  <CapTooltip
206
211
  title={
207
- quickReplyDisable ? formatMessage(ctaMessages.ctaAddDisabled) : ""
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={quickReplyDisable}
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 1px $CAP_G06;
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
  });
@@ -276,6 +276,9 @@
276
276
  align-content: center;
277
277
  justify-content: center;
278
278
  margin-bottom: 4px;
279
+ svg {
280
+ margin-right: $CAP_SPACE_04;
281
+ }
279
282
  }
280
283
  .whatsapp-message-container{
281
284
  max-height: 292px;
@@ -517,4 +520,24 @@
517
520
  .zalo-preview-container-campaign {
518
521
  padding-left: 0px;
519
522
  padding-right: 4.563rem;
523
+ }
524
+
525
+ .url-preview-image {
526
+ width: 100%;
527
+ height: 100%;
528
+ background-color: hsl(0, 0%, 90%);
529
+ }
530
+
531
+ .url-preview-description {
532
+ font-size: 0.6rem;
533
+ font-weight: $FONT_WEIGHT_REGULAR;
534
+ color: $FONT_COLOR_01;
535
+ margin: 0.13rem 0;
536
+ }
537
+
538
+ .url-preview {
539
+ font-size: 0.5rem;
540
+ font-weight: $FONT_WEIGHT_REGULAR;
541
+ color: $FONT_COLOR_02;
542
+ margin-bottom: $CAP_SPACE_08;
520
543
  }
@@ -11,6 +11,7 @@ import _ from 'lodash';
11
11
  import { injectIntl, FormattedMessage, intlShape } from 'react-intl';
12
12
  // import styled from 'styled-components';
13
13
  import { CapColumn, CapRow, CapHeading, CapIcon, CapButton, CapImage, CapLabel, CapDivider, CapTooltip } from '@capillarytech/cap-ui-library';
14
+ import { isEmpty } from 'lodash';
14
15
  import './_templatePreview.scss';
15
16
  import {updateCharCount} from '../../utils/smsCharCountV2';
16
17
  import messages from './messages';
@@ -53,6 +54,8 @@ import {
53
54
  import { TEMPLATE, IMAGE_CAROUSEL, IMAGE, STICKER, TEXT, IMAGE_MAP, VIDEO } from '../../v2Containers/Line/Container/constants';
54
55
  import CapFacebookPreview from '../../v2Containers/CapFacebookPreview';
55
56
  import WhatsappStatusContainer from '../WhatsappStatusContainer';
57
+ import { getWhatsappQuickReply } from '../../v2Containers/Whatsapp/utils';
58
+ import { QUICK_REPLY } from '../../v2Containers/Whatsapp/constants';
56
59
 
57
60
  export class TemplatePreview extends React.Component { // eslint-disable-line react/prefer-stateless-function
58
61
  onPreviewContentClicked = (channel) => {
@@ -319,7 +322,6 @@ export class TemplatePreview extends React.Component { // eslint-disable-line re
319
322
  (ctaType || type) === 'PHONE_NUMBER' ? 'call' : 'launch'
320
323
  }
321
324
  size="xs"
322
- svgProps={{ style: { marginRight: '4px' } }}
323
325
  />
324
326
  {text}
325
327
  </CapLabel>,
@@ -331,31 +333,46 @@ export class TemplatePreview extends React.Component { // eslint-disable-line re
331
333
  };
332
334
 
333
335
  const renderQuickReplyPreview = () => {
334
- const renderArray = [];
335
336
  const { quickReplyData = [] } = content || {};
336
- if (quickReplyData?.length) {
337
- renderArray.push(<CapDivider className="whatsapp-divider" />);
338
- quickReplyData.forEach((quickReply, index) => {
339
- const { text } = quickReply || {};
340
- if (text) {
341
- renderArray.push(
342
- <CapLabel type="label21" className="whatsapp-cta-preview">
343
- <CapIcon
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
- })
337
+ return getWhatsappQuickReply(
338
+ {
339
+ buttons: quickReplyData,
340
+ buttonType: QUICK_REPLY,
341
+ },
342
+ true
343
+ );
344
+ };
345
+
346
+ const renderUrlPreview = (metaTags) => {
347
+ const renderArray = [];
348
+ if (!isEmpty(metaTags)) {
349
+ if (metaTags?.image) {
350
+ renderArray.push(
351
+ <CapImage
352
+ src={metaTags?.image}
353
+ alt={formatMessage(messages.previewUrlMetaImage)}
354
+ className="url-preview-image"
355
+ />
356
+ );
357
+ }
358
+ if (metaTags?.title) {
359
+ renderArray.push(
360
+ <CapLabel type="label8">{metaTags?.title}</CapLabel>
361
+ );
362
+ }
363
+ if (metaTags?.description) {
364
+ renderArray.push(
365
+ <CapLabel className="url-preview-description">{metaTags?.description}</CapLabel>
366
+ );
367
+ }
368
+ if (metaTags?.url) {
369
+ renderArray.push(
370
+ <CapLabel className="url-preview">{metaTags?.url}</CapLabel>
371
+ );
372
+ }
356
373
  }
357
374
  return renderArray;
358
- }
375
+ };
359
376
 
360
377
  const handlePreview = () => {
361
378
  const {templatePreviewUrl = ''} = templateData;
@@ -771,6 +788,9 @@ export class TemplatePreview extends React.Component { // eslint-disable-line re
771
788
  <div className="msg-container whatsapp-message-container">
772
789
  <div className="message-pop align-left" style={whatsappSectionStyle}>
773
790
  <div className="whatsapp-content">
791
+ {content?.isPreviewUrl && (
792
+ renderUrlPreview(content?.metaTagsDetails)
793
+ )}
774
794
  {content?.whatsappImageSrc && (
775
795
  <CapImage
776
796
  src={content.whatsappImageSrc}
@@ -82,4 +82,8 @@ export default defineMessages({
82
82
  id: 'creatives.componentsV2.TemplatePreview.videoPreviewTooltip',
83
83
  defaultMessage: "This is just for preview purposes, video cannot be played here",
84
84
  },
85
+ previewUrlMetaImage: {
86
+ id: 'creatives.componentsV2.TemplatePreview.previewUrlMetaImage',
87
+ defaultMessage: 'Preview url meta image',
88
+ },
85
89
  });