awing-library 2.1.227-dev → 2.1.228-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.
@@ -30,8 +30,14 @@ var react_i18next_1 = require("react-i18next");
30
30
  var recoil_1 = require("recoil");
31
31
  var Recoils_1 = require("../Recoils");
32
32
  var RowTable_1 = __importDefault(require("./RowTable"));
33
+ var Router_1 = require("../../../../AWING/Router");
34
+ var Hooks_1 = __importDefault(require("../../../../ACM-AXN/Campaign/Hooks"));
35
+ var Context_1 = require("../../../../Context");
33
36
  function TabApprove() {
37
+ var campaignId = (0, Router_1.useParams)().campaignId;
34
38
  var t = (0, react_i18next_1.useTranslation)().t;
39
+ var service = (0, Hooks_1.default)().service;
40
+ var snackbar = (0, Context_1.useAwing)().appHelper.snackbar;
35
41
  var setConfirmExit = (0, recoil_1.useSetRecoilState)(Recoils_1.confirmExitState);
36
42
  var _a = (0, react_1.useState)([]), rowSelected = _a[0], setRowSelected = _a[1];
37
43
  var _b = (0, recoil_1.useRecoilState)(Recoils_1.campaignApprovalTableState), campaignApprovalTable = _b[0], setCampaignApprovalTable = _b[1];
@@ -56,6 +62,31 @@ function TabApprove() {
56
62
  });
57
63
  setConfirmExit(true);
58
64
  }, [campaignApprovalTable]);
65
+ var flattenData = (0, react_1.useCallback)(function (data) {
66
+ var flattened = [];
67
+ var index = 0;
68
+ data.forEach(function (item) {
69
+ item.detail.forEach(function (detail) {
70
+ detail.campaign.forEach(function (campaign) {
71
+ campaign.ads.forEach(function (ad) {
72
+ var _a;
73
+ flattened.push({
74
+ id: index++,
75
+ campaignId: campaignId,
76
+ domainId: item.domain.domainId,
77
+ status: detail.status,
78
+ loginId: detail.loginId,
79
+ welcomeId: detail.welcomeId,
80
+ description: detail.description,
81
+ campaignGroupId: (_a = campaign.subCampaigns[0]) === null || _a === void 0 ? void 0 : _a.id,
82
+ campaignAdId: ad === null || ad === void 0 ? void 0 : ad.id,
83
+ });
84
+ });
85
+ });
86
+ });
87
+ });
88
+ return flattened;
89
+ }, []);
59
90
  var handleSelectAll = (0, react_1.useCallback)(function () {
60
91
  setRowSelected(function (pre) {
61
92
  return pre.length < campaignApprovalTable.length
@@ -63,9 +94,18 @@ function TabApprove() {
63
94
  : [];
64
95
  });
65
96
  }, [campaignApprovalTable]);
97
+ var handleSendMail = (0, react_1.useCallback)(function () {
98
+ var data = campaignApprovalTable.filter(function (item) {
99
+ return rowSelected.includes(item.id);
100
+ });
101
+ service.campaignsManualSendMail && service.campaignsManualSendMail(campaignId, flattenData(data)).then(function () {
102
+ setRowSelected([]);
103
+ snackbar('success');
104
+ });
105
+ }, [campaignApprovalTable, rowSelected]);
66
106
  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: {
67
107
  margin: '1rem',
68
- }, children: t('Campaign.Approval.SendEmail') }), (0, jsx_runtime_1.jsxs)(material_1.Table, { sx: {
108
+ }, onClick: handleSendMail, children: t('Campaign.Approval.SendEmail') }), (0, jsx_runtime_1.jsxs)(material_1.Table, { sx: {
69
109
  boxShadow: 'none',
70
110
  '.MuiOutlinedInput-notchedOutline': {
71
111
  border: 'none !important',
@@ -280,6 +280,7 @@ interface CampaignService extends PrmissionService {
280
280
  deviceInfoGetAllRuleOsVersions: () => Promise<RuleOsVersion[]>;
281
281
  deviceInfoGetAllRuleDevices: () => Promise<RuleDevice[]>;
282
282
  attributesGetByObjectTypeCode?: (objectTypeCode: string) => Promise<Attribute[]>;
283
+ campaignsManualSendMail?: (campaignId: string, body: CampaignApproval[]) => Promise<void>;
283
284
  }
284
285
  export interface CampaignFeatureProps {
285
286
  service: CampaignService & PageService & CampaignAnalyticService;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "awing-library",
3
- "version": "2.1.227-dev",
3
+ "version": "2.1.228-dev",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",