@msrajawat298/do-graphs 1.0.0 → 1.0.2
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/README.md +1 -1
- package/dist/App.js +124 -124
- package/dist/App.test.js +8 -8
- package/dist/Components/Charts/Bar/Form.js +231 -231
- package/dist/Components/Charts/Bar/Format.js +43 -43
- package/dist/Components/Charts/Bar/index.js +106 -106
- package/dist/Components/Charts/DoughnutAndPie/Form.js +232 -232
- package/dist/Components/Charts/DoughnutAndPie/Format.js +52 -52
- package/dist/Components/Charts/DoughnutAndPie/index.js +106 -106
- package/dist/Components/Charts/DrawGraph.js +32 -32
- package/dist/Components/Charts/Line/Form.js +231 -231
- package/dist/Components/Charts/Line/Format.js +47 -47
- package/dist/Components/Charts/Line/index.js +106 -106
- package/dist/Components/Charts/MixedChart/index.js +107 -107
- package/dist/Components/Charts/Options.js +139 -139
- package/dist/Components/Charts/PolarArea/Form.js +225 -225
- package/dist/Components/Charts/PolarArea/Format.js +42 -42
- package/dist/Components/Charts/PolarArea/index.js +106 -106
- package/dist/Components/Charts/Progess/Form.js +107 -107
- package/dist/Components/Charts/Progess/index.js +119 -119
- package/dist/Components/Charts/Scatter/Form.js +225 -225
- package/dist/Components/Charts/Scatter/Format.js +45 -45
- package/dist/Components/Charts/Scatter/index.js +106 -106
- package/dist/Components/Charts/Table/Form.js +70 -70
- package/dist/Components/Charts/Table/Styles.js +27 -27
- package/dist/Components/Charts/Table/index.js +56 -56
- package/dist/Components/Common/CustomComponent/index.js +83 -83
- package/dist/Components/Common/Menu/DynamicMenu/List.js +43 -43
- package/dist/Components/Common/Menu/DynamicMenu/index.js +155 -155
- package/dist/Components/Common/Menu/index.js +24 -24
- package/dist/Components/Common/Model/Model.js +56 -56
- package/dist/Components/Common/MultipleSelectDropdown/index.js +124 -124
- package/dist/Components/Common/NotFound/index.js +19 -19
- package/dist/Components/Common/Title/Form.js +36 -36
- package/dist/Components/Common/Title/Styles.js +16 -16
- package/dist/Components/Common/Title/index.js +41 -41
- package/dist/Components/Common/Widget/index.js +407 -407
- package/dist/Pages/Dashboard/CreatePage.js +115 -115
- package/dist/Pages/Dashboard/index.js +150 -150
- package/dist/Pages/LayoutPages/index.js +143 -143
- package/dist/Pages/Layouts/index.js +52 -52
- package/dist/Services/Menu.js +58 -58
- package/dist/Services/Routing.js +80 -80
- package/dist/Utility/Contexts.js +20 -20
- package/dist/Utility/Main.js +368 -368
- package/dist/Utility/Routes.js +10 -10
- package/dist/index.js +15 -15
- package/dist/reportWebVitals.js +13 -13
- package/dist/setupTests.js +5 -5
- package/package.json +4 -3
- package/dist/Assets/Fonts/NotoSans-Bold.ttf +0 -0
- package/dist/Assets/Fonts/NotoSans-Medium.ttf +0 -0
- package/dist/Assets/Fonts/NotoSans-Regular.ttf +0 -0
- package/dist/Assets/Fonts/NotoSans-SemiBold.ttf +0 -0
- package/dist/Assets/Images/analytic-graph.png +0 -0
- package/dist/Assets/Images/bar-graph.png +0 -0
- package/dist/Assets/Images/bubble-chart.png +0 -0
- package/dist/Assets/Images/coding.png +0 -0
- package/dist/Assets/Images/doughnut.png +0 -0
- package/dist/Assets/Images/horizontal-bar-graph.png +0 -0
- package/dist/Assets/Images/line-chart.png +0 -0
- package/dist/Assets/Images/mixed-chart.png +0 -0
- package/dist/Assets/Images/pie-chart.png +0 -0
- package/dist/Assets/Images/polar-chart.png +0 -0
- package/dist/Assets/Images/progress-bar.png +0 -0
- package/dist/Assets/Images/scatter-graph.png +0 -0
- package/dist/Assets/Images/table.png +0 -0
- package/dist/Assets/Images/travel.png +0 -0
|
@@ -1,83 +1,83 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
-
});
|
|
20
|
-
};
|
|
21
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
22
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
23
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
24
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
25
|
-
function step(op) {
|
|
26
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
27
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
28
|
-
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;
|
|
29
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
30
|
-
switch (op[0]) {
|
|
31
|
-
case 0: case 1: t = op; break;
|
|
32
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
33
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
34
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
35
|
-
default:
|
|
36
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
37
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
38
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
39
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
40
|
-
if (t[2]) _.ops.pop();
|
|
41
|
-
_.trys.pop(); continue;
|
|
42
|
-
}
|
|
43
|
-
op = body.call(thisArg, _);
|
|
44
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
45
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
49
|
-
import { Suspense, useContext, useEffect, useState } from 'react';
|
|
50
|
-
import { toast } from 'react-toastify';
|
|
51
|
-
import { PopUpContext } from '../../../Utility/Contexts';
|
|
52
|
-
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
53
|
-
import { faTrashAlt } from '@fortawesome/free-solid-svg-icons';
|
|
54
|
-
var CustomComponent = function (_a) {
|
|
55
|
-
var component = _a.component, layoutId = _a.layoutId, isConfigEdit = _a.isConfigEdit;
|
|
56
|
-
var _b = useContext(PopUpContext), layout = _b.layout, setLayout = _b.setLayout, removeChart = _b.removeChart;
|
|
57
|
-
var _c = useState(null), importedComponent = _c[0], setImportedComponent = _c[1];
|
|
58
|
-
var importComponent = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
59
|
-
var module_1, AnotherComponent, error_1;
|
|
60
|
-
return __generator(this, function (_a) {
|
|
61
|
-
switch (_a.label) {
|
|
62
|
-
case 0:
|
|
63
|
-
_a.trys.push([0, 2, , 3]);
|
|
64
|
-
return [4 /*yield*/, import(process.env.REACT_APP_ROOT_PATH + '/' + component)];
|
|
65
|
-
case 1:
|
|
66
|
-
module_1 = _a.sent();
|
|
67
|
-
AnotherComponent = module_1.default;
|
|
68
|
-
setImportedComponent(_jsx(AnotherComponent, {}));
|
|
69
|
-
return [3 /*break*/, 3];
|
|
70
|
-
case 2:
|
|
71
|
-
error_1 = _a.sent();
|
|
72
|
-
toast.error(error_1 === null || error_1 === void 0 ? void 0 : error_1.toString());
|
|
73
|
-
return [3 /*break*/, 3];
|
|
74
|
-
case 3: return [2 /*return*/];
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
}); };
|
|
78
|
-
useEffect(function () {
|
|
79
|
-
importComponent();
|
|
80
|
-
}, []);
|
|
81
|
-
return (_jsx("div", { children: _jsxs(Suspense, __assign({ fallback: _jsx("div", { children: "loading.." }) }, { children: [_jsx("div", __assign({ className: 'delete-icons', style: { textAlign: 'right' } }, { children: isConfigEdit && _jsx(FontAwesomeIcon, { className: 'disable', icon: faTrashAlt, color: 'red', style: { marginRight: 15 }, cursor: 'pointer', onClick: function () { return removeChart(layoutId); } }) })), importedComponent] })) }));
|
|
82
|
-
};
|
|
83
|
-
export default CustomComponent;
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
22
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
23
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
24
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
25
|
+
function step(op) {
|
|
26
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
27
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
28
|
+
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;
|
|
29
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
30
|
+
switch (op[0]) {
|
|
31
|
+
case 0: case 1: t = op; break;
|
|
32
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
33
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
34
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
35
|
+
default:
|
|
36
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
37
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
38
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
39
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
40
|
+
if (t[2]) _.ops.pop();
|
|
41
|
+
_.trys.pop(); continue;
|
|
42
|
+
}
|
|
43
|
+
op = body.call(thisArg, _);
|
|
44
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
45
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
49
|
+
import { Suspense, useContext, useEffect, useState } from 'react';
|
|
50
|
+
import { toast } from 'react-toastify';
|
|
51
|
+
import { PopUpContext } from '../../../Utility/Contexts';
|
|
52
|
+
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
53
|
+
import { faTrashAlt } from '@fortawesome/free-solid-svg-icons';
|
|
54
|
+
var CustomComponent = function (_a) {
|
|
55
|
+
var component = _a.component, layoutId = _a.layoutId, isConfigEdit = _a.isConfigEdit;
|
|
56
|
+
var _b = useContext(PopUpContext), layout = _b.layout, setLayout = _b.setLayout, removeChart = _b.removeChart;
|
|
57
|
+
var _c = useState(null), importedComponent = _c[0], setImportedComponent = _c[1];
|
|
58
|
+
var importComponent = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
59
|
+
var module_1, AnotherComponent, error_1;
|
|
60
|
+
return __generator(this, function (_a) {
|
|
61
|
+
switch (_a.label) {
|
|
62
|
+
case 0:
|
|
63
|
+
_a.trys.push([0, 2, , 3]);
|
|
64
|
+
return [4 /*yield*/, import(process.env.REACT_APP_ROOT_PATH + '/' + component)];
|
|
65
|
+
case 1:
|
|
66
|
+
module_1 = _a.sent();
|
|
67
|
+
AnotherComponent = module_1.default;
|
|
68
|
+
setImportedComponent(_jsx(AnotherComponent, {}));
|
|
69
|
+
return [3 /*break*/, 3];
|
|
70
|
+
case 2:
|
|
71
|
+
error_1 = _a.sent();
|
|
72
|
+
toast.error(error_1 === null || error_1 === void 0 ? void 0 : error_1.toString());
|
|
73
|
+
return [3 /*break*/, 3];
|
|
74
|
+
case 3: return [2 /*return*/];
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
}); };
|
|
78
|
+
useEffect(function () {
|
|
79
|
+
importComponent();
|
|
80
|
+
}, []);
|
|
81
|
+
return (_jsx("div", { children: _jsxs(Suspense, __assign({ fallback: _jsx("div", { children: "loading.." }) }, { children: [_jsx("div", __assign({ className: 'delete-icons', style: { textAlign: 'right' } }, { children: isConfigEdit && _jsx(FontAwesomeIcon, { className: 'disable', icon: faTrashAlt, color: 'red', style: { marginRight: 15 }, cursor: 'pointer', onClick: function () { return removeChart(layoutId); } }) })), importedComponent] })) }));
|
|
82
|
+
};
|
|
83
|
+
export default CustomComponent;
|
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
-
import { faArrowRightLong, faBars, faClose } from '@fortawesome/free-solid-svg-icons';
|
|
14
|
-
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
15
|
-
import { useContext } from 'react';
|
|
16
|
-
import './index.css';
|
|
17
|
-
import { useNavigate } from 'react-router-dom';
|
|
18
|
-
import { PopUpContext } from '../../../../Utility/Contexts';
|
|
19
|
-
import * as Icons from '@fortawesome/free-solid-svg-icons';
|
|
20
|
-
var DynamicMenuList = function (props) {
|
|
21
|
-
var _a, _b, _c;
|
|
22
|
-
var navigate = useNavigate();
|
|
23
|
-
var _d = useContext(PopUpContext), showMenu = _d.showMenu, setShowMenu = _d.setShowMenu;
|
|
24
|
-
var handleMenu = function () {
|
|
25
|
-
if (showMenu) {
|
|
26
|
-
setShowMenu(false);
|
|
27
|
-
}
|
|
28
|
-
else {
|
|
29
|
-
setShowMenu(true);
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
var renderIcons = function (fIcon) {
|
|
33
|
-
var iconList = Object.keys(Icons).filter(function (key) { return key === (fIcon === null || fIcon === void 0 ? void 0 : fIcon.icons); }).map(function (icon) { return Icons[icon]; });
|
|
34
|
-
if ((iconList === null || iconList === void 0 ? void 0 : iconList.length) > 0) {
|
|
35
|
-
return (_jsx("div", __assign({ className: 'w-100 p-relative list-icn text-center' }, { children: _jsx(FontAwesomeIcon, { className: 'menu-icons', icon: iconList === null || iconList === void 0 ? void 0 : iconList[0], size: 'lg' }) })));
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
return (_jsxs("div", __assign({ className: 'menu-list', style: { width: (props === null || props === void 0 ? void 0 : props.show) ? '200px' : '100%' } }, { children: [((_a = props === null || props === void 0 ? void 0 : props.menu) === null || _a === void 0 ? void 0 : _a.length) > 0 && _jsx(FontAwesomeIcon, { icon: showMenu ? faClose : faBars, size: 'lg', cursor: 'pointer', className: 'mic', onClick: handleMenu }), (props === null || props === void 0 ? void 0 : props.show) && _jsxs("h4", { children: ["Menu ", _jsx(FontAwesomeIcon, { icon: faArrowRightLong })] }), ((_b = props === null || props === void 0 ? void 0 : props.menu) === null || _b === void 0 ? void 0 : _b.length) > 0 && _jsx("ul", __assign({ className: "list-unstyled dy-mn-li", style: { paddingTop: (props === null || props === void 0 ? void 0 : props.show) ? 15 : 25 } }, { children: (_c = props === null || props === void 0 ? void 0 : props.menu) === null || _c === void 0 ? void 0 : _c.map(function (item, i) {
|
|
39
|
-
var _a, _b, _c;
|
|
40
|
-
return (_jsxs("li", __assign({ onClick: function () { var _a; return ((_a = item === null || item === void 0 ? void 0 : item.subMenu) === null || _a === void 0 ? void 0 : _a.length) === 0 && navigate(item === null || item === void 0 ? void 0 : item.path); }, style: { paddingBottom: ((_a = item === null || item === void 0 ? void 0 : item.subMenu) === null || _a === void 0 ? void 0 : _a.length) > 0 ? 15 : 0 } }, { children: [(props === null || props === void 0 ? void 0 : props.show) ? _jsx("p", { children: item === null || item === void 0 ? void 0 : item.title }) : renderIcons(item), (props === null || props === void 0 ? void 0 : props.show) && ((_b = item === null || item === void 0 ? void 0 : item.subMenu) === null || _b === void 0 ? void 0 : _b.length) > 0 && _jsx("ul", __assign({ className: "list-unstyled dy-mn-sli pad-l-30" }, { children: (_c = item === null || item === void 0 ? void 0 : item.subMenu) === null || _c === void 0 ? void 0 : _c.map(function (sm, s) { return (_jsx("li", __assign({ onClick: function () { return navigate(sm === null || sm === void 0 ? void 0 : sm.path); } }, { children: sm === null || sm === void 0 ? void 0 : sm.title }), s)); }) }))] }), i));
|
|
41
|
-
}) }))] })));
|
|
42
|
-
};
|
|
43
|
-
export default DynamicMenuList;
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
import { faArrowRightLong, faBars, faClose } from '@fortawesome/free-solid-svg-icons';
|
|
14
|
+
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
15
|
+
import { useContext } from 'react';
|
|
16
|
+
import './index.css';
|
|
17
|
+
import { useNavigate } from 'react-router-dom';
|
|
18
|
+
import { PopUpContext } from '../../../../Utility/Contexts';
|
|
19
|
+
import * as Icons from '@fortawesome/free-solid-svg-icons';
|
|
20
|
+
var DynamicMenuList = function (props) {
|
|
21
|
+
var _a, _b, _c;
|
|
22
|
+
var navigate = useNavigate();
|
|
23
|
+
var _d = useContext(PopUpContext), showMenu = _d.showMenu, setShowMenu = _d.setShowMenu;
|
|
24
|
+
var handleMenu = function () {
|
|
25
|
+
if (showMenu) {
|
|
26
|
+
setShowMenu(false);
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
setShowMenu(true);
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
var renderIcons = function (fIcon) {
|
|
33
|
+
var iconList = Object.keys(Icons).filter(function (key) { return key === (fIcon === null || fIcon === void 0 ? void 0 : fIcon.icons); }).map(function (icon) { return Icons[icon]; });
|
|
34
|
+
if ((iconList === null || iconList === void 0 ? void 0 : iconList.length) > 0) {
|
|
35
|
+
return (_jsx("div", __assign({ className: 'w-100 p-relative list-icn text-center' }, { children: _jsx(FontAwesomeIcon, { className: 'menu-icons', icon: iconList === null || iconList === void 0 ? void 0 : iconList[0], size: 'lg' }) })));
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
return (_jsxs("div", __assign({ className: 'menu-list', style: { width: (props === null || props === void 0 ? void 0 : props.show) ? '200px' : '100%' } }, { children: [((_a = props === null || props === void 0 ? void 0 : props.menu) === null || _a === void 0 ? void 0 : _a.length) > 0 && _jsx(FontAwesomeIcon, { icon: showMenu ? faClose : faBars, size: 'lg', cursor: 'pointer', className: 'mic', onClick: handleMenu }), (props === null || props === void 0 ? void 0 : props.show) && _jsxs("h4", { children: ["Menu ", _jsx(FontAwesomeIcon, { icon: faArrowRightLong })] }), ((_b = props === null || props === void 0 ? void 0 : props.menu) === null || _b === void 0 ? void 0 : _b.length) > 0 && _jsx("ul", __assign({ className: "list-unstyled dy-mn-li", style: { paddingTop: (props === null || props === void 0 ? void 0 : props.show) ? 15 : 25 } }, { children: (_c = props === null || props === void 0 ? void 0 : props.menu) === null || _c === void 0 ? void 0 : _c.map(function (item, i) {
|
|
39
|
+
var _a, _b, _c;
|
|
40
|
+
return (_jsxs("li", __assign({ onClick: function () { var _a; return ((_a = item === null || item === void 0 ? void 0 : item.subMenu) === null || _a === void 0 ? void 0 : _a.length) === 0 && navigate(item === null || item === void 0 ? void 0 : item.path); }, style: { paddingBottom: ((_a = item === null || item === void 0 ? void 0 : item.subMenu) === null || _a === void 0 ? void 0 : _a.length) > 0 ? 15 : 0 } }, { children: [(props === null || props === void 0 ? void 0 : props.show) ? _jsx("p", { children: item === null || item === void 0 ? void 0 : item.title }) : renderIcons(item), (props === null || props === void 0 ? void 0 : props.show) && ((_b = item === null || item === void 0 ? void 0 : item.subMenu) === null || _b === void 0 ? void 0 : _b.length) > 0 && _jsx("ul", __assign({ className: "list-unstyled dy-mn-sli pad-l-30" }, { children: (_c = item === null || item === void 0 ? void 0 : item.subMenu) === null || _c === void 0 ? void 0 : _c.map(function (sm, s) { return (_jsx("li", __assign({ onClick: function () { return navigate(sm === null || sm === void 0 ? void 0 : sm.path); } }, { children: sm === null || sm === void 0 ? void 0 : sm.title }), s)); }) }))] }), i));
|
|
41
|
+
}) }))] })));
|
|
42
|
+
};
|
|
43
|
+
export default DynamicMenuList;
|
|
@@ -1,155 +1,155 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
-
});
|
|
20
|
-
};
|
|
21
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
22
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
23
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
24
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
25
|
-
function step(op) {
|
|
26
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
27
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
28
|
-
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;
|
|
29
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
30
|
-
switch (op[0]) {
|
|
31
|
-
case 0: case 1: t = op; break;
|
|
32
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
33
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
34
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
35
|
-
default:
|
|
36
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
37
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
38
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
39
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
40
|
-
if (t[2]) _.ops.pop();
|
|
41
|
-
_.trys.pop(); continue;
|
|
42
|
-
}
|
|
43
|
-
op = body.call(thisArg, _);
|
|
44
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
45
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
49
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
50
|
-
if (ar || !(i in from)) {
|
|
51
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
52
|
-
ar[i] = from[i];
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
56
|
-
};
|
|
57
|
-
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
58
|
-
import React, { useContext, useEffect, useState } from "react";
|
|
59
|
-
import { toast } from "react-toastify";
|
|
60
|
-
import { PopUpContext, RouteContext } from "../../../../Utility/Contexts";
|
|
61
|
-
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
|
62
|
-
import { faPlusSquare } from "@fortawesome/free-regular-svg-icons";
|
|
63
|
-
import './index.css';
|
|
64
|
-
import { createMenu } from "../../../../Services/Menu";
|
|
65
|
-
import * as Icons from '@fortawesome/free-solid-svg-icons';
|
|
66
|
-
export var DynamicMenu = function (props) {
|
|
67
|
-
var _a, _b;
|
|
68
|
-
var _c = useState({
|
|
69
|
-
name: '',
|
|
70
|
-
menu: [{
|
|
71
|
-
title: '',
|
|
72
|
-
path: '',
|
|
73
|
-
icon: '',
|
|
74
|
-
subMenu: []
|
|
75
|
-
}]
|
|
76
|
-
}), data = _c[0], setData = _c[1];
|
|
77
|
-
var _d = useContext(PopUpContext), setshowPopup = _d.setshowPopup, setMenu = _d.setMenu, menu = _d.menu;
|
|
78
|
-
var routePages = useContext(RouteContext).routePages;
|
|
79
|
-
var _e = useState([]), paths = _e[0], setPaths = _e[1];
|
|
80
|
-
var handleChange = function (e, i, p, field) {
|
|
81
|
-
var _a = e.target, name = _a.name, value = _a.value;
|
|
82
|
-
if (field === 'Submenu') {
|
|
83
|
-
data['menu'][i]['subMenu'][p][name] = value;
|
|
84
|
-
}
|
|
85
|
-
else {
|
|
86
|
-
data['menu'][i][name] = value;
|
|
87
|
-
}
|
|
88
|
-
setData(__assign({}, data));
|
|
89
|
-
};
|
|
90
|
-
var AddNewRow = function (e) {
|
|
91
|
-
data['menu'] = __spreadArray(__spreadArray([], data['menu'], true), [{ title: '', path: '', subMenu: [] }], false);
|
|
92
|
-
setData(__assign({}, data));
|
|
93
|
-
};
|
|
94
|
-
var AddNewSubRow = function (e, i) {
|
|
95
|
-
data['menu'][i]['subMenu'] = __spreadArray(__spreadArray([], data['menu'][i]['subMenu'], true), [{ title: '', path: '' }], false);
|
|
96
|
-
setData(__assign({}, data));
|
|
97
|
-
};
|
|
98
|
-
var handleSubmit = function (e) { return __awaiter(void 0, void 0, void 0, function () {
|
|
99
|
-
var config, result, obj, getIds, getMaxId, error_1;
|
|
100
|
-
return __generator(this, function (_a) {
|
|
101
|
-
switch (_a.label) {
|
|
102
|
-
case 0:
|
|
103
|
-
e.preventDefault();
|
|
104
|
-
_a.label = 1;
|
|
105
|
-
case 1:
|
|
106
|
-
_a.trys.push([1, 4, , 5]);
|
|
107
|
-
if (!(data === null || data === void 0 ? void 0 : data.name)) return [3 /*break*/, 3];
|
|
108
|
-
config = {
|
|
109
|
-
method: 'POST',
|
|
110
|
-
body: JSON.stringify(data),
|
|
111
|
-
headers: __assign({ "Content-Type": "application/json" }, props === null || props === void 0 ? void 0 : props.headers)
|
|
112
|
-
};
|
|
113
|
-
return [4 /*yield*/, createMenu(props === null || props === void 0 ? void 0 : props.backendUrl, config)];
|
|
114
|
-
case 2:
|
|
115
|
-
result = _a.sent();
|
|
116
|
-
toast.success(result === null || result === void 0 ? void 0 : result.message);
|
|
117
|
-
obj = data;
|
|
118
|
-
getIds = (menu === null || menu === void 0 ? void 0 : menu.map(function (it) { return it === null || it === void 0 ? void 0 : it.id; })) || [];
|
|
119
|
-
getMaxId = (getIds === null || getIds === void 0 ? void 0 : getIds.length) > 0 ? Math.max.apply(Math, getIds) : 0;
|
|
120
|
-
obj['id'] = (result === null || result === void 0 ? void 0 : result.id) || getMaxId + 1;
|
|
121
|
-
setMenu(__spreadArray(__spreadArray([], menu, true), [obj], false));
|
|
122
|
-
setshowPopup(false);
|
|
123
|
-
_a.label = 3;
|
|
124
|
-
case 3: return [3 /*break*/, 5];
|
|
125
|
-
case 4:
|
|
126
|
-
error_1 = _a.sent();
|
|
127
|
-
toast.error(error_1 === null || error_1 === void 0 ? void 0 : error_1.toString());
|
|
128
|
-
return [3 /*break*/, 5];
|
|
129
|
-
case 5: return [2 /*return*/];
|
|
130
|
-
}
|
|
131
|
-
});
|
|
132
|
-
}); };
|
|
133
|
-
var renderHtml = function (i, p, field) {
|
|
134
|
-
var _a;
|
|
135
|
-
return (_jsxs(React.Fragment, { children: [_jsxs("div", __assign({ className: "form-group ".concat(field === 'Menu' ? 'w-25' : 'w-45') }, { children: [_jsxs("label", { children: [field, " Title (", i + 1, field === 'Submenu' && ".".concat(p + 1), ")"] }), _jsx("input", { type: "text", name: 'title', className: "form-control", onChange: function (e) { return handleChange(e, i, p, field); } })] })), _jsxs("div", __assign({ className: "form-group ".concat(field === 'Menu' ? 'w-25' : 'w-45') }, { children: [_jsxs("label", { children: [field, " Path (", i + 1, field === 'Submenu' && ".".concat(p + 1), ")"] }), _jsxs("select", __assign({ name: "path", className: "form-control", onChange: function (e) { return handleChange(e, i, p, field); } }, { children: [_jsx("option", __assign({ value: '' }, { children: "-- Select Route --" })), paths === null || paths === void 0 ? void 0 : paths.map(function (it, i) {
|
|
136
|
-
var _a;
|
|
137
|
-
return (_jsx("option", __assign({ value: it === null || it === void 0 ? void 0 : it.path }, { children: (_a = it === null || it === void 0 ? void 0 : it.title) === null || _a === void 0 ? void 0 : _a.name }), i));
|
|
138
|
-
})] }))] })), field === 'Menu' && _jsxs("div", __assign({ className: "form-group ".concat(field === 'Menu' ? 'w-25' : 'w-45') }, { children: [_jsx("label", { children: "Title Icons" }), _jsxs("select", __assign({ name: "icon", className: "form-control", onChange: function (e) { return handleChange(e, i, p, field); } }, { children: [_jsx("option", __assign({ value: '' }, { children: "-- Select Icon --" })), (_a = Object.keys(Icons)) === null || _a === void 0 ? void 0 : _a.map(function (it, i) { return (_jsx("option", __assign({ value: it }, { children: it }), i)); })] }))] }))] }));
|
|
139
|
-
};
|
|
140
|
-
var getRoutesData = function () {
|
|
141
|
-
var routes = routePages === null || routePages === void 0 ? void 0 : routePages.map(function (it) { return { id: it === null || it === void 0 ? void 0 : it.id, title: it === null || it === void 0 ? void 0 : it.title, path: it === null || it === void 0 ? void 0 : it.path }; });
|
|
142
|
-
setPaths(routes);
|
|
143
|
-
};
|
|
144
|
-
useEffect(function () {
|
|
145
|
-
getRoutesData();
|
|
146
|
-
}, [props]);
|
|
147
|
-
return (_jsxs("div", __assign({ className: "crt-pge-st col-md-12" }, { children: [_jsxs("div", __assign({ className: "form-group" }, { children: [_jsx("label", { children: "Unique Identifier Name" }), _jsx("input", { type: 'text', name: "name", className: "form-control", onChange: function (e) {
|
|
148
|
-
var _a;
|
|
149
|
-
return setData(__assign(__assign({}, data), (_a = {}, _a[e.target.name] = e.target.value, _a)));
|
|
150
|
-
} })] })), ((_a = data === null || data === void 0 ? void 0 : data.menu) === null || _a === void 0 ? void 0 : _a.length) > 0 && _jsx("ul", __assign({ className: "list-unstyled dy-mn" }, { children: (_b = data === null || data === void 0 ? void 0 : data.menu) === null || _b === void 0 ? void 0 : _b.map(function (item, i) {
|
|
151
|
-
var _a, _b;
|
|
152
|
-
return (_jsxs("li", __assign({ className: "d-flex flex-wrap justify-content-between align-items-center" }, { children: [_jsxs("div", __assign({ className: "add-icons" }, { children: [_jsx(FontAwesomeIcon, { className: "icon", icon: faPlusSquare, cursor: 'pointer', onClick: function (e) { return AddNewRow(e); } }), _jsx(FontAwesomeIcon, { className: "icon", icon: faPlusSquare, cursor: 'pointer', style: { marginLeft: 5 }, onClick: function (e) { return AddNewSubRow(e, i); } })] })), renderHtml(i, 0, 'Menu'), ((_a = item === null || item === void 0 ? void 0 : item.subMenu) === null || _a === void 0 ? void 0 : _a.length) > 0 && _jsx("ul", __assign({ className: "dy-mn" }, { children: (_b = item === null || item === void 0 ? void 0 : item.subMenu) === null || _b === void 0 ? void 0 : _b.map(function (sm, s) { return (_jsxs("li", __assign({ className: "d-flex flex-wrap justify-content-between align-items-center" }, { children: [_jsx(FontAwesomeIcon, { className: "icon", icon: faPlusSquare, cursor: 'pointer', style: { marginLeft: 5 }, onClick: function (e) { return AddNewSubRow(e, i); } }), renderHtml(i, s, 'Submenu')] }), s)); }) }))] }), i));
|
|
153
|
-
}) })), _jsx("div", __assign({ className: "button" }, { children: _jsx("button", __assign({ className: "btn add-btn", onClick: function (e) { return handleSubmit(e); } }, { children: "Submit" })) }))] })));
|
|
154
|
-
};
|
|
155
|
-
export default DynamicMenu;
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
22
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
23
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
24
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
25
|
+
function step(op) {
|
|
26
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
27
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
28
|
+
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;
|
|
29
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
30
|
+
switch (op[0]) {
|
|
31
|
+
case 0: case 1: t = op; break;
|
|
32
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
33
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
34
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
35
|
+
default:
|
|
36
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
37
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
38
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
39
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
40
|
+
if (t[2]) _.ops.pop();
|
|
41
|
+
_.trys.pop(); continue;
|
|
42
|
+
}
|
|
43
|
+
op = body.call(thisArg, _);
|
|
44
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
45
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
49
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
50
|
+
if (ar || !(i in from)) {
|
|
51
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
52
|
+
ar[i] = from[i];
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
56
|
+
};
|
|
57
|
+
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
58
|
+
import React, { useContext, useEffect, useState } from "react";
|
|
59
|
+
import { toast } from "react-toastify";
|
|
60
|
+
import { PopUpContext, RouteContext } from "../../../../Utility/Contexts";
|
|
61
|
+
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
|
62
|
+
import { faPlusSquare } from "@fortawesome/free-regular-svg-icons";
|
|
63
|
+
import './index.css';
|
|
64
|
+
import { createMenu } from "../../../../Services/Menu";
|
|
65
|
+
import * as Icons from '@fortawesome/free-solid-svg-icons';
|
|
66
|
+
export var DynamicMenu = function (props) {
|
|
67
|
+
var _a, _b;
|
|
68
|
+
var _c = useState({
|
|
69
|
+
name: '',
|
|
70
|
+
menu: [{
|
|
71
|
+
title: '',
|
|
72
|
+
path: '',
|
|
73
|
+
icon: '',
|
|
74
|
+
subMenu: []
|
|
75
|
+
}]
|
|
76
|
+
}), data = _c[0], setData = _c[1];
|
|
77
|
+
var _d = useContext(PopUpContext), setshowPopup = _d.setshowPopup, setMenu = _d.setMenu, menu = _d.menu;
|
|
78
|
+
var routePages = useContext(RouteContext).routePages;
|
|
79
|
+
var _e = useState([]), paths = _e[0], setPaths = _e[1];
|
|
80
|
+
var handleChange = function (e, i, p, field) {
|
|
81
|
+
var _a = e.target, name = _a.name, value = _a.value;
|
|
82
|
+
if (field === 'Submenu') {
|
|
83
|
+
data['menu'][i]['subMenu'][p][name] = value;
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
data['menu'][i][name] = value;
|
|
87
|
+
}
|
|
88
|
+
setData(__assign({}, data));
|
|
89
|
+
};
|
|
90
|
+
var AddNewRow = function (e) {
|
|
91
|
+
data['menu'] = __spreadArray(__spreadArray([], data['menu'], true), [{ title: '', path: '', subMenu: [] }], false);
|
|
92
|
+
setData(__assign({}, data));
|
|
93
|
+
};
|
|
94
|
+
var AddNewSubRow = function (e, i) {
|
|
95
|
+
data['menu'][i]['subMenu'] = __spreadArray(__spreadArray([], data['menu'][i]['subMenu'], true), [{ title: '', path: '' }], false);
|
|
96
|
+
setData(__assign({}, data));
|
|
97
|
+
};
|
|
98
|
+
var handleSubmit = function (e) { return __awaiter(void 0, void 0, void 0, function () {
|
|
99
|
+
var config, result, obj, getIds, getMaxId, error_1;
|
|
100
|
+
return __generator(this, function (_a) {
|
|
101
|
+
switch (_a.label) {
|
|
102
|
+
case 0:
|
|
103
|
+
e.preventDefault();
|
|
104
|
+
_a.label = 1;
|
|
105
|
+
case 1:
|
|
106
|
+
_a.trys.push([1, 4, , 5]);
|
|
107
|
+
if (!(data === null || data === void 0 ? void 0 : data.name)) return [3 /*break*/, 3];
|
|
108
|
+
config = {
|
|
109
|
+
method: 'POST',
|
|
110
|
+
body: JSON.stringify(data),
|
|
111
|
+
headers: __assign({ "Content-Type": "application/json" }, props === null || props === void 0 ? void 0 : props.headers)
|
|
112
|
+
};
|
|
113
|
+
return [4 /*yield*/, createMenu(props === null || props === void 0 ? void 0 : props.backendUrl, config)];
|
|
114
|
+
case 2:
|
|
115
|
+
result = _a.sent();
|
|
116
|
+
toast.success(result === null || result === void 0 ? void 0 : result.message);
|
|
117
|
+
obj = data;
|
|
118
|
+
getIds = (menu === null || menu === void 0 ? void 0 : menu.map(function (it) { return it === null || it === void 0 ? void 0 : it.id; })) || [];
|
|
119
|
+
getMaxId = (getIds === null || getIds === void 0 ? void 0 : getIds.length) > 0 ? Math.max.apply(Math, getIds) : 0;
|
|
120
|
+
obj['id'] = (result === null || result === void 0 ? void 0 : result.id) || getMaxId + 1;
|
|
121
|
+
setMenu(__spreadArray(__spreadArray([], menu, true), [obj], false));
|
|
122
|
+
setshowPopup(false);
|
|
123
|
+
_a.label = 3;
|
|
124
|
+
case 3: return [3 /*break*/, 5];
|
|
125
|
+
case 4:
|
|
126
|
+
error_1 = _a.sent();
|
|
127
|
+
toast.error(error_1 === null || error_1 === void 0 ? void 0 : error_1.toString());
|
|
128
|
+
return [3 /*break*/, 5];
|
|
129
|
+
case 5: return [2 /*return*/];
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
}); };
|
|
133
|
+
var renderHtml = function (i, p, field) {
|
|
134
|
+
var _a;
|
|
135
|
+
return (_jsxs(React.Fragment, { children: [_jsxs("div", __assign({ className: "form-group ".concat(field === 'Menu' ? 'w-25' : 'w-45') }, { children: [_jsxs("label", { children: [field, " Title (", i + 1, field === 'Submenu' && ".".concat(p + 1), ")"] }), _jsx("input", { type: "text", name: 'title', className: "form-control", onChange: function (e) { return handleChange(e, i, p, field); } })] })), _jsxs("div", __assign({ className: "form-group ".concat(field === 'Menu' ? 'w-25' : 'w-45') }, { children: [_jsxs("label", { children: [field, " Path (", i + 1, field === 'Submenu' && ".".concat(p + 1), ")"] }), _jsxs("select", __assign({ name: "path", className: "form-control", onChange: function (e) { return handleChange(e, i, p, field); } }, { children: [_jsx("option", __assign({ value: '' }, { children: "-- Select Route --" })), paths === null || paths === void 0 ? void 0 : paths.map(function (it, i) {
|
|
136
|
+
var _a;
|
|
137
|
+
return (_jsx("option", __assign({ value: it === null || it === void 0 ? void 0 : it.path }, { children: (_a = it === null || it === void 0 ? void 0 : it.title) === null || _a === void 0 ? void 0 : _a.name }), i));
|
|
138
|
+
})] }))] })), field === 'Menu' && _jsxs("div", __assign({ className: "form-group ".concat(field === 'Menu' ? 'w-25' : 'w-45') }, { children: [_jsx("label", { children: "Title Icons" }), _jsxs("select", __assign({ name: "icon", className: "form-control", onChange: function (e) { return handleChange(e, i, p, field); } }, { children: [_jsx("option", __assign({ value: '' }, { children: "-- Select Icon --" })), (_a = Object.keys(Icons)) === null || _a === void 0 ? void 0 : _a.map(function (it, i) { return (_jsx("option", __assign({ value: it }, { children: it }), i)); })] }))] }))] }));
|
|
139
|
+
};
|
|
140
|
+
var getRoutesData = function () {
|
|
141
|
+
var routes = routePages === null || routePages === void 0 ? void 0 : routePages.map(function (it) { return { id: it === null || it === void 0 ? void 0 : it.id, title: it === null || it === void 0 ? void 0 : it.title, path: it === null || it === void 0 ? void 0 : it.path }; });
|
|
142
|
+
setPaths(routes);
|
|
143
|
+
};
|
|
144
|
+
useEffect(function () {
|
|
145
|
+
getRoutesData();
|
|
146
|
+
}, [props]);
|
|
147
|
+
return (_jsxs("div", __assign({ className: "crt-pge-st col-md-12" }, { children: [_jsxs("div", __assign({ className: "form-group" }, { children: [_jsx("label", { children: "Unique Identifier Name" }), _jsx("input", { type: 'text', name: "name", className: "form-control", onChange: function (e) {
|
|
148
|
+
var _a;
|
|
149
|
+
return setData(__assign(__assign({}, data), (_a = {}, _a[e.target.name] = e.target.value, _a)));
|
|
150
|
+
} })] })), ((_a = data === null || data === void 0 ? void 0 : data.menu) === null || _a === void 0 ? void 0 : _a.length) > 0 && _jsx("ul", __assign({ className: "list-unstyled dy-mn" }, { children: (_b = data === null || data === void 0 ? void 0 : data.menu) === null || _b === void 0 ? void 0 : _b.map(function (item, i) {
|
|
151
|
+
var _a, _b;
|
|
152
|
+
return (_jsxs("li", __assign({ className: "d-flex flex-wrap justify-content-between align-items-center" }, { children: [_jsxs("div", __assign({ className: "add-icons" }, { children: [_jsx(FontAwesomeIcon, { className: "icon", icon: faPlusSquare, cursor: 'pointer', onClick: function (e) { return AddNewRow(e); } }), _jsx(FontAwesomeIcon, { className: "icon", icon: faPlusSquare, cursor: 'pointer', style: { marginLeft: 5 }, onClick: function (e) { return AddNewSubRow(e, i); } })] })), renderHtml(i, 0, 'Menu'), ((_a = item === null || item === void 0 ? void 0 : item.subMenu) === null || _a === void 0 ? void 0 : _a.length) > 0 && _jsx("ul", __assign({ className: "dy-mn" }, { children: (_b = item === null || item === void 0 ? void 0 : item.subMenu) === null || _b === void 0 ? void 0 : _b.map(function (sm, s) { return (_jsxs("li", __assign({ className: "d-flex flex-wrap justify-content-between align-items-center" }, { children: [_jsx(FontAwesomeIcon, { className: "icon", icon: faPlusSquare, cursor: 'pointer', style: { marginLeft: 5 }, onClick: function (e) { return AddNewSubRow(e, i); } }), renderHtml(i, s, 'Submenu')] }), s)); }) }))] }), i));
|
|
153
|
+
}) })), _jsx("div", __assign({ className: "button" }, { children: _jsx("button", __assign({ className: "btn add-btn", onClick: function (e) { return handleSubmit(e); } }, { children: "Submit" })) }))] })));
|
|
154
|
+
};
|
|
155
|
+
export default DynamicMenu;
|