@capillarytech/creatives-library 7.17.59 → 7.17.61-alpha.0
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/package.json +1 -1
- package/v2Containers/Templates/index.js +1 -1
- package/v2Containers/Zalo/actions.js +8 -1
- package/v2Containers/Zalo/constants.js +1 -0
- package/v2Containers/Zalo/index.js +12 -6
- package/v2Containers/Zalo/reducer.js +6 -0
- package/v2Containers/Zalo/tests/actions.test.js +6 -0
- package/v2Containers/Zalo/tests/index.test.js +1 -0
- package/v2Containers/Zalo/tests/reducer.test.js +11 -0
package/package.json
CHANGED
|
@@ -626,7 +626,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
626
626
|
const zaloPreviewUrl = get(nextProps, 'Zalo.zaloTemplatePreviewData.versions.base.content.zalo.previewUrl', '');
|
|
627
627
|
if (zaloPreviewUrl && this.state.channel.toLowerCase() === ZALO_LOWERCASE) {
|
|
628
628
|
handlePreviewInNewTab(zaloPreviewUrl);
|
|
629
|
-
this.props.zaloActions.
|
|
629
|
+
this.props.zaloActions.resetTemplatePreviewData();
|
|
630
630
|
}
|
|
631
631
|
}
|
|
632
632
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ZALO_TEMPLATE_INFO_REQUEST,
|
|
3
3
|
ZALO_TEMPLATE_PREVIEW_RESET,
|
|
4
|
+
ZALO_TEMPLATE_INFO_RESET,
|
|
4
5
|
} from "./constants";
|
|
5
6
|
|
|
6
7
|
export function getTemplateInfoById(payload) {
|
|
@@ -10,8 +11,14 @@ export function getTemplateInfoById(payload) {
|
|
|
10
11
|
};
|
|
11
12
|
}
|
|
12
13
|
|
|
13
|
-
export function
|
|
14
|
+
export function resetTemplatePreviewData() {
|
|
14
15
|
return {
|
|
15
16
|
type: ZALO_TEMPLATE_PREVIEW_RESET,
|
|
16
17
|
};
|
|
17
18
|
}
|
|
19
|
+
|
|
20
|
+
export function resetTemplateInfoData() {
|
|
21
|
+
return {
|
|
22
|
+
type: ZALO_TEMPLATE_INFO_RESET,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
@@ -24,6 +24,7 @@ export const ZALO_TEMPLATE_INFO_SUCCESS = `${prefix}/ZALO_TEMPLATE_INFO_SUCCESS`
|
|
|
24
24
|
export const ZALO_TEMPLATE_INFO_ERROR = `${prefix}/ZALO_TEMPLATE_INFO_ERROR`;
|
|
25
25
|
export const ZALO_TEMPLATE_PREVIEW_RESET = `${prefix}/ZALO_TEMPLATE_PREVIEW_RESET`;
|
|
26
26
|
export const ZALO_TEMPLATE_PREVIEW_INFO = `${prefix}/ZALO_TEMPLATE_PREVIEW_INFO`;
|
|
27
|
+
export const ZALO_TEMPLATE_INFO_RESET = `${prefix}/ZALO_TEMPLATE_INFO_RESET`;
|
|
27
28
|
|
|
28
29
|
export const ZALO_STATUSES = {
|
|
29
30
|
PENDING_REVIEW: 'PENDING_REVIEW',
|
|
@@ -80,7 +80,8 @@ export const Zalo = (props) => {
|
|
|
80
80
|
const [textAreaId, updateTextAreaId] = useState('');
|
|
81
81
|
const { zaloTemplateInfoValue = {}, zaloTemplateInfoStatus = REQUEST } =
|
|
82
82
|
editData;
|
|
83
|
-
const { _id, templateConfigs: { varMapped = {} } = {} } = templateData;
|
|
83
|
+
const { _id = '', templateConfigs: { id = '', varMapped = {} } = {} } = templateData;
|
|
84
|
+
const zaloTempId = _id || id;
|
|
84
85
|
const ZaloFooter = styled.div`
|
|
85
86
|
background-color: ${CAP_WHITE};
|
|
86
87
|
position: fixed;
|
|
@@ -112,16 +113,20 @@ export const Zalo = (props) => {
|
|
|
112
113
|
|
|
113
114
|
//gets template details
|
|
114
115
|
useEffect(() => {
|
|
115
|
-
if (
|
|
116
|
+
if (zaloTempId && oa_id && token && username) {
|
|
116
117
|
actions.getTemplateInfoById({
|
|
117
118
|
username,
|
|
118
119
|
oa_id,
|
|
119
120
|
token,
|
|
120
|
-
id:
|
|
121
|
+
id: zaloTempId,
|
|
121
122
|
actionCallback,
|
|
122
123
|
});
|
|
123
124
|
}
|
|
124
|
-
|
|
125
|
+
//cleanup code
|
|
126
|
+
return () => {
|
|
127
|
+
actions.resetTemplateInfoData();
|
|
128
|
+
};
|
|
129
|
+
}, [zaloTempId, oa_id, token, username]);
|
|
125
130
|
|
|
126
131
|
const handleSetValues = (paramsData = []) =>
|
|
127
132
|
paramsData.map((paramData) => {
|
|
@@ -136,7 +141,7 @@ export const Zalo = (props) => {
|
|
|
136
141
|
const setDataForEdit = (setValues) => {
|
|
137
142
|
const {
|
|
138
143
|
name = '',
|
|
139
|
-
_id:
|
|
144
|
+
_id: zaloId = '',
|
|
140
145
|
versions: {
|
|
141
146
|
base: {
|
|
142
147
|
content: {
|
|
@@ -150,7 +155,7 @@ export const Zalo = (props) => {
|
|
|
150
155
|
} = {},
|
|
151
156
|
} = zaloTemplateInfoValue;
|
|
152
157
|
setTemplateName(name);
|
|
153
|
-
setTemplateId(
|
|
158
|
+
setTemplateId(zaloId);
|
|
154
159
|
setTemplateListParams(setValues ? handleSetValues(paramsData) : paramsData);
|
|
155
160
|
setTemplatePreviewUrl(previewUrl);
|
|
156
161
|
setZaloTemplateStatus(status);
|
|
@@ -353,6 +358,7 @@ export const Zalo = (props) => {
|
|
|
353
358
|
template: templatePreviewUrl,
|
|
354
359
|
varMapped: varMap,
|
|
355
360
|
},
|
|
361
|
+
token,
|
|
356
362
|
};
|
|
357
363
|
return payload;
|
|
358
364
|
};
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
ZALO_TEMPLATE_INFO_REQUEST,
|
|
6
6
|
ZALO_TEMPLATE_PREVIEW_RESET,
|
|
7
7
|
ZALO_TEMPLATE_PREVIEW_INFO,
|
|
8
|
+
ZALO_TEMPLATE_INFO_RESET,
|
|
8
9
|
SUCCESS,
|
|
9
10
|
REQUEST,
|
|
10
11
|
ERROR,
|
|
@@ -48,6 +49,11 @@ const zaloReducer = (state = initialState, action) => {
|
|
|
48
49
|
.set("zaloTemplateInfoStatus", REQUEST)
|
|
49
50
|
.set("zaloTemplatePreviewData", "")
|
|
50
51
|
.set("zaloTemplateInfoError", null);
|
|
52
|
+
case ZALO_TEMPLATE_INFO_RESET:
|
|
53
|
+
return state
|
|
54
|
+
.set("zaloTemplateInfoStatus", REQUEST)
|
|
55
|
+
.set("zaloTemplateInfoValue", "")
|
|
56
|
+
.set("zaloTemplateInfoError", null);
|
|
51
57
|
|
|
52
58
|
default:
|
|
53
59
|
return state;
|
|
@@ -15,6 +15,12 @@ describe("Test zalo actions", () => {
|
|
|
15
15
|
const expected = {
|
|
16
16
|
type: types.ZALO_TEMPLATE_PREVIEW_RESET,
|
|
17
17
|
};
|
|
18
|
+
expect(actions.resetTemplatePreviewData()).toEqual(expected);
|
|
19
|
+
});
|
|
20
|
+
it("has a type of ZALO_TEMPLATE_INFO_RESET action", () => {
|
|
21
|
+
const expected = {
|
|
22
|
+
type: types.ZALO_TEMPLATE_INFO_RESET,
|
|
23
|
+
};
|
|
18
24
|
expect(actions.resetTemplateInfoData()).toEqual(expected);
|
|
19
25
|
});
|
|
20
26
|
});
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
ZALO_TEMPLATE_INFO_ERROR,
|
|
7
7
|
ZALO_TEMPLATE_PREVIEW_INFO,
|
|
8
8
|
ZALO_TEMPLATE_PREVIEW_RESET,
|
|
9
|
+
ZALO_TEMPLATE_INFO_RESET,
|
|
9
10
|
REQUEST,
|
|
10
11
|
SUCCESS,
|
|
11
12
|
ERROR,
|
|
@@ -76,6 +77,16 @@ describe("zalo reducer", () => {
|
|
|
76
77
|
expect(zaloReducer(state, action)).toEqual(expectedResult);
|
|
77
78
|
});
|
|
78
79
|
|
|
80
|
+
it("should handle ZALO_TEMPLATE_INFO_RESET action", () => {
|
|
81
|
+
action.type = ZALO_TEMPLATE_INFO_RESET;
|
|
82
|
+
state = state
|
|
83
|
+
.set("zaloTemplateInfoStatus", REQUEST)
|
|
84
|
+
.set("zaloTemplateInfoValue", "")
|
|
85
|
+
.set("zaloTemplateInfoError", null);
|
|
86
|
+
const expectedResult = state;
|
|
87
|
+
expect(zaloReducer(state, action)).toEqual(expectedResult);
|
|
88
|
+
});
|
|
89
|
+
|
|
79
90
|
it("should handle default action", () => {
|
|
80
91
|
action.type = "deafult_action";
|
|
81
92
|
const expectedResult = state;
|