awing-library 2.1.190-dev → 2.1.191-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.
@@ -1,3 +1,7 @@
1
1
  import React from 'react';
2
- declare const _default: React.FC<unknown>;
2
+ interface CreateOrEditProps {
3
+ quickWizard?: (p?: any) => JSX.Element;
4
+ type?: string;
5
+ }
6
+ declare const _default: React.FC<CreateOrEditProps>;
3
7
  export default _default;
@@ -21,6 +21,15 @@ var __rest = (this && this.__rest) || function (s, e) {
21
21
  }
22
22
  return t;
23
23
  };
24
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
25
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
26
+ if (ar || !(i in from)) {
27
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
28
+ ar[i] = from[i];
29
+ }
30
+ }
31
+ return to.concat(ar || Array.prototype.slice.call(from));
32
+ };
24
33
  var __importDefault = (this && this.__importDefault) || function (mod) {
25
34
  return (mod && mod.__esModule) ? mod : { "default": mod };
26
35
  };
@@ -58,7 +67,7 @@ var route = [
58
67
  Constant_1.Constants.CAMPAIGN_CONNECT,
59
68
  Constant_1.Constants.CAMPAIGN_PERMISSION,
60
69
  ];
61
- var CreateOrEdit = function () {
70
+ var CreateOrEdit = function (props) {
62
71
  var _a;
63
72
  var _b = (0, Router_1.useParams)(), campaignId = _b.campaignId, tabName = _b.tabName;
64
73
  var location = (0, Router_1.useLocation)();
@@ -74,13 +83,15 @@ var CreateOrEdit = function () {
74
83
  var readyForSubmit = (0, recoil_1.useRecoilValue)(Recoils_1.readyForSubmitState);
75
84
  var setCreate = (0, recoil_1.useSetRecoilState)(Recoils_1.isCreateState);
76
85
  var _f = (0, react_1.useState)(), fullPlaces = _f[0], setFullPlaces = _f[1];
86
+ var _g = (0, react_1.useState)(false), validWizad = _g[0], setValidWizad = _g[1];
87
+ var childRefWizard = (0, react_1.useRef)(null);
77
88
  var tabValid = {
78
89
  tabInfomationValid: (0, recoil_1.useRecoilValue)(Recoils_1.tabInfomationValidState),
79
90
  tabSubCampaignValid: (0, recoil_1.useRecoilValue)(Recoils_1.tabSubCampaignValidState),
80
91
  tabPartnerValid: (0, recoil_1.useRecoilValue)(Recoils_1.tabPartnerValidState),
81
92
  };
82
- var _g = (0, react_1.useState)('0'), value = _g[0], setValue = _g[1];
83
- var _h = (0, react_1.useState)(true), loading = _h[0], setLoading = _h[1];
93
+ var _h = (0, react_1.useState)('0'), value = _h[0], setValue = _h[1];
94
+ var _j = (0, react_1.useState)(true), loading = _j[0], setLoading = _j[1];
84
95
  var componentStatus = (0, react_1.useMemo)(function () {
85
96
  return location.pathname.includes(Constant_1.Constants.CAMPAIGN_DETAIL) &&
86
97
  !!campaignId
@@ -125,20 +136,35 @@ var CreateOrEdit = function () {
125
136
  setValue(String(route.indexOf(tabName)));
126
137
  }
127
138
  }, [tabName]);
139
+ var getTabs = function () {
140
+ return !(campaignData.campaignWizard && (props === null || props === void 0 ? void 0 : props.quickWizard))
141
+ ? [
142
+ {
143
+ label: t('Campaign.Info'),
144
+ isShow: true,
145
+ valid: 'tabInfomationValid',
146
+ component: (0, jsx_runtime_1.jsx)(TabInfomation_1.default, {}),
147
+ },
148
+ {
149
+ label: t('Campaign.SubCampaign'),
150
+ isShow: true,
151
+ valid: 'tabSubCampaignValid',
152
+ component: (0, jsx_runtime_1.jsx)(TabSubCampaign_1.default, {}),
153
+ },
154
+ ]
155
+ : [
156
+ {
157
+ label: t('Campaign.Wizard'),
158
+ isShow: true,
159
+ component: props === null || props === void 0 ? void 0 : props.quickWizard({
160
+ ref: childRefWizard,
161
+ onSubmitWizard: handleSubmit,
162
+ }),
163
+ },
164
+ ];
165
+ };
128
166
  var tabsList = (0, react_1.useMemo)(function () {
129
- return [
130
- {
131
- label: t('Campaign.Info'),
132
- isShow: true,
133
- valid: 'tabInfomationValid',
134
- component: (0, jsx_runtime_1.jsx)(TabInfomation_1.default, {}),
135
- },
136
- {
137
- label: t('Campaign.SubCampaign'),
138
- isShow: true,
139
- valid: 'tabSubCampaignValid',
140
- component: (0, jsx_runtime_1.jsx)(TabSubCampaign_1.default, {}),
141
- },
167
+ return __spreadArray(__spreadArray([], getTabs(), true), [
142
168
  {
143
169
  label: t('Campaign.Statistic'),
144
170
  isShow: componentStatus === Constant_1.Constants.CAMPAIGN_DETAIL,
@@ -155,7 +181,7 @@ var CreateOrEdit = function () {
155
181
  isShow: componentStatus === Constant_1.Constants.CAMPAIGN_DETAIL,
156
182
  component: (0, jsx_runtime_1.jsx)(TabPermission_1.default, {}),
157
183
  },
158
- ].filter(function (tab) { return tab.isShow; });
184
+ ], false).filter(function (tab) { return tab.isShow; });
159
185
  },
160
186
  // eslint-disable-next-line react-hooks/exhaustive-deps
161
187
  [t, componentStatus, Constant_1.Constants, campaignData]);
@@ -221,25 +247,47 @@ var CreateOrEdit = function () {
221
247
  };
222
248
  var handleSubmit = function () {
223
249
  var _a;
224
- if (!(0, Utils_1.adsClassCValid)(campaignData.campaignGroups
225
- .filter(function (x) {
226
- return (0, Utils_1.checkPriority)(x.campaignGroup.priority, Enum_1.CampaignPriority.ClassC);
227
- })
228
- .flatMap(function (x) { return x.ads; }))) {
229
- return Promise.reject(t('Campaign.CClassDuplicatePlace'));
250
+ if (campaignData.campaignWizard && (props === null || props === void 0 ? void 0 : props.quickWizard)) {
251
+ if (childRefWizard.current) {
252
+ childRefWizard.current.onSubmit({
253
+ campaignPartner: campaignData.campaignPartner,
254
+ });
255
+ }
230
256
  }
231
- var dataSubmit = __assign(__assign({}, campaignData), { campaignAttributes: campaignData.campaignAttributes.filter(Boolean) });
232
- if (!((_a = dataSubmit.campaignPartner) === null || _a === void 0 ? void 0 : _a.isSendApi)) {
233
- delete dataSubmit.campaignPartner;
257
+ else {
258
+ if (!(0, Utils_1.adsClassCValid)(campaignData.campaignGroups
259
+ .filter(function (x) {
260
+ return (0, Utils_1.checkPriority)(x.campaignGroup.priority, Enum_1.CampaignPriority.ClassC);
261
+ })
262
+ .flatMap(function (x) { return x.ads; }))) {
263
+ return Promise.reject(t('Campaign.CClassDuplicatePlace'));
264
+ }
265
+ var dataSubmit = __assign(__assign({}, campaignData), { campaignAttributes: campaignData.campaignAttributes.filter(Boolean) });
266
+ if (!((_a = dataSubmit.campaignPartner) === null || _a === void 0 ? void 0 : _a.isSendApi)) {
267
+ delete dataSubmit.campaignPartner;
268
+ }
269
+ if (componentStatus === Constant_1.Constants.CAMPAIGN_DETAIL) {
270
+ return service.campaignsPut(campaignId, dataSubmit);
271
+ }
272
+ else {
273
+ return service.campaignsPost(dataSubmit);
274
+ }
234
275
  }
235
- if (componentStatus === Constant_1.Constants.CAMPAIGN_DETAIL) {
236
- return service.campaignsPut(campaignId, dataSubmit);
276
+ };
277
+ var handleDisableButtonSubmit = function () {
278
+ if (campaignData.campaignWizard && (props === null || props === void 0 ? void 0 : props.quickWizard)) {
279
+ return validWizad;
237
280
  }
238
- else {
239
- return service.campaignsPost(dataSubmit);
281
+ return !readyForSubmit || !confirmExit;
282
+ };
283
+ var handleClose = function () {
284
+ if (campaignData.campaignWizard && (props === null || props === void 0 ? void 0 : props.quickWizard)) {
285
+ if (childRefWizard.current) {
286
+ childRefWizard.current.resetData();
287
+ }
240
288
  }
241
289
  };
242
- return ((0, jsx_runtime_1.jsx)(ClassicDrawer_1.default, { title: "".concat(t(['Campaign', campaignId ? 'TitleDetail' : 'Create'].join('.'))).concat(campaignId ? ": ".concat((_a = campaignData === null || campaignData === void 0 ? void 0 : campaignData.campaign) === null || _a === void 0 ? void 0 : _a.name) : '', "\n "), onSubmit: handleSubmit, disableButtonSubmit: !readyForSubmit || !confirmExit, confirmExit: confirmExit, childrenWrapperStyle: { padding: 0 }, children: (0, jsx_runtime_1.jsx)(material_1.Grid, { container: true, sx: {
290
+ return ((0, jsx_runtime_1.jsx)(ClassicDrawer_1.default, { title: "".concat(t(['Campaign', campaignId ? 'TitleDetail' : 'Create'].join('.'))).concat(campaignId ? ": ".concat((_a = campaignData === null || campaignData === void 0 ? void 0 : campaignData.campaign) === null || _a === void 0 ? void 0 : _a.name) : '', "\n "), onSubmit: handleSubmit, disableButtonSubmit: handleDisableButtonSubmit(), confirmExit: confirmExit, childrenWrapperStyle: { padding: 0 }, onClose: handleClose, children: (0, jsx_runtime_1.jsx)(material_1.Grid, { container: true, sx: {
243
291
  display: 'flex',
244
292
  flexDirection: 'column',
245
293
  flexGrow: 1,
@@ -251,7 +299,20 @@ var CreateOrEdit = function () {
251
299
  ? !tabValid[tab === null || tab === void 0 ? void 0 : tab.valid]
252
300
  : undefined, errContent: (0, jsx_runtime_1.jsx)("span", { style: {
253
301
  marginLeft: '-5px',
254
- }, children: "*" }) }) }, idx)); }) }) }), tabsList.map(function (tab, idx) { return ((0, jsx_runtime_1.jsx)(lab_1.TabPanel, { sx: { padding: '0' }, value: String(idx), children: tab.component }, idx)); })] }) })) }) }));
302
+ }, children: "*" }) }) }, idx)); }) }) }), campaignData.campaignWizard &&
303
+ (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({
304
+ ref: childRefWizard,
305
+ onSubmitWizard: handleSubmit,
306
+ handleValidWizad: setValidWizad,
307
+ sxEdit: {
308
+ display: value === '0'
309
+ ? 'block'
310
+ : 'none',
311
+ },
312
+ type: props.type,
313
+ }), tabsList.map(function (tab, idx) {
314
+ return idx !== 0 && ((0, jsx_runtime_1.jsx)(lab_1.TabPanel, { sx: { padding: '0' }, value: String(idx), children: tab.component }, idx));
315
+ })] })) : ((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)); }) }))] }) })) }) }));
255
316
  };
256
317
  // eslint-disable-next-line import/no-anonymous-default-export
257
318
  exports.default = (0, Wrapper_1.default)(CreateOrEdit, { component: recoil_1.RecoilRoot });
@@ -43,6 +43,12 @@ export type CampaignModel = {
43
43
  campaignGroups: CampaignGroupModel[];
44
44
  campaignAttributes: CampaignAttribute[];
45
45
  campaignPartner?: CampaignPartner;
46
+ campaignWizard?: {
47
+ id?: number;
48
+ campaignId?: string;
49
+ wizardGroupId?: number;
50
+ wizardId?: string;
51
+ };
46
52
  };
47
53
  export type Campaign = {
48
54
  id: string;
@@ -272,5 +278,6 @@ export interface CampaignFeatureProps {
272
278
  domainId: string;
273
279
  configs: any;
274
280
  isAxn?: boolean;
281
+ quickWizard?: (p?: any) => JSX.Element;
275
282
  }
276
283
  export {};
@@ -52,11 +52,11 @@ var Campaign = function (props) {
52
52
  },
53
53
  {
54
54
  param: Constant_1.Constants.CAMPAIGN_DETAIL + '/:campaignId/:tabName/*',
55
- element: (0, jsx_runtime_1.jsx)(CreateOrEdit_1.default, {}),
55
+ element: (0, jsx_runtime_1.jsx)(CreateOrEdit_1.default, { quickWizard: props.quickWizard }),
56
56
  },
57
57
  {
58
58
  param: Constant_1.Constants.CAMPAIGN_CLONE + '/:campaignId/:tabName/*',
59
- element: (0, jsx_runtime_1.jsx)(CreateOrEdit_1.default, {}),
59
+ element: ((0, jsx_runtime_1.jsx)(CreateOrEdit_1.default, { quickWizard: props.quickWizard, type: Constant_1.Constants.CAMPAIGN_CLONE })),
60
60
  },
61
61
  ];
62
62
  return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Container_1.default, {}), (0, jsx_runtime_1.jsx)(Router_1.Routes, { children: paths.map(function (p) { return ((0, jsx_runtime_1.jsx)(Router_1.Route, { path: p.param, element: p.element }, p.param)); }) })] }));
@@ -512,7 +512,8 @@
512
512
  "View": "Impression",
513
513
  "Authentication": "Engagement / Spot",
514
514
  "Click": "Click"
515
- }
515
+ },
516
+ "Wizard": "Wizard"
516
517
  },
517
518
  "DirectoryManagement": {
518
519
  "DirectoryName": "Directory Name",
@@ -496,7 +496,8 @@
496
496
  "View": "Impression",
497
497
  "Authentication": "Engagement / Spot",
498
498
  "Click": "Click"
499
- }
499
+ },
500
+ "Wizard": "Wizard"
500
501
  },
501
502
  "TemplateManagement": {
502
503
  "Create": "Tạo mới template",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "awing-library",
3
- "version": "2.1.190-dev",
3
+ "version": "2.1.191-dev",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",