awing-library 2.1.225-dev → 2.1.227-dev
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/lib/ACM-AXN/Campaign/CreateOrEdit/Recoils.d.ts +2 -1
- package/lib/ACM-AXN/Campaign/CreateOrEdit/Recoils.js +5 -1
- package/lib/ACM-AXN/Campaign/CreateOrEdit/TabApprove/RowTable.d.ts +8 -8
- package/lib/ACM-AXN/Campaign/CreateOrEdit/TabApprove/RowTable.js +2 -2
- package/lib/ACM-AXN/Campaign/CreateOrEdit/TabApprove/RowTable.test.d.ts +1 -0
- package/lib/ACM-AXN/Campaign/CreateOrEdit/TabApprove/RowTable.test.js +218 -73
- package/lib/ACM-AXN/Campaign/CreateOrEdit/TabApprove/RunInBackground.d.ts +2 -0
- package/lib/ACM-AXN/Campaign/CreateOrEdit/TabApprove/RunInBackground.js +322 -0
- package/lib/ACM-AXN/Campaign/CreateOrEdit/TabApprove/index.d.ts +0 -25
- package/lib/ACM-AXN/Campaign/CreateOrEdit/TabApprove/index.js +22 -237
- package/lib/ACM-AXN/Campaign/CreateOrEdit/index.js +23 -22
- package/lib/ACM-AXN/Campaign/Types.d.ts +30 -2
- package/package.json +1 -1
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { CampaignModel, Directory, CampaignGroupModel, Attribute } from '../Types';
|
|
1
|
+
import { CampaignModel, Directory, CampaignGroupModel, Attribute, ICampaignApprovalTable } from '../Types';
|
|
2
2
|
import { WeightContainerProps } from './TabSubCampaign/Weight';
|
|
3
3
|
import { MenuOption } from '../../../AWING';
|
|
4
4
|
export declare const directoriesState: import("recoil").RecoilState<Directory[]>;
|
|
5
5
|
export declare const attributesState: import("recoil").RecoilState<Attribute[]>;
|
|
6
6
|
export declare const isCreateState: import("recoil").RecoilState<boolean>;
|
|
7
|
+
export declare const campaignApprovalTableState: import("recoil").RecoilState<ICampaignApprovalTable[]>;
|
|
7
8
|
/**
|
|
8
9
|
* Đánh dấu việc cần xác nhận lại trước khi đóng (set thành true khi có bất kỳ chỉnh sửa campaign nào)
|
|
9
10
|
*/
|
|
@@ -11,7 +11,7 @@ var __assign = (this && this.__assign) || function () {
|
|
|
11
11
|
return __assign.apply(this, arguments);
|
|
12
12
|
};
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.cacheSearchPageState = exports.weightState = exports.readyForSubmitState = exports.tabPartnerValidState = exports.tabSubCampaignValidState = exports.tabInfomationValidState = exports.campaignPartnerState = exports.campaignGroupsState = exports.campaignApprovalState = exports.campaignAttributesState = exports.campaignState = exports.campaignModelState = exports.confirmExitState = exports.isCreateState = exports.attributesState = exports.directoriesState = void 0;
|
|
14
|
+
exports.cacheSearchPageState = exports.weightState = exports.readyForSubmitState = exports.tabPartnerValidState = exports.tabSubCampaignValidState = exports.tabInfomationValidState = exports.campaignPartnerState = exports.campaignGroupsState = exports.campaignApprovalState = exports.campaignAttributesState = exports.campaignState = exports.campaignModelState = exports.confirmExitState = exports.campaignApprovalTableState = exports.isCreateState = exports.attributesState = exports.directoriesState = void 0;
|
|
15
15
|
var recoil_1 = require("recoil");
|
|
16
16
|
var Utils_1 = require("../Utils");
|
|
17
17
|
var atoms_1 = require("./TabSubCampaign/atoms");
|
|
@@ -28,6 +28,10 @@ exports.isCreateState = (0, recoil_1.atom)({
|
|
|
28
28
|
key: 'isCreateState',
|
|
29
29
|
default: false,
|
|
30
30
|
});
|
|
31
|
+
exports.campaignApprovalTableState = (0, recoil_1.atom)({
|
|
32
|
+
key: 'campaignApprovalTableState',
|
|
33
|
+
default: [],
|
|
34
|
+
});
|
|
31
35
|
/**
|
|
32
36
|
* Đánh dấu việc cần xác nhận lại trước khi đóng (set thành true khi có bất kỳ chỉnh sửa campaign nào)
|
|
33
37
|
*/
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { ICampaignApprovalSubRow, ICampaignApprovalTable, ICampaignApprovalTableRow } from '../../../../ACM-AXN/Campaign/Types';
|
|
3
3
|
interface TableRowProps {
|
|
4
|
-
row:
|
|
5
|
-
link:
|
|
6
|
-
sub:
|
|
4
|
+
row: ICampaignApprovalTable;
|
|
5
|
+
link: ICampaignApprovalTableRow;
|
|
6
|
+
sub: ICampaignApprovalSubRow;
|
|
7
7
|
linkIndex: number;
|
|
8
8
|
subIndex: number;
|
|
9
|
-
rowSelected:
|
|
10
|
-
handleRowSelect: (id:
|
|
11
|
-
updateRow: (
|
|
9
|
+
rowSelected: string[];
|
|
10
|
+
handleRowSelect: (id: string) => void;
|
|
11
|
+
updateRow: (dataTableUpdate: {
|
|
12
12
|
status: number;
|
|
13
13
|
description: string;
|
|
14
|
-
},
|
|
14
|
+
}, rowId: string, linkId: string) => void;
|
|
15
15
|
}
|
|
16
16
|
declare const TableRowMemo: React.FC<TableRowProps>;
|
|
17
17
|
export default TableRowMemo;
|
|
@@ -56,7 +56,7 @@ var TableRowMemo = react_1.default.memo(function (_a) {
|
|
|
56
56
|
updateRow({
|
|
57
57
|
status: newStatus,
|
|
58
58
|
description: valueInput
|
|
59
|
-
}, row.id);
|
|
59
|
+
}, row.id, link.id);
|
|
60
60
|
}, [row, link]);
|
|
61
61
|
var handleInputChange = (0, react_1.useCallback)(function (event) {
|
|
62
62
|
var newValue = event.target.value;
|
|
@@ -64,7 +64,7 @@ var TableRowMemo = react_1.default.memo(function (_a) {
|
|
|
64
64
|
updateRow({
|
|
65
65
|
status: selectStatus,
|
|
66
66
|
description: newValue
|
|
67
|
-
}, row.id);
|
|
67
|
+
}, row.id, link.id);
|
|
68
68
|
}, [row, link]);
|
|
69
69
|
return ((0, jsx_runtime_1.jsxs)(material_1.TableRow, { children: [linkIndex === 0 && subIndex === 0 && ((0, jsx_runtime_1.jsx)(material_1.TableCell, { rowSpan: row.detail.reduce(function (acc, curr) { return acc + curr.campaign.length; }, 0), style: { width: 60, padding: '0 0 0 4px' }, children: (0, jsx_runtime_1.jsx)(material_1.Box, { display: 'flex', children: (0, jsx_runtime_1.jsx)(material_1.Checkbox, { checked: rowSelected.some(function (x) { return x === row.id; }), color: "primary", onChange: function () { return handleRowSelect(row.id); } }) }) })), linkIndex === 0 && subIndex === 0 && ((0, jsx_runtime_1.jsx)(material_1.TableCell, { rowSpan: row.detail.reduce(function (acc, curr) { return acc + curr.campaign.length; }, 0), children: row.domain.domainName })), subIndex === 0 && ((0, jsx_runtime_1.jsx)(material_1.TableCell, { rowSpan: link.campaign.length, style: { maxWidth: 400 }, children: (0, jsx_runtime_1.jsx)(material_1.Box, { sx: {
|
|
70
70
|
display: '-webkit-box',
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,74 +1,219 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
//
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
50
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
51
|
+
};
|
|
52
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
|
+
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
54
|
+
var react_1 = require("@testing-library/react");
|
|
55
|
+
var Enum_1 = require("../../../../ACM-AXN/Campaign/Enum");
|
|
56
|
+
var RowTable_1 = __importDefault(require("./RowTable"));
|
|
57
|
+
var user_event_1 = __importDefault(require("@testing-library/user-event"));
|
|
58
|
+
// Mock the useTranslation hook
|
|
59
|
+
jest.mock('react-i18next', function () { return ({
|
|
60
|
+
useTranslation: function () { return ({ t: function (key) { return key; } }); },
|
|
61
|
+
}); });
|
|
62
|
+
var mockProps = {
|
|
63
|
+
row: {
|
|
64
|
+
id: '100',
|
|
65
|
+
domain: {
|
|
66
|
+
domainName: 'Vincom',
|
|
67
|
+
domainId: '100',
|
|
68
|
+
},
|
|
69
|
+
detail: [
|
|
70
|
+
{
|
|
71
|
+
id: '10c77e54-8aff-4e36-8334-70eca26d5a75',
|
|
72
|
+
linkPreview: 'http://connect.awifi.com.vn/Preview/Page?loginId=5122170857262705548&welcomeId=4841207366749869113&isNetworkCampaign=true&domainId=100',
|
|
73
|
+
campaign: [
|
|
74
|
+
{
|
|
75
|
+
subCampaigns: [
|
|
76
|
+
{
|
|
77
|
+
id: 1,
|
|
78
|
+
name: 'Sub-Campaign 1',
|
|
79
|
+
},
|
|
80
|
+
],
|
|
81
|
+
ads: [
|
|
82
|
+
{
|
|
83
|
+
id: 1,
|
|
84
|
+
name: 'Ad 1',
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
id: 2,
|
|
88
|
+
name: 'Ad 2',
|
|
89
|
+
},
|
|
90
|
+
],
|
|
91
|
+
},
|
|
92
|
+
],
|
|
93
|
+
status: 0,
|
|
94
|
+
description: '',
|
|
95
|
+
loginId: '5122170857262705548',
|
|
96
|
+
welcomeId: '4841207366749869113',
|
|
97
|
+
},
|
|
98
|
+
],
|
|
99
|
+
},
|
|
100
|
+
link: {
|
|
101
|
+
id: '10c77e54-8aff-4e36-8334-70eca26d5a75',
|
|
102
|
+
linkPreview: 'http://connect.awifi.com.vn/Preview/Page?loginId=5122170857262705548&welcomeId=4841207366749869113&isNetworkCampaign=true&domainId=100',
|
|
103
|
+
campaign: [
|
|
104
|
+
{
|
|
105
|
+
subCampaigns: [
|
|
106
|
+
{
|
|
107
|
+
id: 1,
|
|
108
|
+
name: 'Sub-Campaign 1',
|
|
109
|
+
},
|
|
110
|
+
],
|
|
111
|
+
ads: [
|
|
112
|
+
{
|
|
113
|
+
id: 1,
|
|
114
|
+
name: 'Ad 1',
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
id: 2,
|
|
118
|
+
name: 'Ad 2',
|
|
119
|
+
},
|
|
120
|
+
],
|
|
121
|
+
},
|
|
122
|
+
],
|
|
123
|
+
status: 0,
|
|
124
|
+
description: '',
|
|
125
|
+
loginId: '5122170857262705548',
|
|
126
|
+
welcomeId: '4841207366749869113',
|
|
127
|
+
},
|
|
128
|
+
sub: {
|
|
129
|
+
subCampaigns: [
|
|
130
|
+
{
|
|
131
|
+
id: 1,
|
|
132
|
+
name: 'Sub-Campaign 1',
|
|
133
|
+
},
|
|
134
|
+
],
|
|
135
|
+
ads: [
|
|
136
|
+
{
|
|
137
|
+
id: 1,
|
|
138
|
+
name: 'Ad 1',
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
id: 2,
|
|
142
|
+
name: 'Ad 2',
|
|
143
|
+
},
|
|
144
|
+
],
|
|
145
|
+
},
|
|
146
|
+
linkIndex: 0,
|
|
147
|
+
subIndex: 0,
|
|
148
|
+
rowSelected: [],
|
|
149
|
+
handleRowSelect: jest.fn(),
|
|
150
|
+
updateRow: jest.fn(),
|
|
151
|
+
};
|
|
152
|
+
// Mock cho các component MUI
|
|
153
|
+
jest.mock('@mui/material', function () { return (__assign(__assign({}, jest.requireActual('@mui/material')), { TableCell: function (_a) {
|
|
154
|
+
var children = _a.children;
|
|
155
|
+
return (0, jsx_runtime_1.jsx)("td", { children: children });
|
|
156
|
+
}, Chip: function (_a) {
|
|
157
|
+
var label = _a.label;
|
|
158
|
+
return (0, jsx_runtime_1.jsx)("span", { children: label });
|
|
159
|
+
}, FormControl: function (_a) {
|
|
160
|
+
var children = _a.children;
|
|
161
|
+
return (0, jsx_runtime_1.jsx)("div", { children: children });
|
|
162
|
+
}, Select: function (_a) {
|
|
163
|
+
var children = _a.children, value = _a.value, onChange = _a.onChange;
|
|
164
|
+
return ((0, jsx_runtime_1.jsx)("select", { value: value, onChange: onChange, children: children }));
|
|
165
|
+
}, MenuItem: function (_a) {
|
|
166
|
+
var children = _a.children, value = _a.value;
|
|
167
|
+
return ((0, jsx_runtime_1.jsx)("option", { value: value, children: children }));
|
|
168
|
+
}, TextField: function (_a) {
|
|
169
|
+
var value = _a.value, onChange = _a.onChange;
|
|
170
|
+
return ((0, jsx_runtime_1.jsx)("input", { type: "text", value: value, onChange: onChange }));
|
|
171
|
+
}, Link: function (_a) {
|
|
172
|
+
var children = _a.children, href = _a.href, target = _a.target;
|
|
173
|
+
return ((0, jsx_runtime_1.jsx)("a", { href: href, target: target, children: children }));
|
|
174
|
+
} })); });
|
|
175
|
+
var renderUi = function () {
|
|
176
|
+
return (0, react_1.render)((0, jsx_runtime_1.jsx)("table", { children: (0, jsx_runtime_1.jsx)("tbody", { children: (0, jsx_runtime_1.jsx)(RowTable_1.default, __assign({}, mockProps)) }) }));
|
|
177
|
+
};
|
|
178
|
+
describe('TableRowMemo', function () {
|
|
179
|
+
it('renders correctly', function () {
|
|
180
|
+
renderUi();
|
|
181
|
+
expect(react_1.screen.getByText('Vincom')).toBeInTheDocument();
|
|
182
|
+
expect(react_1.screen.getByText('http://connect.awifi.com.vn/Preview/Page?loginId=5122170857262705548&welcomeId=4841207366749869113&isNetworkCampaign=true&domainId=100')).toBeInTheDocument();
|
|
183
|
+
expect(react_1.screen.getByText('Sub-Campaign 1')).toBeInTheDocument();
|
|
184
|
+
expect(react_1.screen.getByText('Ad 1')).toBeInTheDocument();
|
|
185
|
+
});
|
|
186
|
+
it('handles checkbox change', function () {
|
|
187
|
+
renderUi();
|
|
188
|
+
var checkbox = react_1.screen.getByRole('checkbox');
|
|
189
|
+
react_1.fireEvent.click(checkbox);
|
|
190
|
+
expect(mockProps.handleRowSelect).toHaveBeenCalledWith('100');
|
|
191
|
+
});
|
|
192
|
+
it('handles status change', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
193
|
+
var select;
|
|
194
|
+
return __generator(this, function (_a) {
|
|
195
|
+
switch (_a.label) {
|
|
196
|
+
case 0:
|
|
197
|
+
renderUi();
|
|
198
|
+
select = react_1.screen.getByRole('combobox');
|
|
199
|
+
return [4 /*yield*/, user_event_1.default.selectOptions(select, Enum_1.CampaignApprovalStatus.Rejected.toString())];
|
|
200
|
+
case 1:
|
|
201
|
+
_a.sent();
|
|
202
|
+
expect(mockProps.updateRow).toHaveBeenCalledWith({
|
|
203
|
+
status: Enum_1.CampaignApprovalStatus.Rejected.toString(),
|
|
204
|
+
description: '',
|
|
205
|
+
}, '100', '10c77e54-8aff-4e36-8334-70eca26d5a75');
|
|
206
|
+
return [2 /*return*/];
|
|
207
|
+
}
|
|
208
|
+
});
|
|
209
|
+
}); });
|
|
210
|
+
it('handles description change', function () {
|
|
211
|
+
renderUi();
|
|
212
|
+
var input = react_1.screen.getByRole('textbox');
|
|
213
|
+
react_1.fireEvent.change(input, { target: { value: 'New description' } });
|
|
214
|
+
expect(mockProps.updateRow).toHaveBeenCalledWith({
|
|
215
|
+
status: Enum_1.CampaignApprovalStatus.PendingApproval,
|
|
216
|
+
description: 'New description',
|
|
217
|
+
}, '100', '10c77e54-8aff-4e36-8334-70eca26d5a75');
|
|
218
|
+
});
|
|
219
|
+
});
|
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
18
|
+
var recoil_1 = require("recoil");
|
|
19
|
+
var Recoils_1 = require("../Recoils");
|
|
20
|
+
var react_1 = require("react");
|
|
21
|
+
var Hooks_1 = __importDefault(require("../../../../ACM-AXN/Campaign/Hooks"));
|
|
22
|
+
var Constant_1 = require("../../../../ACM-AXN/Common/Constant");
|
|
23
|
+
var lodash_1 = __importDefault(require("lodash"));
|
|
24
|
+
var Helpers_1 = require("../../../../Utils/Helpers");
|
|
25
|
+
var Router_1 = require("../../../../AWING/Router");
|
|
26
|
+
var atoms_1 = require("../TabSubCampaign/atoms");
|
|
27
|
+
var icons_material_1 = require("@mui/icons-material");
|
|
28
|
+
var RunInBackground = function () {
|
|
29
|
+
var campaignId = (0, Router_1.useParams)().campaignId;
|
|
30
|
+
var subCampaigns = (0, recoil_1.useRecoilValue)(Recoils_1.campaignGroupsState);
|
|
31
|
+
var subCampaignDetailValid = (0, recoil_1.useRecoilValue)(atoms_1.subCampaignDetailValidState);
|
|
32
|
+
var subCampaignAdsValid = (0, recoil_1.useRecoilValue)(atoms_1.subCampaignAdsValidState);
|
|
33
|
+
var _a = (0, Hooks_1.default)(), service = _a.service, defaultDomainId = _a.domainId;
|
|
34
|
+
var _b = (0, recoil_1.useRecoilState)(Recoils_1.campaignApprovalState), campaignApproval = _b[0], setCampaignApproval = _b[1];
|
|
35
|
+
var _c = (0, recoil_1.useRecoilState)(Recoils_1.campaignApprovalTableState), campaignApprovalTable = _c[0], setCampaignApprovalTable = _c[1];
|
|
36
|
+
var _d = (0, react_1.useState)([]), domains = _d[0], setDomains = _d[1];
|
|
37
|
+
var _e = (0, react_1.useState)(true), isInit = _e[0], setIsInit = _e[1];
|
|
38
|
+
var oldCampaignApproval = (0, react_1.useRef)([]);
|
|
39
|
+
var prevDomainIds = (0, react_1.useRef)([]);
|
|
40
|
+
var domainIds = (0, react_1.useMemo)(function () {
|
|
41
|
+
var ads = subCampaigns.flatMap(function (sub) { return sub.ads; });
|
|
42
|
+
return lodash_1.default.uniq(ads
|
|
43
|
+
.filter(function (ad) { return ad.places; })
|
|
44
|
+
.map(function (ad) { return ad.places.map(function (x) { return x.domainId; }); })
|
|
45
|
+
.flat()
|
|
46
|
+
.filter(Boolean));
|
|
47
|
+
}, [subCampaigns]);
|
|
48
|
+
var areAllTrue = function (data) {
|
|
49
|
+
return Object.values(data).every(function (value) { return value === true; });
|
|
50
|
+
};
|
|
51
|
+
var renderLinkPreview = function (ad, domainId) {
|
|
52
|
+
if (domainId === void 0) { domainId = defaultDomainId; }
|
|
53
|
+
var url = "".concat(Constant_1.Constants.CAPTIVE_DOMAIN, "/").concat(Constant_1.Constants.PAGE_LOGIN_PREVIEW, "?loginId=").concat(ad.loginId);
|
|
54
|
+
if (ad.welcomeId)
|
|
55
|
+
url += "&welcomeId=".concat(ad.welcomeId, "&isNetworkCampaign=").concat(Boolean(service.domainsGetAll).toString());
|
|
56
|
+
if (domainId)
|
|
57
|
+
url += "&domainId=".concat(domainId);
|
|
58
|
+
return url;
|
|
59
|
+
};
|
|
60
|
+
var mergedData = function (data) {
|
|
61
|
+
return data.reduce(function (acc, detail) {
|
|
62
|
+
var existingLink = acc.find(function (l) { return l.linkPreview === detail.linkPreview; });
|
|
63
|
+
if (existingLink) {
|
|
64
|
+
var existingCampaign = existingLink.campaign.find(function (item) {
|
|
65
|
+
return item.subCampaigns.find(function (subCampaign) {
|
|
66
|
+
return subCampaign.id ===
|
|
67
|
+
detail.campaign[0].subCampaigns[0].id;
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
if (existingCampaign) {
|
|
71
|
+
existingCampaign.ads.push({
|
|
72
|
+
id: detail.campaign[0].ads[0].id,
|
|
73
|
+
name: detail.campaign[0].ads[0].name,
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
detail.campaign.forEach(function (item) {
|
|
78
|
+
existingLink.campaign.push(item);
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
acc.push({
|
|
84
|
+
id: (0, Helpers_1.generateUUID)(),
|
|
85
|
+
linkPreview: detail.linkPreview,
|
|
86
|
+
campaign: detail.campaign,
|
|
87
|
+
status: detail.status,
|
|
88
|
+
description: detail.description,
|
|
89
|
+
loginId: detail.loginId,
|
|
90
|
+
welcomeId: detail.welcomeId,
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
return acc;
|
|
94
|
+
}, []);
|
|
95
|
+
};
|
|
96
|
+
var renderDataDetail = function (domainId) {
|
|
97
|
+
return mergedData(subCampaigns
|
|
98
|
+
.map(function (subCampaign) {
|
|
99
|
+
return subCampaign.ads
|
|
100
|
+
.map(function (ad) {
|
|
101
|
+
var _a;
|
|
102
|
+
var isDomain = (_a = ad === null || ad === void 0 ? void 0 : ad.places) === null || _a === void 0 ? void 0 : _a.find(function (place) {
|
|
103
|
+
return place.domainId === domainId;
|
|
104
|
+
});
|
|
105
|
+
if (isDomain) {
|
|
106
|
+
return {
|
|
107
|
+
linkPreview: renderLinkPreview(ad, domainId),
|
|
108
|
+
campaign: [
|
|
109
|
+
{
|
|
110
|
+
subCampaigns: [
|
|
111
|
+
{
|
|
112
|
+
id: subCampaign
|
|
113
|
+
.campaignGroup.id,
|
|
114
|
+
name: subCampaign
|
|
115
|
+
.campaignGroup.name,
|
|
116
|
+
},
|
|
117
|
+
],
|
|
118
|
+
ads: [
|
|
119
|
+
{
|
|
120
|
+
id: ad.id,
|
|
121
|
+
name: ad.name,
|
|
122
|
+
},
|
|
123
|
+
],
|
|
124
|
+
},
|
|
125
|
+
],
|
|
126
|
+
loginId: ad.loginId,
|
|
127
|
+
welcomeId: ad.welcomeId,
|
|
128
|
+
description: '',
|
|
129
|
+
status: 0,
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
})
|
|
133
|
+
.filter(Boolean);
|
|
134
|
+
})
|
|
135
|
+
.flat()
|
|
136
|
+
.filter(Boolean));
|
|
137
|
+
};
|
|
138
|
+
var flattenData = function (data) {
|
|
139
|
+
var flattened = [];
|
|
140
|
+
var index = 0;
|
|
141
|
+
data.forEach(function (item) {
|
|
142
|
+
item.detail.forEach(function (detail) {
|
|
143
|
+
detail.campaign.forEach(function (campaign) {
|
|
144
|
+
campaign.ads.forEach(function (ad) {
|
|
145
|
+
var _a;
|
|
146
|
+
flattened.push({
|
|
147
|
+
id: index++,
|
|
148
|
+
campaignId: campaignId,
|
|
149
|
+
domainId: item.domain.domainId,
|
|
150
|
+
status: detail.status,
|
|
151
|
+
loginId: detail.loginId,
|
|
152
|
+
welcomeId: detail.welcomeId,
|
|
153
|
+
description: detail.description,
|
|
154
|
+
campaignGroupId: (_a = campaign.subCampaigns[0]) === null || _a === void 0 ? void 0 : _a.id,
|
|
155
|
+
campaignAdId: ad === null || ad === void 0 ? void 0 : ad.id,
|
|
156
|
+
});
|
|
157
|
+
});
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
});
|
|
161
|
+
return flattened;
|
|
162
|
+
};
|
|
163
|
+
var unflattenData = function (inputData) {
|
|
164
|
+
var subCampaignsFlat = subCampaigns.flatMap(function (item) {
|
|
165
|
+
var subCampaignId = item.campaignGroup.id;
|
|
166
|
+
var subCampaignName = item.campaignGroup.name;
|
|
167
|
+
return item.ads.map(function (ad) { return ({
|
|
168
|
+
subCampaignId: subCampaignId,
|
|
169
|
+
subCampaignName: subCampaignName,
|
|
170
|
+
adId: ad.id,
|
|
171
|
+
adName: ad.name,
|
|
172
|
+
loginId: ad.loginId,
|
|
173
|
+
welcomeId: ad.welcomeId,
|
|
174
|
+
}); });
|
|
175
|
+
});
|
|
176
|
+
var findAd = function (subId, adId) {
|
|
177
|
+
var ad = subCampaignsFlat.find(function (item) { return item.adId === adId && item.subCampaignId === subId; });
|
|
178
|
+
return ad;
|
|
179
|
+
};
|
|
180
|
+
var groupedData = inputData.reduce(function (acc, item) {
|
|
181
|
+
var _a, _b, _c;
|
|
182
|
+
var domainId = item.domainId;
|
|
183
|
+
if (!acc[domainId]) {
|
|
184
|
+
var domain = domains.find(function (d) { return d.domainId === domainId; });
|
|
185
|
+
acc[domainId] = {
|
|
186
|
+
id: domainId,
|
|
187
|
+
domain: {
|
|
188
|
+
domainName: domain === null || domain === void 0 ? void 0 : domain.name,
|
|
189
|
+
domainId: domain === null || domain === void 0 ? void 0 : domain.domainId,
|
|
190
|
+
},
|
|
191
|
+
detail: [],
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
// Tạo linkPreview chỉ nếu chưa tồn tại
|
|
195
|
+
var existingDetail = acc[domainId].detail.find(function (detail) {
|
|
196
|
+
return detail.loginId === item.loginId &&
|
|
197
|
+
detail.welcomeId === item.welcomeId;
|
|
198
|
+
});
|
|
199
|
+
if (!existingDetail) {
|
|
200
|
+
acc[domainId].detail.push({
|
|
201
|
+
id: (0, Helpers_1.generateUUID)(),
|
|
202
|
+
linkPreview: renderLinkPreview({
|
|
203
|
+
loginId: item.loginId,
|
|
204
|
+
welcomeId: item.welcomeId,
|
|
205
|
+
}, domainId),
|
|
206
|
+
campaign: [],
|
|
207
|
+
status: item.status,
|
|
208
|
+
description: item.description,
|
|
209
|
+
loginId: item.loginId,
|
|
210
|
+
welcomeId: item.welcomeId,
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
var campaign = (_a = acc[domainId].detail.find(function (detail) {
|
|
214
|
+
return detail.loginId === item.loginId &&
|
|
215
|
+
detail.welcomeId === item.welcomeId;
|
|
216
|
+
})) === null || _a === void 0 ? void 0 : _a.campaign;
|
|
217
|
+
var subCampaign = campaign.find(function (c) { return c.subCampaigns[0].id === item.campaignGroupId; });
|
|
218
|
+
if (!subCampaign) {
|
|
219
|
+
var sub = subCampaigns.find(function (subCampaign) {
|
|
220
|
+
return subCampaign.campaignGroup.id ===
|
|
221
|
+
item.campaignGroupId;
|
|
222
|
+
});
|
|
223
|
+
subCampaign = {
|
|
224
|
+
subCampaigns: [
|
|
225
|
+
{
|
|
226
|
+
id: sub.campaignGroup.id,
|
|
227
|
+
name: sub.campaignGroup.name,
|
|
228
|
+
},
|
|
229
|
+
],
|
|
230
|
+
ads: [],
|
|
231
|
+
};
|
|
232
|
+
campaign.push(subCampaign);
|
|
233
|
+
}
|
|
234
|
+
subCampaign.ads.push({
|
|
235
|
+
id: item.campaignAdId,
|
|
236
|
+
name: (_c = (_b = findAd(subCampaign.subCampaigns[0].id, item.campaignAdId)) === null || _b === void 0 ? void 0 : _b.adName) !== null && _c !== void 0 ? _c : '',
|
|
237
|
+
});
|
|
238
|
+
return acc;
|
|
239
|
+
}, {});
|
|
240
|
+
return Object.values(groupedData);
|
|
241
|
+
};
|
|
242
|
+
var fetchDomains = (0, react_1.useCallback)(function (ids) {
|
|
243
|
+
if (ids.length > 0 && service.domainsGetByIds) {
|
|
244
|
+
service.domainsGetByIds(ids).then(setDomains);
|
|
245
|
+
}
|
|
246
|
+
}, [service.domainsGetByIds, setDomains]);
|
|
247
|
+
var dataDiff = function (apiData, currentData) {
|
|
248
|
+
var mergedData = currentData.map(function (currentItem) {
|
|
249
|
+
var matchingApiItem = apiData.find(function (apiItem) {
|
|
250
|
+
return apiItem.domainId === currentItem.domainId &&
|
|
251
|
+
apiItem.campaignGroupId === currentItem.campaignGroupId &&
|
|
252
|
+
apiItem.campaignAdId === currentItem.campaignAdId;
|
|
253
|
+
});
|
|
254
|
+
if (matchingApiItem) {
|
|
255
|
+
return __assign(__assign({}, currentItem), { status: matchingApiItem.status });
|
|
256
|
+
}
|
|
257
|
+
return currentItem;
|
|
258
|
+
});
|
|
259
|
+
return mergedData;
|
|
260
|
+
};
|
|
261
|
+
var campaignApprovalMerged = function (oldData, newData) {
|
|
262
|
+
return newData.map(function (newItem) {
|
|
263
|
+
var newDomainId = newItem.domain.domainId;
|
|
264
|
+
newItem.detail = newItem.detail.map(function (newDetail) {
|
|
265
|
+
var oldItem = oldData.find(function (item) { return item.domain.domainId === newDomainId; });
|
|
266
|
+
if (oldItem) {
|
|
267
|
+
var oldDetail = oldItem.detail.find(function (detail) {
|
|
268
|
+
return detail.welcomeId === newDetail.welcomeId &&
|
|
269
|
+
detail.loginId === newDetail.loginId;
|
|
270
|
+
});
|
|
271
|
+
if (oldDetail) {
|
|
272
|
+
return __assign(__assign({}, newDetail), { status: oldDetail.status });
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
return newDetail;
|
|
276
|
+
});
|
|
277
|
+
return newItem;
|
|
278
|
+
});
|
|
279
|
+
};
|
|
280
|
+
(0, react_1.useEffect)(function () {
|
|
281
|
+
if (!Boolean(service.attributesGetByObjectTypeCode))
|
|
282
|
+
icons_material_1.KeyboardReturn;
|
|
283
|
+
if (!domains.length)
|
|
284
|
+
return setCampaignApprovalTable([]);
|
|
285
|
+
// if (campaignApproval?.length) {
|
|
286
|
+
// return setCampaignApprovalTable(unflattenData(campaignApproval))
|
|
287
|
+
// }
|
|
288
|
+
if (areAllTrue(subCampaignDetailValid) &&
|
|
289
|
+
areAllTrue(subCampaignAdsValid)) {
|
|
290
|
+
var data = domains.map(function (domain) {
|
|
291
|
+
return {
|
|
292
|
+
id: domain.domainId,
|
|
293
|
+
domain: {
|
|
294
|
+
domainName: domain.name,
|
|
295
|
+
domainId: domain.domainId,
|
|
296
|
+
},
|
|
297
|
+
detail: renderDataDetail(domain.domainId),
|
|
298
|
+
};
|
|
299
|
+
});
|
|
300
|
+
return setCampaignApprovalTable(campaignApprovalMerged(unflattenData(oldCampaignApproval.current), data));
|
|
301
|
+
}
|
|
302
|
+
}, [domains, subCampaigns]);
|
|
303
|
+
(0, react_1.useEffect)(function () {
|
|
304
|
+
if (!lodash_1.default.isEqual(prevDomainIds.current, domainIds)) {
|
|
305
|
+
fetchDomains(domainIds);
|
|
306
|
+
prevDomainIds.current = domainIds;
|
|
307
|
+
}
|
|
308
|
+
}, [domainIds]);
|
|
309
|
+
(0, react_1.useEffect)(function () {
|
|
310
|
+
if (campaignApprovalTable.length > 0) {
|
|
311
|
+
setCampaignApproval(flattenData(campaignApprovalTable));
|
|
312
|
+
}
|
|
313
|
+
}, [campaignApprovalTable]);
|
|
314
|
+
(0, react_1.useEffect)(function () {
|
|
315
|
+
if (!oldCampaignApproval.current.length && isInit) {
|
|
316
|
+
oldCampaignApproval.current = campaignApproval !== null && campaignApproval !== void 0 ? campaignApproval : [];
|
|
317
|
+
setIsInit(true);
|
|
318
|
+
}
|
|
319
|
+
}, [campaignApproval]);
|
|
320
|
+
return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {});
|
|
321
|
+
};
|
|
322
|
+
exports.default = RunInBackground;
|
|
@@ -1,26 +1 @@
|
|
|
1
|
-
interface IItem {
|
|
2
|
-
id?: number;
|
|
3
|
-
name?: string;
|
|
4
|
-
}
|
|
5
|
-
export interface ICammpaignItem {
|
|
6
|
-
subCampaigns: IItem[];
|
|
7
|
-
ads: IItem[];
|
|
8
|
-
}
|
|
9
|
-
export interface IDetail {
|
|
10
|
-
id?: number;
|
|
11
|
-
status: number;
|
|
12
|
-
linkPreview: string;
|
|
13
|
-
subCampaigns?: IItem[];
|
|
14
|
-
campaign: ICammpaignItem[];
|
|
15
|
-
description: string;
|
|
16
|
-
}
|
|
17
|
-
export interface IDataTable {
|
|
18
|
-
id: number;
|
|
19
|
-
domain: {
|
|
20
|
-
domainName?: string;
|
|
21
|
-
domainId?: string;
|
|
22
|
-
};
|
|
23
|
-
detail: IDetail[];
|
|
24
|
-
}
|
|
25
1
|
export default function TabApprove(): import("react/jsx-runtime").JSX.Element;
|
|
26
|
-
export {};
|
|
@@ -25,271 +25,56 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
27
27
|
var material_1 = require("@mui/material");
|
|
28
|
-
var Hooks_1 = __importDefault(require("../../../../ACM-AXN/Campaign/Hooks"));
|
|
29
|
-
var Constant_1 = require("../../../../ACM-AXN/Common/Constant");
|
|
30
|
-
var Router_1 = require("../../../../AWING/Router");
|
|
31
|
-
var lodash_1 = __importDefault(require("lodash"));
|
|
32
28
|
var react_1 = require("react");
|
|
33
29
|
var react_i18next_1 = require("react-i18next");
|
|
34
30
|
var recoil_1 = require("recoil");
|
|
35
31
|
var Recoils_1 = require("../Recoils");
|
|
36
|
-
var atoms_1 = require("../TabSubCampaign/atoms");
|
|
37
32
|
var RowTable_1 = __importDefault(require("./RowTable"));
|
|
38
33
|
function TabApprove() {
|
|
39
34
|
var t = (0, react_i18next_1.useTranslation)().t;
|
|
40
|
-
var campaignId = (0, Router_1.useParams)().campaignId;
|
|
41
|
-
var _a = (0, recoil_1.useRecoilState)(Recoils_1.campaignApprovalState), campaignApproval = _a[0], setCampaignApproval = _a[1];
|
|
42
35
|
var setConfirmExit = (0, recoil_1.useSetRecoilState)(Recoils_1.confirmExitState);
|
|
43
|
-
var
|
|
44
|
-
var
|
|
45
|
-
var ads = (0, recoil_1.useRecoilValue)(atoms_1.adListState);
|
|
46
|
-
var subCampaigns = (0, recoil_1.useRecoilValue)(Recoils_1.campaignGroupsState);
|
|
47
|
-
var _d = (0, Hooks_1.default)(), service = _d.service, defaultDomainId = _d.domainId;
|
|
48
|
-
var domainIds = (0, react_1.useMemo)(function () {
|
|
49
|
-
return lodash_1.default.uniq(ads
|
|
50
|
-
.filter(function (ad) { return ad.places; })
|
|
51
|
-
.map(function (ad) { return ad.places.map(function (x) { return x.domainId; }); })
|
|
52
|
-
.flat()
|
|
53
|
-
.filter(Boolean));
|
|
54
|
-
}, [ads]);
|
|
55
|
-
var generateRandomId = function () {
|
|
56
|
-
return Math.floor(Math.random() * 1000000000); // Số ngẫu nhiên từ 0 đến 999,999,999
|
|
57
|
-
};
|
|
58
|
-
var renderLinkPreview = function (ad, domainId) {
|
|
59
|
-
if (domainId === void 0) { domainId = defaultDomainId; }
|
|
60
|
-
var url = "".concat(Constant_1.Constants.CAPTIVE_DOMAIN, "/").concat(Constant_1.Constants.PAGE_LOGIN_PREVIEW, "?loginId=").concat(ad.loginId, "&isNetworkCampaign=").concat(Boolean(service.domainsGetAll).toString());
|
|
61
|
-
if (ad.welcomeId)
|
|
62
|
-
url += "&welcomeId=".concat(ad.welcomeId);
|
|
63
|
-
if (domainId)
|
|
64
|
-
url += "&domainId=".concat(domainId);
|
|
65
|
-
return url;
|
|
66
|
-
};
|
|
67
|
-
var mergedData = function (data) {
|
|
68
|
-
return data.reduce(function (acc, detail) {
|
|
69
|
-
var existingLink = acc.find(function (l) { return l.linkPreview === detail.linkPreview; });
|
|
70
|
-
if (existingLink) {
|
|
71
|
-
var existingCampaign = existingLink.campaign.find(function (item) {
|
|
72
|
-
return item.subCampaigns.find(function (subCampaign) {
|
|
73
|
-
return subCampaign.id ===
|
|
74
|
-
detail.campaign[0].subCampaigns[0].id;
|
|
75
|
-
});
|
|
76
|
-
});
|
|
77
|
-
if (existingCampaign) {
|
|
78
|
-
existingCampaign.ads.push({
|
|
79
|
-
id: detail.campaign[0].ads[0].id,
|
|
80
|
-
name: detail.campaign[0].ads[0].name,
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
else {
|
|
84
|
-
detail.campaign.forEach(function (item) {
|
|
85
|
-
existingLink.campaign.push(item);
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
else {
|
|
90
|
-
acc.push({
|
|
91
|
-
id: generateRandomId(),
|
|
92
|
-
linkPreview: detail.linkPreview,
|
|
93
|
-
campaign: detail.campaign,
|
|
94
|
-
status: detail.status,
|
|
95
|
-
description: detail.description,
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
return acc;
|
|
99
|
-
}, []);
|
|
100
|
-
};
|
|
101
|
-
var renderDataDetail = function (domainId) {
|
|
102
|
-
return mergedData(subCampaigns
|
|
103
|
-
.map(function (subCampaign) {
|
|
104
|
-
return subCampaign.ads
|
|
105
|
-
.map(function (ad) {
|
|
106
|
-
var _a;
|
|
107
|
-
var isDomain = (_a = ad === null || ad === void 0 ? void 0 : ad.places) === null || _a === void 0 ? void 0 : _a.find(function (place) {
|
|
108
|
-
return place.domainId === domainId;
|
|
109
|
-
});
|
|
110
|
-
if (isDomain) {
|
|
111
|
-
return {
|
|
112
|
-
linkPreview: renderLinkPreview(ad, domainId),
|
|
113
|
-
campaign: [
|
|
114
|
-
{
|
|
115
|
-
subCampaigns: [
|
|
116
|
-
{
|
|
117
|
-
id: subCampaign
|
|
118
|
-
.campaignGroup.id,
|
|
119
|
-
name: subCampaign
|
|
120
|
-
.campaignGroup.name,
|
|
121
|
-
},
|
|
122
|
-
],
|
|
123
|
-
ads: [
|
|
124
|
-
{
|
|
125
|
-
id: ad.id,
|
|
126
|
-
name: ad.name,
|
|
127
|
-
},
|
|
128
|
-
],
|
|
129
|
-
},
|
|
130
|
-
],
|
|
131
|
-
description: '',
|
|
132
|
-
status: 0,
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
})
|
|
136
|
-
.filter(Boolean);
|
|
137
|
-
})
|
|
138
|
-
.flat()
|
|
139
|
-
.filter(Boolean));
|
|
140
|
-
};
|
|
36
|
+
var _a = (0, react_1.useState)([]), rowSelected = _a[0], setRowSelected = _a[1];
|
|
37
|
+
var _b = (0, recoil_1.useRecoilState)(Recoils_1.campaignApprovalTableState), campaignApprovalTable = _b[0], setCampaignApprovalTable = _b[1];
|
|
141
38
|
var handleRowSelect = (0, react_1.useCallback)(function (id) {
|
|
142
39
|
setRowSelected(function (pre) {
|
|
143
40
|
return pre.includes(id) ? pre.filter(function (x) { return x !== id; }) : __spreadArray(__spreadArray([], pre, true), [id], false);
|
|
144
41
|
});
|
|
145
42
|
}, []);
|
|
146
|
-
var updateRow = (0, react_1.useCallback)(function (
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
43
|
+
var updateRow = (0, react_1.useCallback)(function (dataUpdate, rowId, linkId) {
|
|
44
|
+
setCampaignApprovalTable(function (pre) {
|
|
45
|
+
return pre.map(function (item) {
|
|
46
|
+
if (item.id === rowId) {
|
|
47
|
+
return __assign(__assign({}, item), { detail: item.detail.map(function (detail) {
|
|
48
|
+
if (detail.id === linkId) {
|
|
49
|
+
return __assign(__assign({}, detail), { status: dataUpdate.status, description: dataUpdate.description });
|
|
50
|
+
}
|
|
51
|
+
return detail;
|
|
52
|
+
}) });
|
|
154
53
|
}
|
|
155
54
|
return item;
|
|
156
55
|
});
|
|
157
|
-
return newState;
|
|
158
|
-
});
|
|
159
|
-
}, [setCampaignApproval]);
|
|
160
|
-
function flattenData(data) {
|
|
161
|
-
var flattened = [];
|
|
162
|
-
data.forEach(function (item) {
|
|
163
|
-
item.detail.forEach(function (detail) {
|
|
164
|
-
detail.campaign.forEach(function (campaign) {
|
|
165
|
-
campaign.ads.forEach(function (ad) {
|
|
166
|
-
var _a;
|
|
167
|
-
flattened.push({
|
|
168
|
-
id: item.id,
|
|
169
|
-
campaignId: campaignId,
|
|
170
|
-
domainId: item.domain.domainId,
|
|
171
|
-
status: detail.status,
|
|
172
|
-
description: detail.description,
|
|
173
|
-
subId: (_a = campaign.subCampaigns[0]) === null || _a === void 0 ? void 0 : _a.id,
|
|
174
|
-
adId: ad === null || ad === void 0 ? void 0 : ad.id,
|
|
175
|
-
});
|
|
176
|
-
});
|
|
177
|
-
});
|
|
178
|
-
});
|
|
179
56
|
});
|
|
180
|
-
|
|
181
|
-
}
|
|
182
|
-
var unflattenData = function (inputData) {
|
|
183
|
-
var subCampaignsFlat = subCampaigns.flatMap(function (item) {
|
|
184
|
-
var subCampaignId = item.campaignGroup.id;
|
|
185
|
-
var subCampaignName = item.campaignGroup.name;
|
|
186
|
-
return item.ads.map(function (ad) { return ({
|
|
187
|
-
subCampaignId: subCampaignId,
|
|
188
|
-
subCampaignName: subCampaignName,
|
|
189
|
-
adId: ad.id,
|
|
190
|
-
adName: ad.name,
|
|
191
|
-
loginId: ad.loginId,
|
|
192
|
-
welcomeId: ad.welcomeId,
|
|
193
|
-
}); });
|
|
194
|
-
});
|
|
195
|
-
var findAd = function (subId, adId) {
|
|
196
|
-
var ad = subCampaignsFlat.find(function (item) { return item.adId === adId && item.subCampaignId === subId; });
|
|
197
|
-
return ad;
|
|
198
|
-
};
|
|
199
|
-
var groupedData = inputData.reduce(function (acc, item) {
|
|
200
|
-
var _a, _b, _c;
|
|
201
|
-
if (!acc[Number(item.domainId)]) {
|
|
202
|
-
var domain = domains.find(function (d) { return d.domainId === item.domainId; });
|
|
203
|
-
acc[Number(item.domainId)] = {
|
|
204
|
-
id: item.id,
|
|
205
|
-
domain: {
|
|
206
|
-
domainName: domain === null || domain === void 0 ? void 0 : domain.name,
|
|
207
|
-
domainId: domain === null || domain === void 0 ? void 0 : domain.domainId,
|
|
208
|
-
},
|
|
209
|
-
detail: [
|
|
210
|
-
{
|
|
211
|
-
id: generateRandomId(),
|
|
212
|
-
linkPreview: renderLinkPreview((_a = findAd(item.subId, item.adId)) !== null && _a !== void 0 ? _a : {}, item.domainId),
|
|
213
|
-
campaign: [],
|
|
214
|
-
status: item.status,
|
|
215
|
-
description: item.description,
|
|
216
|
-
},
|
|
217
|
-
],
|
|
218
|
-
};
|
|
219
|
-
}
|
|
220
|
-
var campaign = acc[Number(item.domainId)].detail[0]
|
|
221
|
-
.campaign;
|
|
222
|
-
var subCampaign = campaign.find(function (c) { return c.subCampaigns[0].id === item.subId; });
|
|
223
|
-
if (!subCampaign) {
|
|
224
|
-
var sub = subCampaigns.find(function (subCampaign) {
|
|
225
|
-
return subCampaign.campaignGroup.id === item.subId;
|
|
226
|
-
});
|
|
227
|
-
subCampaign = {
|
|
228
|
-
subCampaigns: [
|
|
229
|
-
{
|
|
230
|
-
id: sub.campaignGroup.id,
|
|
231
|
-
name: sub.campaignGroup.name,
|
|
232
|
-
},
|
|
233
|
-
],
|
|
234
|
-
ads: [],
|
|
235
|
-
};
|
|
236
|
-
campaign.push(subCampaign);
|
|
237
|
-
}
|
|
238
|
-
subCampaign.ads.push({
|
|
239
|
-
id: item.adId,
|
|
240
|
-
name: (_c = (_b = findAd(subCampaign.subCampaigns[0].id, item.adId)) === null || _b === void 0 ? void 0 : _b.adName) !== null && _c !== void 0 ? _c : '',
|
|
241
|
-
});
|
|
242
|
-
return acc;
|
|
243
|
-
}, {});
|
|
244
|
-
return Object.values(groupedData);
|
|
245
|
-
};
|
|
246
|
-
var dataTable = (0, react_1.useMemo)(function () {
|
|
247
|
-
if (!domains.length)
|
|
248
|
-
return [];
|
|
249
|
-
var data;
|
|
250
|
-
if (campaignApproval === null || campaignApproval === void 0 ? void 0 : campaignApproval.length) {
|
|
251
|
-
return unflattenData(campaignApproval);
|
|
252
|
-
}
|
|
253
|
-
data = domains.map(function (domain) {
|
|
254
|
-
return {
|
|
255
|
-
id: generateRandomId(),
|
|
256
|
-
domain: {
|
|
257
|
-
domainName: domain.name,
|
|
258
|
-
domainId: domain.domainId,
|
|
259
|
-
},
|
|
260
|
-
detail: renderDataDetail(domain.domainId),
|
|
261
|
-
};
|
|
262
|
-
});
|
|
263
|
-
return data;
|
|
264
|
-
}, [domains]);
|
|
57
|
+
setConfirmExit(true);
|
|
58
|
+
}, [campaignApprovalTable]);
|
|
265
59
|
var handleSelectAll = (0, react_1.useCallback)(function () {
|
|
266
60
|
setRowSelected(function (pre) {
|
|
267
|
-
return pre.length <
|
|
268
|
-
?
|
|
61
|
+
return pre.length < campaignApprovalTable.length
|
|
62
|
+
? campaignApprovalTable.map(function (item) { return item.id; })
|
|
269
63
|
: [];
|
|
270
64
|
});
|
|
271
|
-
}, [
|
|
272
|
-
(0, react_1.useEffect)(function () {
|
|
273
|
-
if (domainIds.length > 0) {
|
|
274
|
-
service.domainsGetByIds &&
|
|
275
|
-
service.domainsGetByIds(domainIds).then(setDomains);
|
|
276
|
-
}
|
|
277
|
-
}, [domainIds]);
|
|
278
|
-
(0, react_1.useEffect)(function () {
|
|
279
|
-
if (dataTable.length > 0) {
|
|
280
|
-
setCampaignApproval(flattenData(dataTable));
|
|
281
|
-
}
|
|
282
|
-
}, [dataTable]);
|
|
65
|
+
}, [campaignApprovalTable]);
|
|
283
66
|
return ((0, jsx_runtime_1.jsxs)(material_1.TableContainer, { children: [(0, jsx_runtime_1.jsx)(material_1.Button, { variant: "outlined", color: "primary", disabled: !rowSelected.length, sx: {
|
|
284
|
-
margin: '1rem'
|
|
67
|
+
margin: '1rem',
|
|
285
68
|
}, children: t('Campaign.Approval.SendEmail') }), (0, jsx_runtime_1.jsxs)(material_1.Table, { sx: {
|
|
286
69
|
boxShadow: 'none',
|
|
287
70
|
'.MuiOutlinedInput-notchedOutline': {
|
|
288
71
|
border: 'none !important',
|
|
289
72
|
},
|
|
290
73
|
}, children: [(0, jsx_runtime_1.jsx)(material_1.TableHead, { children: (0, jsx_runtime_1.jsxs)(material_1.TableRow, { style: { height: 57 }, children: [(0, jsx_runtime_1.jsx)(material_1.TableCell, { style: { width: 60, padding: '0 0 0 4px' }, children: (0, jsx_runtime_1.jsx)(material_1.Checkbox, { indeterminate: rowSelected.length > 0 &&
|
|
291
|
-
rowSelected.length <
|
|
292
|
-
|
|
74
|
+
rowSelected.length <
|
|
75
|
+
campaignApprovalTable.length, checked: rowSelected.length > 0 &&
|
|
76
|
+
rowSelected.length ===
|
|
77
|
+
campaignApprovalTable.length, onChange: handleSelectAll, inputProps: { 'aria-label': 'select all ad' }, color: "primary" }) }), (0, jsx_runtime_1.jsx)(material_1.TableCell, { children: t('Campaign.Approval.Domain') }), (0, jsx_runtime_1.jsx)(material_1.TableCell, { style: { maxWidth: 400 }, children: t('Campaign.Approval.LinkPreview') }), (0, jsx_runtime_1.jsx)(material_1.TableCell, { children: t('Campaign.Approval.SubCampaign') }), (0, jsx_runtime_1.jsx)(material_1.TableCell, { children: t('Campaign.Approval.Advertisement') }), (0, jsx_runtime_1.jsx)(material_1.TableCell, { children: t('Campaign.Approval.Status') }), (0, jsx_runtime_1.jsx)(material_1.TableCell, { children: t('Campaign.Approval.Note') })] }) }), (0, jsx_runtime_1.jsx)(material_1.TableBody, { children: campaignApprovalTable.map(function (row) {
|
|
293
78
|
return row.detail.map(function (link, linkIndex) {
|
|
294
79
|
return link.campaign.map(function (sub, subIndex) { return ((0, jsx_runtime_1.jsx)(RowTable_1.default, { row: row, link: link, sub: sub, linkIndex: linkIndex, subIndex: subIndex, rowSelected: rowSelected, handleRowSelect: handleRowSelect, updateRow: updateRow }, "".concat(row.id, "-").concat(linkIndex, "-").concat(subIndex))); });
|
|
295
80
|
});
|
|
@@ -62,6 +62,7 @@ var TabStatistic_1 = __importDefault(require("./TabStatistic"));
|
|
|
62
62
|
var Enum_2 = require("../../../ACM-AXN/Common/Enum");
|
|
63
63
|
var Context_1 = require("../../../Context");
|
|
64
64
|
var TabApprove_1 = __importDefault(require("./TabApprove"));
|
|
65
|
+
var RunInBackground_1 = __importDefault(require("./TabApprove/RunInBackground"));
|
|
65
66
|
var CreateOrEdit = function (props) {
|
|
66
67
|
var _a;
|
|
67
68
|
var _b = (0, Router_1.useParams)(), campaignId = _b.campaignId, tabName = _b.tabName;
|
|
@@ -320,28 +321,28 @@ var CreateOrEdit = function (props) {
|
|
|
320
321
|
flexDirection: 'column',
|
|
321
322
|
flexGrow: 1,
|
|
322
323
|
padding: function (theme) { return theme.spacing(3); },
|
|
323
|
-
}, children: loading ? ((0, jsx_runtime_1.jsx)(AWING_1.CircularProgress, {})) : ((0, jsx_runtime_1.
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
324
|
+
}, children: loading ? ((0, jsx_runtime_1.jsx)(AWING_1.CircularProgress, {})) : ((0, jsx_runtime_1.jsxs)(material_1.Grid, { item: true, component: material_1.Paper, sx: { width: '100%', padding: 0 }, children: [(0, jsx_runtime_1.jsxs)(lab_1.TabContext, { value: value, children: [(0, jsx_runtime_1.jsx)(material_1.Box, { sx: { borderBottom: 1, borderColor: 'divider' }, children: (0, jsx_runtime_1.jsx)(lab_1.TabList, { variant: "scrollable", onChange: handleChangeTab, "aria-label": "lab API tabs example", children: tabsList.map(function (tab, idx) { return ((0, jsx_runtime_1.jsx)(material_1.Tab, { sx: { minWidth: '160px' }, value: String(idx), label: (0, jsx_runtime_1.jsx)(TabLabel_1.default, { content: (0, jsx_runtime_1.jsx)("div", { style: {
|
|
325
|
+
fontWeight: 600,
|
|
326
|
+
fontSize: '0.875rem',
|
|
327
|
+
}, children: tab.label }), error: (tab === null || tab === void 0 ? void 0 : tab.valid)
|
|
328
|
+
? !tabValid[tab === null || tab === void 0 ? void 0 : tab.valid]
|
|
329
|
+
: undefined, errContent: (0, jsx_runtime_1.jsx)("span", { style: {
|
|
330
|
+
marginLeft: '-5px',
|
|
331
|
+
}, children: "*" }) }) }, idx)); }) }) }), campaignData.campaignWizard && !editModeWizard &&
|
|
332
|
+
(props === null || props === void 0 ? void 0 : props.quickWizard) ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [props === null || props === void 0 ? void 0 : props.quickWizard({
|
|
333
|
+
ref: childRefWizard,
|
|
334
|
+
onSubmitWizard: handleSubmit,
|
|
335
|
+
handleValidWizad: setValidWizad,
|
|
336
|
+
handleEditMode: setEditModeWizard,
|
|
337
|
+
sxEdit: {
|
|
338
|
+
display: value === '0'
|
|
339
|
+
? 'block'
|
|
340
|
+
: 'none',
|
|
341
|
+
},
|
|
342
|
+
type: props.type,
|
|
343
|
+
}), tabsList.map(function (tab, idx) {
|
|
344
|
+
return idx !== 0 && ((0, jsx_runtime_1.jsx)(lab_1.TabPanel, { sx: { padding: '0' }, value: String(idx), children: tab.component }, idx));
|
|
345
|
+
})] })) : ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: tabsList.map(function (tab, idx) { return ((0, jsx_runtime_1.jsx)(lab_1.TabPanel, { sx: { padding: '0' }, value: String(idx), children: tab.component }, idx)); }) }))] }), (0, jsx_runtime_1.jsx)(RunInBackground_1.default, {})] })) }) }));
|
|
345
346
|
};
|
|
346
347
|
// eslint-disable-next-line import/no-anonymous-default-export
|
|
347
348
|
exports.default = (0, Wrapper_1.default)(CreateOrEdit, { component: recoil_1.RecoilRoot });
|
|
@@ -216,10 +216,12 @@ export type CampaignApproval = {
|
|
|
216
216
|
id?: number;
|
|
217
217
|
campaignId?: string;
|
|
218
218
|
domainId?: string;
|
|
219
|
-
|
|
220
|
-
|
|
219
|
+
campaignGroupId?: number;
|
|
220
|
+
campaignAdId?: number;
|
|
221
221
|
status: number;
|
|
222
222
|
description: string;
|
|
223
|
+
loginId?: string;
|
|
224
|
+
welcomeId?: string;
|
|
223
225
|
};
|
|
224
226
|
export type DateRange = {
|
|
225
227
|
startDate: Date;
|
|
@@ -288,4 +290,30 @@ export interface CampaignFeatureProps {
|
|
|
288
290
|
isAxn?: boolean;
|
|
289
291
|
quickWizard?: (p?: any) => JSX.Element;
|
|
290
292
|
}
|
|
293
|
+
interface ICampaignApprovalItemSubRow {
|
|
294
|
+
id?: number;
|
|
295
|
+
name?: string;
|
|
296
|
+
}
|
|
297
|
+
export interface ICampaignApprovalSubRow {
|
|
298
|
+
subCampaigns: ICampaignApprovalItemSubRow[];
|
|
299
|
+
ads: ICampaignApprovalItemSubRow[];
|
|
300
|
+
}
|
|
301
|
+
export interface ICampaignApprovalTableRow {
|
|
302
|
+
id?: string;
|
|
303
|
+
status: number;
|
|
304
|
+
linkPreview: string;
|
|
305
|
+
subCampaigns?: ICampaignApprovalItemSubRow[];
|
|
306
|
+
loginId?: string;
|
|
307
|
+
welcomeId?: string;
|
|
308
|
+
campaign: ICampaignApprovalSubRow[];
|
|
309
|
+
description: string;
|
|
310
|
+
}
|
|
311
|
+
export interface ICampaignApprovalTable {
|
|
312
|
+
id: string;
|
|
313
|
+
domain: {
|
|
314
|
+
domainName?: string;
|
|
315
|
+
domainId?: string;
|
|
316
|
+
};
|
|
317
|
+
detail: ICampaignApprovalTableRow[];
|
|
318
|
+
}
|
|
291
319
|
export {};
|