awing-library 2.1.189-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.
- package/lib/ACM-AXN/Campaign/CreateOrEdit/index.d.ts +5 -1
- package/lib/ACM-AXN/Campaign/CreateOrEdit/index.js +93 -32
- package/lib/ACM-AXN/Campaign/Types.d.ts +7 -0
- package/lib/ACM-AXN/Campaign/index.js +2 -2
- package/lib/AWING/GoogleMap/GGMap.js +38 -12
- package/lib/translate/en/translation.json +2 -1
- package/lib/translate/vi/translation.json +2 -1
- package/package.json +1 -1
|
@@ -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
|
|
83
|
-
var
|
|
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 (
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
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
|
-
|
|
232
|
-
|
|
233
|
-
|
|
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
|
-
|
|
236
|
-
|
|
276
|
+
};
|
|
277
|
+
var handleDisableButtonSubmit = function () {
|
|
278
|
+
if (campaignData.campaignWizard && (props === null || props === void 0 ? void 0 : props.quickWizard)) {
|
|
279
|
+
return validWizad;
|
|
237
280
|
}
|
|
238
|
-
|
|
239
|
-
|
|
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:
|
|
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)); }) }) }),
|
|
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)); }) })] }));
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
3
|
+
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
4
|
+
return cooked;
|
|
5
|
+
};
|
|
2
6
|
var __assign = (this && this.__assign) || function () {
|
|
3
7
|
__assign = Object.assign || function(t) {
|
|
4
8
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
@@ -25,6 +29,7 @@ var mapContainerStyle = {
|
|
|
25
29
|
height: '320px',
|
|
26
30
|
width: '100%',
|
|
27
31
|
};
|
|
32
|
+
var myEffectExit = (0, material_1.keyframes)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n 0% {\n transform: scale(1);\n border: 0px solid #fff;\n opacity: 1;\n }\n 25% {\n transform: scale(1.1);\n border: 10px solid #1a78fc;\n opacity: 0.8;\n }\n 50% {\n transform: scale(1.12);\n\tborder: 8px solid #1a78fc;\n opacity: 0.5;\n }\n 75% {\n transform: scale(1.14);\n\tborder: 6px solid #1a78fc;\n opacity: 0.3;\n }\n 100% {\n transform: scale(1.16);\n\tborder: 4px solid #1a78fc;\n opacity: 0.2;\n }\n"], ["\n 0% {\n transform: scale(1);\n border: 0px solid #fff;\n opacity: 1;\n }\n 25% {\n transform: scale(1.1);\n border: 10px solid #1a78fc;\n opacity: 0.8;\n }\n 50% {\n transform: scale(1.12);\n\tborder: 8px solid #1a78fc;\n opacity: 0.5;\n }\n 75% {\n transform: scale(1.14);\n\tborder: 6px solid #1a78fc;\n opacity: 0.3;\n }\n 100% {\n transform: scale(1.16);\n\tborder: 4px solid #1a78fc;\n opacity: 0.2;\n }\n"])));
|
|
28
33
|
var libraries = ['places'];
|
|
29
34
|
var stylesDefault = {
|
|
30
35
|
position: 'relative',
|
|
@@ -44,6 +49,22 @@ var GGMap = function (_a) {
|
|
|
44
49
|
var onLoad = function (autocomplete) {
|
|
45
50
|
autocompleteRef.current = autocomplete;
|
|
46
51
|
};
|
|
52
|
+
var markerConvert = (0, react_1.useMemo)(function () {
|
|
53
|
+
var _a;
|
|
54
|
+
var coordMap = (_a = markerPositions === null || markerPositions === void 0 ? void 0 : markerPositions.reduce(function (acc, _a) {
|
|
55
|
+
var longitude = _a.longitude, latitude = _a.latitude;
|
|
56
|
+
var key = "".concat(longitude, ",").concat(latitude);
|
|
57
|
+
if (acc[key]) {
|
|
58
|
+
acc[key].count += 1;
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
acc[key] = { longitude: longitude, latitude: latitude, count: 1 };
|
|
62
|
+
}
|
|
63
|
+
return acc;
|
|
64
|
+
}, {})) !== null && _a !== void 0 ? _a : {};
|
|
65
|
+
// Convert the object to an array
|
|
66
|
+
return Object.values(coordMap);
|
|
67
|
+
}, [markerPosition]);
|
|
47
68
|
var onPlaceChanged = function () {
|
|
48
69
|
var _a, _b, _c, _d;
|
|
49
70
|
if (autocompleteRef.current !== null) {
|
|
@@ -116,6 +137,9 @@ var GGMap = function (_a) {
|
|
|
116
137
|
lng: (_b = Number(markerPosition === null || markerPosition === void 0 ? void 0 : markerPosition.longitude)) !== null && _b !== void 0 ? _b : 0,
|
|
117
138
|
};
|
|
118
139
|
}, [markerPosition]);
|
|
140
|
+
var calculateRadius = function (currentZoom) {
|
|
141
|
+
return 100000 * Math.pow(2, 5 - currentZoom);
|
|
142
|
+
};
|
|
119
143
|
return ((0, jsx_runtime_1.jsx)(material_1.Box, { sx: sxMap ? sxMap : stylesDefault, ref: boxRef, children: (0, jsx_runtime_1.jsxs)(api_1.LoadScript, { googleMapsApiKey: apiKey || '', libraries: libraries, children: [!isDisplayAutoComplete &&
|
|
120
144
|
((0, jsx_runtime_1.jsx)(api_1.Autocomplete, { onPlaceChanged: onPlaceChanged, onLoad: onLoad, children: (0, jsx_runtime_1.jsx)("input", { type: "text", placeholder: t('Common.PlaceHolderLocation'), onFocus: function () {
|
|
121
145
|
var _a;
|
|
@@ -139,7 +163,10 @@ var GGMap = function (_a) {
|
|
|
139
163
|
margin: '10px 0',
|
|
140
164
|
zIndex: 99,
|
|
141
165
|
top: '50px',
|
|
142
|
-
} }) })), (0, jsx_runtime_1.jsx)(api_1.GoogleMap, __assign({ id: "map", mapContainerStyle: sizeMap !== null && sizeMap !== void 0 ? sizeMap : mapContainerStyle, zoom: zoom,
|
|
166
|
+
} }) })), (0, jsx_runtime_1.jsx)(api_1.GoogleMap, __assign({ id: "map", mapContainerStyle: sizeMap !== null && sizeMap !== void 0 ? sizeMap : mapContainerStyle, zoom: zoom, onZoomChanged: function () {
|
|
167
|
+
var _a;
|
|
168
|
+
setZoom((_a = map === null || map === void 0 ? void 0 : map.getZoom()) !== null && _a !== void 0 ? _a : 0);
|
|
169
|
+
}, center: marker, onLoad: onLoadMap, onClick: onMapClick }, isTypeTracking && {
|
|
143
170
|
options: {
|
|
144
171
|
disableDefaultUI: true,
|
|
145
172
|
styles: utils_1.mapStyles,
|
|
@@ -157,17 +184,16 @@ var GGMap = function (_a) {
|
|
|
157
184
|
strokeOpacity: 1,
|
|
158
185
|
strokeWeight: 2,
|
|
159
186
|
} })] })
|
|
160
|
-
: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children:
|
|
161
|
-
var _a, _b;
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
// (1 / 7);
|
|
170
|
-
return (0, jsx_runtime_1.jsx)(api_1.Marker, { position: { lat: (_a = coordinates.latitude) !== null && _a !== void 0 ? _a : 0, lng: (_b = coordinates.longitude) !== null && _b !== void 0 ? _b : 0 } }, index);
|
|
187
|
+
: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: markerConvert === null || markerConvert === void 0 ? void 0 : markerConvert.map(function (coordinates, index, positions) {
|
|
188
|
+
var _a, _b, _c;
|
|
189
|
+
return (0, jsx_runtime_1.jsx)(api_1.CircleF, { center: { lat: (_a = coordinates.latitude) !== null && _a !== void 0 ? _a : 0, lng: (_b = coordinates.longitude) !== null && _b !== void 0 ? _b : 0 }, radius: calculateRadius(zoom * (((_c = coordinates === null || coordinates === void 0 ? void 0 : coordinates.count) !== null && _c !== void 0 ? _c : 0))), options: {
|
|
190
|
+
strokeColor: '#4285F4',
|
|
191
|
+
strokeOpacity: 0.8,
|
|
192
|
+
strokeWeight: 2,
|
|
193
|
+
fillColor: "#4285F4",
|
|
194
|
+
fillOpacity: 0.35,
|
|
195
|
+
} }, index);
|
|
171
196
|
}) }) }))] }) }));
|
|
172
197
|
};
|
|
173
198
|
exports.default = GGMap;
|
|
199
|
+
var templateObject_1;
|