awing-library 2.1.218-dev → 2.1.219-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,7 +1,8 @@
1
1
  import { IDetail } from '.';
2
2
  interface RowTableProps {
3
3
  row: IDetail;
4
- updateRow?: any;
4
+ updateRow: (updatedRow: any, id: string) => void;
5
+ id: string;
5
6
  }
6
7
  export declare function RowTable(props: RowTableProps): import("react/jsx-runtime").JSX.Element;
7
8
  export {};
@@ -1,61 +1,68 @@
1
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
+ };
2
13
  Object.defineProperty(exports, "__esModule", { value: true });
3
14
  exports.RowTable = void 0;
4
15
  var jsx_runtime_1 = require("react/jsx-runtime");
5
16
  var material_1 = require("@mui/material");
6
17
  var react_1 = require("react");
7
- function RowTable(props) {
8
- var _a;
9
- var row = props.row;
10
- var optionsState = [
11
- {
12
- id: '1',
13
- name: 'Chờ duyệt',
14
- },
15
- {
16
- id: '2',
17
- name: 'Duyệt',
18
- },
19
- {
20
- id: '3',
21
- name: 'Hủy',
18
+ var optionsStatus = [
19
+ { value: 0, label: 'Chờ duyệt' },
20
+ { value: 1, label: 'Duyệt' },
21
+ { value: 2, label: 'Hủy' },
22
+ ];
23
+ var ITEM_HEIGHT = 48;
24
+ var ITEM_PADDING_TOP = 8;
25
+ var MenuProps = {
26
+ PaperProps: {
27
+ style: {
28
+ maxHeight: ITEM_HEIGHT * 4.5 + ITEM_PADDING_TOP,
29
+ width: 250,
22
30
  },
23
- ];
24
- var _b = (0, react_1.useState)([
25
- optionsState[0].name,
26
- ]), personName = _b[0], setPersonName = _b[1];
27
- var _c = (0, react_1.useState)((_a = row === null || row === void 0 ? void 0 : row.ghichu) !== null && _a !== void 0 ? _a : ''), valueInput = _c[0], setValueInput = _c[1];
28
- var handleChange = function (event) {
29
- var value = event.target.value;
30
- setPersonName(typeof value === 'string' ? value.split(',') : value);
31
- };
32
- var ITEM_HEIGHT = 48;
33
- var ITEM_PADDING_TOP = 8;
34
- var MenuProps = {
35
- PaperProps: {
36
- style: {
37
- maxHeight: ITEM_HEIGHT * 4.5 + ITEM_PADDING_TOP,
38
- width: 250,
39
- },
40
- },
41
- };
42
- return ((0, jsx_runtime_1.jsxs)(material_1.TableRow, { children: [(0, jsx_runtime_1.jsx)(material_1.TableCell, { style: { maxWidth: 400 }, children: (0, jsx_runtime_1.jsx)(material_1.Box, { sx: {
43
- display: '-webkit-box',
44
- WebkitLineClamp: 2,
45
- WebkitBoxOrient: 'vertical',
46
- overflow: 'hidden',
47
- textOverflow: 'ellipsis',
48
- }, children: (0, jsx_runtime_1.jsx)(material_1.Link, { href: row === null || row === void 0 ? void 0 : row.link, sx: {
49
- wordWrap: 'break-word',
50
- wordBreak: 'break-all',
51
- color: 'blue',
52
- textDecorationColor: 'unset',
53
- }, target: "_blank", children: row === null || row === void 0 ? void 0 : row.link }) }) }), (0, jsx_runtime_1.jsx)(material_1.TableCell, { children: (0, jsx_runtime_1.jsx)(material_1.Box, { sx: {
31
+ },
32
+ };
33
+ function RowTable(props) {
34
+ var _a, _b;
35
+ var row = props.row, updateRow = props.updateRow, id = props.id;
36
+ var _c = (0, react_1.useState)((_a = row === null || row === void 0 ? void 0 : row.status) !== null && _a !== void 0 ? _a : 0), selectStatus = _c[0], setSelectStatus = _c[1];
37
+ var _d = (0, react_1.useState)((_b = row === null || row === void 0 ? void 0 : row.ghichu) !== null && _b !== void 0 ? _b : ''), valueInput = _d[0], setValueInput = _d[1];
38
+ var handleStatusChange = (0, react_1.useCallback)(function (value) {
39
+ var newStatus = value;
40
+ setSelectStatus(newStatus);
41
+ updateRow(__assign(__assign({}, row), { status: newStatus }), id);
42
+ }, [row, id, updateRow]);
43
+ var handleInputChange = (0, react_1.useCallback)(function (event) {
44
+ var newValue = event.target.value;
45
+ setValueInput(newValue);
46
+ updateRow(__assign(__assign({}, row), { ghichu: newValue }), id);
47
+ }, [row, id, updateRow]);
48
+ var linkComponent = (0, react_1.useMemo)(function () { return ((0, jsx_runtime_1.jsx)(material_1.Box, { sx: {
49
+ display: '-webkit-box',
50
+ WebkitLineClamp: 2,
51
+ WebkitBoxOrient: 'vertical',
52
+ overflow: 'hidden',
53
+ textOverflow: 'ellipsis',
54
+ }, children: (0, jsx_runtime_1.jsx)(material_1.Link, { href: row.link, sx: {
55
+ wordWrap: 'break-word',
56
+ wordBreak: 'break-all',
57
+ color: 'blue',
58
+ textDecorationColor: 'unset',
59
+ }, underline: "hover", target: "_blank", children: row.link }) })); }, [row.link]);
60
+ return ((0, jsx_runtime_1.jsxs)(material_1.TableRow, { children: [(0, jsx_runtime_1.jsx)(material_1.TableCell, { style: { maxWidth: 400 }, children: linkComponent }), (0, jsx_runtime_1.jsx)(material_1.TableCell, { children: (0, jsx_runtime_1.jsx)(material_1.Box, { sx: {
54
61
  display: 'flex',
55
62
  flexWrap: 'wrap',
56
63
  gap: '8px',
57
- }, children: row.subCampaigns.map(function (subCampaign, index) { return ((0, jsx_runtime_1.jsx)(material_1.Chip, { label: subCampaign.name }, index)); }) }) }), (0, jsx_runtime_1.jsx)(material_1.TableCell, { children: (0, jsx_runtime_1.jsx)(material_1.FormControl, { sx: { m: 1, width: 300 }, children: (0, jsx_runtime_1.jsx)(material_1.Select, { value: personName, onChange: handleChange, MenuProps: MenuProps, children: optionsState.map(function (item) { return ((0, jsx_runtime_1.jsx)(material_1.MenuItem, { value: item.name, children: item.name }, item.id)); }) }) }) }), (0, jsx_runtime_1.jsx)(material_1.TableCell, { children: (0, jsx_runtime_1.jsx)(material_1.TextField, { value: valueInput, onChange: function (e) {
58
- setValueInput(e.target.value);
59
- } }) })] }));
64
+ }, children: row.subCampaigns.map(function (subCampaign, index) { return ((0, jsx_runtime_1.jsx)(material_1.Chip, { label: subCampaign.name }, index)); }) }) }), (0, jsx_runtime_1.jsx)(material_1.TableCell, { children: (0, jsx_runtime_1.jsx)(material_1.FormControl, { sx: { m: 1, width: 300 }, children: (0, jsx_runtime_1.jsx)(material_1.Select, { value: selectStatus, onChange: function (e) {
65
+ return handleStatusChange(e.target.value);
66
+ }, MenuProps: MenuProps, children: optionsStatus.map(function (item) { return ((0, jsx_runtime_1.jsx)(material_1.MenuItem, { value: item.value, children: item.label }, item.value)); }) }) }) }), (0, jsx_runtime_1.jsx)(material_1.TableCell, { children: (0, jsx_runtime_1.jsx)(material_1.TextField, { value: valueInput, onChange: handleInputChange }) })] }));
60
67
  }
61
68
  exports.RowTable = RowTable;
@@ -43,45 +43,46 @@ jest.mock('@mui/material', function () { return (__assign(__assign({}, jest.requ
43
43
  var value = _a.value, onChange = _a.onChange;
44
44
  return ((0, jsx_runtime_1.jsx)("input", { type: "text", value: value, onChange: onChange }));
45
45
  } })); });
46
+ var mockRow = {
47
+ link: 'https://example.com',
48
+ subCampaigns: [
49
+ { id: '1', name: 'Campaign 1' },
50
+ { id: '2', name: 'Campaign 2' },
51
+ ],
52
+ ghichu: 'Initial note',
53
+ status: 0,
54
+ };
55
+ var renderUi = function () { return (0, react_1.render)((0, jsx_runtime_1.jsx)(RowTable_1.RowTable, { row: mockRow, id: '', updateRow: function () { } })); };
46
56
  describe('RowTable', function () {
47
- var mockRow = {
48
- link: 'https://example.com',
49
- subCampaigns: [
50
- { id: '1', name: 'Campaign 1' },
51
- { id: '2', name: 'Campaign 2' },
52
- ],
53
- ghichu: 'Initial note',
54
- status: 'Chờ duyệt',
55
- };
56
57
  it('renders the link correctly', function () {
57
- (0, react_1.render)((0, jsx_runtime_1.jsx)(RowTable_1.RowTable, { row: mockRow }));
58
+ renderUi();
58
59
  var link = react_1.screen.getByRole('link', { name: 'https://example.com' });
59
60
  expect(link).toBeInTheDocument();
60
61
  expect(link).toHaveAttribute('href', 'https://example.com');
61
62
  });
62
63
  it('renders sub-campaigns as chips', function () {
63
- (0, react_1.render)((0, jsx_runtime_1.jsx)(RowTable_1.RowTable, { row: mockRow }));
64
+ renderUi();
64
65
  expect(react_1.screen.getByText('Campaign 1')).toBeInTheDocument();
65
66
  expect(react_1.screen.getByText('Campaign 2')).toBeInTheDocument();
66
67
  });
67
68
  it('renders the select with correct initial value', function () {
68
- (0, react_1.render)((0, jsx_runtime_1.jsx)(RowTable_1.RowTable, { row: mockRow }));
69
+ renderUi();
69
70
  var select = react_1.screen.getByRole('combobox');
70
71
  expect(select).toHaveValue('Chờ duyệt');
71
72
  });
72
73
  it('changes the select value when a new option is chosen', function () {
73
- (0, react_1.render)((0, jsx_runtime_1.jsx)(RowTable_1.RowTable, { row: mockRow }));
74
+ renderUi();
74
75
  var select = react_1.screen.getByRole('combobox');
75
76
  react_1.fireEvent.change(select, { target: { value: 'Duyệt' } });
76
77
  expect(select).toHaveValue('Duyệt');
77
78
  });
78
79
  it('renders the text field with the initial note', function () {
79
- (0, react_1.render)((0, jsx_runtime_1.jsx)(RowTable_1.RowTable, { row: mockRow }));
80
+ renderUi();
80
81
  var textField = react_1.screen.getByRole('textbox');
81
82
  expect(textField).toHaveValue('Initial note');
82
83
  });
83
84
  it('updates the text field value when typed into', function () {
84
- (0, react_1.render)((0, jsx_runtime_1.jsx)(RowTable_1.RowTable, { row: mockRow }));
85
+ renderUi();
85
86
  var textField = react_1.screen.getByRole('textbox');
86
87
  react_1.fireEvent.change(textField, { target: { value: 'New note' } });
87
88
  expect(textField).toHaveValue('New note');
@@ -3,7 +3,7 @@ interface ISubCampaign {
3
3
  name: string;
4
4
  }
5
5
  export interface IDetail {
6
- status: string;
6
+ status: number;
7
7
  link: string;
8
8
  subCampaigns: ISubCampaign[];
9
9
  ghichu: string;
@@ -1,27 +1,4 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
2
  var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
26
3
  if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
27
4
  if (ar || !(i in from)) {
@@ -40,7 +17,7 @@ var material_1 = require("@mui/material");
40
17
  var Hooks_1 = __importDefault(require("../../../../ACM-AXN/Campaign/Hooks"));
41
18
  var Constant_1 = require("../../../../ACM-AXN/Common/Constant");
42
19
  var lodash_1 = __importDefault(require("lodash"));
43
- var react_1 = __importStar(require("react"));
20
+ var react_1 = require("react");
44
21
  var react_i18next_1 = require("react-i18next");
45
22
  var recoil_1 = require("recoil");
46
23
  var Recoils_1 = require("../Recoils");
@@ -109,7 +86,7 @@ function TabApprove() {
109
86
  ],
110
87
  link: renderLinkPreview(ad, domainId),
111
88
  ghichu: 'ghichu',
112
- status: 'status',
89
+ status: 0,
113
90
  };
114
91
  }
115
92
  })
@@ -141,6 +118,23 @@ function TabApprove() {
141
118
  return pre.includes(id) ? pre.filter(function (x) { return x !== id; }) : __spreadArray(__spreadArray([], pre, true), [id], false);
142
119
  });
143
120
  }, []);
121
+ var updateRow = (0, react_1.useCallback)(function (row, id) {
122
+ // setData((prevData) =>
123
+ // prevData.map((item) => {
124
+ // if (id === item.id) {
125
+ // return {
126
+ // ...item,
127
+ // detail: item.detail.map((detailItem) => ({
128
+ // ...detailItem,
129
+ // ghichu: row.ghichu,
130
+ // status: row.status,
131
+ // })),
132
+ // }
133
+ // }
134
+ // return item
135
+ // })
136
+ // )
137
+ }, []);
144
138
  (0, react_1.useEffect)(function () {
145
139
  if (domainIds.length > 0) {
146
140
  service.domainsGetByIds &&
@@ -149,10 +143,15 @@ function TabApprove() {
149
143
  }, [domainIds]);
150
144
  return ((0, jsx_runtime_1.jsxs)(material_1.TableContainer, { children: [(0, jsx_runtime_1.jsx)(material_1.Button, { variant: "outlined", sx: {
151
145
  margin: '1rem',
152
- }, children: t('Campaign.Approval.GetApprovalInformation') }), (0, jsx_runtime_1.jsxs)(material_1.Table, { 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 &&
146
+ }, children: t('Campaign.Approval.GetApprovalInformation') }), (0, jsx_runtime_1.jsx)(material_1.Button, { variant: "outlined", color: "primary", disabled: !rowSelected.length, children: t('Campaign.Approval.SendEmail') }), (0, jsx_runtime_1.jsxs)(material_1.Table, { sx: {
147
+ boxShadow: 'none',
148
+ '.MuiOutlinedInput-notchedOutline': {
149
+ border: 'none !important',
150
+ },
151
+ }, 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 &&
153
152
  rowSelected.length < dataTable.length, checked: rowSelected.length > 0 &&
154
- rowSelected.length === dataTable.length, onChange: handleSelectAll, inputProps: { 'aria-label': 'select all ad' }, color: "primary" }) }), rowSelected.length ? ((0, jsx_runtime_1.jsx)(material_1.TableCell, { colSpan: 5, style: { padding: 0 }, children: (0, jsx_runtime_1.jsx)(material_1.Button, { variant: "outlined", color: "primary", children: t('Campaign.Approval.SendEmail') }) })) : ((0, jsx_runtime_1.jsxs)(react_1.default.Fragment, { children: [(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.Status') }), (0, jsx_runtime_1.jsx)(material_1.TableCell, { children: t('Campaign.Approval.Note') })] }))] }) }), (0, jsx_runtime_1.jsx)(material_1.TableBody, { children: dataTable.map(function (item, index) { return ((0, jsx_runtime_1.jsxs)(react_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)(material_1.TableRow, { children: [(0, jsx_runtime_1.jsx)(material_1.TableCell, { rowSpan: item.detail.length + 1, 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 === item.id; }), color: "primary", onChange: function () {
153
+ rowSelected.length === dataTable.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.Status') }), (0, jsx_runtime_1.jsx)(material_1.TableCell, { children: t('Campaign.Approval.Note') })] }) }), (0, jsx_runtime_1.jsx)(material_1.TableBody, { children: dataTable.map(function (item, index) { return ((0, jsx_runtime_1.jsxs)(react_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)(material_1.TableRow, { children: [(0, jsx_runtime_1.jsx)(material_1.TableCell, { rowSpan: item.detail.length + 1, 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 === item.id; }), color: "primary", onChange: function () {
155
154
  return handleRowSelect(item.id);
156
- } }) }) }), (0, jsx_runtime_1.jsx)(material_1.TableCell, { rowSpan: item.detail.length + 1, children: item.domainName })] }), item.detail.map(function (detail, index2) { return ((0, jsx_runtime_1.jsx)(RowTable_1.RowTable, { row: detail }, index2)); })] }, index)); }) })] })] }));
155
+ } }) }) }), (0, jsx_runtime_1.jsx)(material_1.TableCell, { rowSpan: item.detail.length + 1, children: item.domainName })] }), item.detail.map(function (detail, index2) { return ((0, jsx_runtime_1.jsx)(RowTable_1.RowTable, { row: detail, id: item.id, updateRow: updateRow }, index2)); })] }, index)); }) })] })] }));
157
156
  }
158
157
  exports.default = TabApprove;
@@ -62,13 +62,6 @@ 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 route = [
66
- Constant_1.Constants.CAMPAIGN_INFORMATION,
67
- Constant_1.Constants.CAMPAIGN_SUBCAMPAIGN,
68
- Constant_1.Constants.CAMPAIGN_STATISTICS,
69
- Constant_1.Constants.CAMPAIGN_CONNECT,
70
- Constant_1.Constants.CAMPAIGN_PERMISSION,
71
- ];
72
65
  var CreateOrEdit = function (props) {
73
66
  var _a;
74
67
  var _b = (0, Router_1.useParams)(), campaignId = _b.campaignId, tabName = _b.tabName;
@@ -135,25 +128,22 @@ var CreateOrEdit = function (props) {
135
128
  }
136
129
  // eslint-disable-next-line react-hooks/exhaustive-deps
137
130
  }, []);
138
- (0, react_1.useLayoutEffect)(function () {
139
- if (tabName && route.includes(tabName)) {
140
- setValue(String(route.indexOf(tabName)));
141
- }
142
- }, [tabName]);
143
131
  var getTabs = function () {
144
- return !(campaignData.campaignWizard && !editModeWizard && (props === null || props === void 0 ? void 0 : props.quickWizard))
132
+ var baseTabs = !(campaignData.campaignWizard && !editModeWizard && (props === null || props === void 0 ? void 0 : props.quickWizard))
145
133
  ? [
146
134
  {
147
135
  label: t('Campaign.Info'),
148
136
  isShow: true,
149
137
  valid: 'tabInfomationValid',
150
138
  component: (0, jsx_runtime_1.jsx)(TabInfomation_1.default, {}),
139
+ route: Constant_1.Constants.CAMPAIGN_INFORMATION,
151
140
  },
152
141
  {
153
142
  label: t('Campaign.SubCampaign'),
154
143
  isShow: true,
155
144
  valid: 'tabSubCampaignValid',
156
145
  component: (0, jsx_runtime_1.jsx)(TabSubCampaign_1.default, {}),
146
+ route: Constant_1.Constants.CAMPAIGN_SUBCAMPAIGN,
157
147
  },
158
148
  ]
159
149
  : [
@@ -162,43 +152,65 @@ var CreateOrEdit = function (props) {
162
152
  isShow: true,
163
153
  component: props === null || props === void 0 ? void 0 : props.quickWizard({
164
154
  ref: childRefWizard,
165
- onSubmitWizard: handleSubmit,
166
155
  }),
156
+ route: Constant_1.Constants.CAMPAIGN_WIZARD,
167
157
  },
168
158
  ];
169
- };
170
- var tabsList = (0, react_1.useMemo)(function () {
171
- return __spreadArray(__spreadArray([], getTabs(), true), [
159
+ return __spreadArray(__spreadArray([], baseTabs, true), [
172
160
  {
173
161
  label: t('Campaign.Approval.Title'),
174
162
  isShow: Boolean(service.attributesGetByObjectTypeCode),
175
163
  component: (0, jsx_runtime_1.jsx)(TabApprove_1.default, {}),
164
+ route: Constant_1.Constants.CAMPAIGN_APPROVE,
176
165
  },
177
166
  {
178
167
  label: t('Campaign.Statistic'),
179
168
  isShow: componentStatus === Constant_1.Constants.CAMPAIGN_DETAIL,
180
169
  component: ((0, jsx_runtime_1.jsx)(TabStatistic_1.default, __assign({ campaignId: campaignData.campaign.id, campaignName: campaignData.campaign.name, subCampaigns: campaignData.campaignGroups, fullPlaces: fullPlaces }, otherProps, { services: service }))),
170
+ route: Constant_1.Constants.CAMPAIGN_STATISTICS,
181
171
  },
182
172
  {
183
173
  label: t('Campaign.Partner'),
184
174
  isShow: true,
185
175
  component: (0, jsx_runtime_1.jsx)(TabPartner_1.default, {}),
186
176
  valid: 'tabPartnerValid',
177
+ route: Constant_1.Constants.CAMPAIGN_CONNECT,
187
178
  },
188
179
  {
189
180
  label: t('Campaign.Permission'),
190
181
  isShow: componentStatus === Constant_1.Constants.CAMPAIGN_DETAIL,
191
182
  component: (0, jsx_runtime_1.jsx)(TabPermission_1.default, {}),
183
+ route: Constant_1.Constants.CAMPAIGN_PERMISSION,
192
184
  },
193
185
  ], false).filter(function (tab) { return tab.isShow; });
186
+ };
187
+ var tabsList = (0, react_1.useMemo)(function () {
188
+ return getTabs();
194
189
  },
195
190
  // eslint-disable-next-line react-hooks/exhaustive-deps
196
- [t, componentStatus, Constant_1.Constants, campaignData, editModeWizard]);
191
+ [t, componentStatus, Constant_1.Constants, campaignData, editModeWizard, campaignData.campaignWizard]);
192
+ (0, react_1.useLayoutEffect)(function () {
193
+ var tabIndex = tabsList.findIndex(function (tab) { return tab.route === tabName; });
194
+ if (tabIndex !== -1) {
195
+ setValue(String(tabIndex));
196
+ }
197
+ else {
198
+ var firstTabRoute = tabsList[0].route;
199
+ navigate((0, Router_1.generatePath)(matchPath, {
200
+ campaignId: campaignId,
201
+ tabName: firstTabRoute,
202
+ }), { replace: true });
203
+ setValue('0');
204
+ }
205
+ }, [tabName, tabsList]);
197
206
  var handleChangeTab = function (_event, newValue) {
198
- navigate((0, Router_1.generatePath)(matchPath, {
199
- campaignId: campaignId,
200
- tabName: route[Number(newValue)],
201
- }), { replace: true });
207
+ var newTab = tabsList[Number(newValue)];
208
+ if (newTab) {
209
+ navigate((0, Router_1.generatePath)(matchPath, {
210
+ campaignId: campaignId,
211
+ tabName: newTab.route,
212
+ }), { replace: true });
213
+ }
202
214
  };
203
215
  var getCampaignData = function () {
204
216
  if (campaignId) {
@@ -82,6 +82,7 @@ export declare const Constants: {
82
82
  CAMPAIGN_CONNECT: string;
83
83
  CAMPAIGN_PERMISSION: string;
84
84
  CAMPAIGN_APPROVE: string;
85
+ CAMPAIGN_WIZARD: string;
85
86
  CAPTIVE_DOMAIN: any;
86
87
  CAMPAIGN_PREVIEW: string;
87
88
  DOMAIN_PREVIEW: string;
@@ -72,6 +72,7 @@ exports.Constants = {
72
72
  CAMPAIGN_CONNECT: 'Connect',
73
73
  CAMPAIGN_PERMISSION: 'Permission',
74
74
  CAMPAIGN_APPROVE: 'Approve',
75
+ CAMPAIGN_WIZARD: 'Wizard',
75
76
  CAPTIVE_DOMAIN: window.REACT_APP_CAPTIVE_DOMAIN,
76
77
  CAMPAIGN_PREVIEW: 'Preview/Campaign',
77
78
  DOMAIN_PREVIEW: 'Preview/Domain',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "awing-library",
3
- "version": "2.1.218-dev",
3
+ "version": "2.1.219-dev",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",