@banch0u/core-project-test-repository 2.1.13 → 2.1.15
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.
|
@@ -8,7 +8,8 @@ import style from "./index.module.scss";
|
|
|
8
8
|
import { entryData } from "../../../pages/Platform/constant";
|
|
9
9
|
import Portal from "../../Portal";
|
|
10
10
|
var Panel = Collapse.Panel;
|
|
11
|
-
var AppSelect = function AppSelect() {
|
|
11
|
+
var AppSelect = function AppSelect(_ref) {
|
|
12
|
+
var mainPage = _ref.mainPage;
|
|
12
13
|
var location = useLocation();
|
|
13
14
|
var _useSelector = useSelector(function (state) {
|
|
14
15
|
return state.auth;
|
|
@@ -24,6 +25,9 @@ var AppSelect = function AppSelect() {
|
|
|
24
25
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
25
26
|
dropdownStyle = _useState4[0],
|
|
26
27
|
setDropdownStyle = _useState4[1];
|
|
28
|
+
|
|
29
|
+
// ✅ if mainPage is provided => disable dropdown behavior
|
|
30
|
+
var isDisabled = !!mainPage;
|
|
27
31
|
var filteredOptions = useMemo(function () {
|
|
28
32
|
return entryData.filter(function (item) {
|
|
29
33
|
return item.scopes === "account" || scopesData === "*" || (scopesData === null || scopesData === void 0 ? void 0 : scopesData.includes(item.scopes));
|
|
@@ -40,6 +44,7 @@ var AppSelect = function AppSelect() {
|
|
|
40
44
|
useEffect(function () {
|
|
41
45
|
var handleClickOutside = function handleClickOutside(e) {
|
|
42
46
|
var _dropdownRef$current;
|
|
47
|
+
if (isDisabled) return;
|
|
43
48
|
if (accordionRef.current && !accordionRef.current.contains(e.target) && !((_dropdownRef$current = dropdownRef.current) !== null && _dropdownRef$current !== void 0 && _dropdownRef$current.contains(e.target))) {
|
|
44
49
|
setActiveKey([]);
|
|
45
50
|
}
|
|
@@ -48,8 +53,9 @@ var AppSelect = function AppSelect() {
|
|
|
48
53
|
return function () {
|
|
49
54
|
return document.removeEventListener("mousedown", handleClickOutside);
|
|
50
55
|
};
|
|
51
|
-
}, []);
|
|
56
|
+
}, [isDisabled]);
|
|
52
57
|
useEffect(function () {
|
|
58
|
+
if (isDisabled) return;
|
|
53
59
|
if (activeKey.length > 0 && accordionRef.current) {
|
|
54
60
|
var rect = accordionRef.current.getBoundingClientRect();
|
|
55
61
|
setDropdownStyle({
|
|
@@ -60,36 +66,48 @@ var AppSelect = function AppSelect() {
|
|
|
60
66
|
zIndex: 9999
|
|
61
67
|
});
|
|
62
68
|
}
|
|
63
|
-
}, [activeKey]);
|
|
69
|
+
}, [activeKey, isDisabled]);
|
|
70
|
+
|
|
71
|
+
// ✅ make sure dropdown is closed if it becomes disabled
|
|
72
|
+
useEffect(function () {
|
|
73
|
+
if (isDisabled) setActiveKey([]);
|
|
74
|
+
}, [isDisabled]);
|
|
64
75
|
return /*#__PURE__*/React.createElement("div", {
|
|
65
76
|
ref: accordionRef
|
|
66
77
|
}, /*#__PURE__*/React.createElement(Collapse, {
|
|
67
78
|
bordered: false,
|
|
68
|
-
activeKey: activeKey,
|
|
79
|
+
activeKey: isDisabled ? [] : activeKey,
|
|
69
80
|
onChange: function onChange(key) {
|
|
70
|
-
|
|
81
|
+
if (isDisabled) return;
|
|
82
|
+
setActiveKey(key);
|
|
71
83
|
},
|
|
72
84
|
expandIconPosition: "end",
|
|
73
|
-
expandIcon: function expandIcon(
|
|
74
|
-
var isActive =
|
|
85
|
+
expandIcon: function expandIcon(_ref2) {
|
|
86
|
+
var isActive = _ref2.isActive;
|
|
75
87
|
return /*#__PURE__*/React.createElement("div", {
|
|
76
88
|
"data-no-invert": true
|
|
77
89
|
}, /*#__PURE__*/React.createElement(RightOutlined, {
|
|
78
90
|
style: {
|
|
79
|
-
transform: "rotate(".concat(isActive ? 270 : 90, "deg)"),
|
|
91
|
+
transform: "rotate(".concat(!isDisabled && isActive ? 270 : 90, "deg)"),
|
|
80
92
|
transition: "transform 0.2s ease",
|
|
81
93
|
color: "white",
|
|
82
|
-
fontSize: "14px"
|
|
94
|
+
fontSize: "14px",
|
|
95
|
+
opacity: isDisabled ? 0.5 : 1,
|
|
96
|
+
cursor: isDisabled ? "not-allowed" : "pointer"
|
|
83
97
|
}
|
|
84
98
|
}));
|
|
85
99
|
},
|
|
86
100
|
className: style.accordion
|
|
87
101
|
}, /*#__PURE__*/React.createElement(Panel, {
|
|
88
102
|
header: /*#__PURE__*/React.createElement("div", {
|
|
89
|
-
className: style.accordionHeader
|
|
103
|
+
className: style.accordionHeader,
|
|
104
|
+
style: {
|
|
105
|
+
opacity: isDisabled ? 0.8 : 1,
|
|
106
|
+
cursor: isDisabled ? "default" : "pointer"
|
|
107
|
+
}
|
|
90
108
|
}, baseSegment === "settings" ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(SettingOutlined, null)), /*#__PURE__*/React.createElement("span", null, "T\u0259nziml\u0259m\u0259l\u0259r")) : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", null, active === null || active === void 0 ? void 0 : active.icon), /*#__PURE__*/React.createElement("span", null, active === null || active === void 0 ? void 0 : active.value))),
|
|
91
109
|
key: "1"
|
|
92
|
-
})), activeKey.length > 0 && /*#__PURE__*/React.createElement(Portal, null, /*#__PURE__*/React.createElement("div", {
|
|
110
|
+
})), !isDisabled && activeKey.length > 0 && /*#__PURE__*/React.createElement(Portal, null, /*#__PURE__*/React.createElement("div", {
|
|
93
111
|
"data-no-invert": true,
|
|
94
112
|
ref: dropdownRef,
|
|
95
113
|
className: style.accordionBody,
|
|
@@ -5,12 +5,18 @@ import ProfileOptions from "../../components/ProfileOptions";
|
|
|
5
5
|
import AppSelect from "./AppSelect";
|
|
6
6
|
import { useDispatch } from "react-redux";
|
|
7
7
|
import { getLoginType } from "../../store/slices/auth";
|
|
8
|
+
import { getCompanyInfo } from "../../store/slices/companyInfo";
|
|
9
|
+
import { useSelector } from "react-redux";
|
|
8
10
|
var Header = function Header() {
|
|
11
|
+
var _companyInfo$;
|
|
9
12
|
var _useState = useState(localStorage.getItem("theme") || "light"),
|
|
10
13
|
_useState2 = _slicedToArray(_useState, 2),
|
|
11
14
|
theme = _useState2[0],
|
|
12
15
|
setTheme = _useState2[1];
|
|
13
16
|
var dispatch = useDispatch();
|
|
17
|
+
var companyInfo = useSelector(function (state) {
|
|
18
|
+
return state.companyInfo.companyInfo;
|
|
19
|
+
});
|
|
14
20
|
var updateTheme = function updateTheme() {
|
|
15
21
|
var newTheme = localStorage.getItem("theme") || "light";
|
|
16
22
|
setTheme(newTheme);
|
|
@@ -23,10 +29,13 @@ var Header = function Header() {
|
|
|
23
29
|
}, []);
|
|
24
30
|
useEffect(function () {
|
|
25
31
|
dispatch(getLoginType());
|
|
32
|
+
dispatch(getCompanyInfo());
|
|
26
33
|
}, [dispatch]);
|
|
27
34
|
return /*#__PURE__*/React.createElement("header", {
|
|
28
35
|
className: style.header,
|
|
29
36
|
"data-no-invert": true
|
|
30
|
-
}, /*#__PURE__*/React.createElement(AppSelect,
|
|
37
|
+
}, /*#__PURE__*/React.createElement(AppSelect, {
|
|
38
|
+
mainPage: companyInfo === null || companyInfo === void 0 || (_companyInfo$ = companyInfo[0]) === null || _companyInfo$ === void 0 ? void 0 : _companyInfo$.mainPage
|
|
39
|
+
}), /*#__PURE__*/React.createElement(ProfileOptions, null));
|
|
31
40
|
};
|
|
32
41
|
export default Header;
|
|
@@ -9,7 +9,6 @@ import { Layout, Menu } from "antd";
|
|
|
9
9
|
import { DsgLogo, DsgLogoEmblem } from "../../assets/icons";
|
|
10
10
|
import { PLATFORM_PATH } from "../../utils/path";
|
|
11
11
|
import { useDispatch, useSelector } from "react-redux";
|
|
12
|
-
import { getCompanyInfo } from "../../store/slices/companyInfo";
|
|
13
12
|
import api from "../../utils/axios";
|
|
14
13
|
var Sider = Layout.Sider;
|
|
15
14
|
var Sidebar = function Sidebar(_ref) {
|
|
@@ -69,26 +68,26 @@ var Sidebar = function Sidebar(_ref) {
|
|
|
69
68
|
useEffect(function () {
|
|
70
69
|
var sidebarState = Cookies.get("sidebarCollapsed") === "true";
|
|
71
70
|
setCollapsed(sidebarState);
|
|
72
|
-
dispatch(getCompanyInfo());
|
|
73
71
|
}, [dispatch]);
|
|
74
72
|
useEffect(function () {
|
|
75
73
|
var fetchLogo = /*#__PURE__*/function () {
|
|
76
74
|
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
77
|
-
var _companyInfo
|
|
78
|
-
var base64;
|
|
75
|
+
var _companyInfo$, _companyInfo$data;
|
|
76
|
+
var filePath, base64;
|
|
79
77
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
80
78
|
while (1) switch (_context2.prev = _context2.next) {
|
|
81
79
|
case 0:
|
|
82
|
-
|
|
83
|
-
|
|
80
|
+
filePath = (companyInfo === null || companyInfo === void 0 || (_companyInfo$ = companyInfo[0]) === null || _companyInfo$ === void 0 ? void 0 : _companyInfo$.filePath) || (companyInfo === null || companyInfo === void 0 || (_companyInfo$data = companyInfo.data) === null || _companyInfo$data === void 0 || (_companyInfo$data = _companyInfo$data[0]) === null || _companyInfo$data === void 0 ? void 0 : _companyInfo$data.filePath);
|
|
81
|
+
if (!filePath) {
|
|
82
|
+
_context2.next = 6;
|
|
84
83
|
break;
|
|
85
84
|
}
|
|
86
|
-
_context2.next =
|
|
87
|
-
return getBase64FromURL(
|
|
88
|
-
case
|
|
85
|
+
_context2.next = 4;
|
|
86
|
+
return getBase64FromURL(filePath);
|
|
87
|
+
case 4:
|
|
89
88
|
base64 = _context2.sent;
|
|
90
89
|
setImageSrc(base64);
|
|
91
|
-
case
|
|
90
|
+
case 6:
|
|
92
91
|
case "end":
|
|
93
92
|
return _context2.stop();
|
|
94
93
|
}
|
|
@@ -110,6 +109,12 @@ var Sidebar = function Sidebar(_ref) {
|
|
|
110
109
|
};
|
|
111
110
|
}, []);
|
|
112
111
|
|
|
112
|
+
// ✅ if mainPage exists -> logo should NOT be a link
|
|
113
|
+
var hasMainPage = useMemo(function () {
|
|
114
|
+
var _companyInfo$2, _companyInfo$data2;
|
|
115
|
+
return !!(companyInfo !== null && companyInfo !== void 0 && (_companyInfo$2 = companyInfo[0]) !== null && _companyInfo$2 !== void 0 && _companyInfo$2.mainPage || companyInfo !== null && companyInfo !== void 0 && (_companyInfo$data2 = companyInfo.data) !== null && _companyInfo$data2 !== void 0 && (_companyInfo$data2 = _companyInfo$data2[0]) !== null && _companyInfo$data2 !== void 0 && _companyInfo$data2.mainPage);
|
|
116
|
+
}, [companyInfo]);
|
|
117
|
+
|
|
113
118
|
// --- FIX: compute selectedKey by exact segment match OR full-path prefix match, prefer the longest match
|
|
114
119
|
var flatItems = useMemo(function () {
|
|
115
120
|
var _flatten = function flatten(arr) {
|
|
@@ -147,6 +152,15 @@ var Sidebar = function Sidebar(_ref) {
|
|
|
147
152
|
});
|
|
148
153
|
return matches[0]; // undefined if none
|
|
149
154
|
}, [location.pathname, flatItems]);
|
|
155
|
+
|
|
156
|
+
// ✅ choose wrapper element (Link or div)
|
|
157
|
+
var LogoWrapper = hasMainPage ? "div" : Link;
|
|
158
|
+
var logoWrapperProps = hasMainPage ? {
|
|
159
|
+
className: style.buttons
|
|
160
|
+
} : {
|
|
161
|
+
to: PLATFORM_PATH,
|
|
162
|
+
className: style.buttons
|
|
163
|
+
};
|
|
150
164
|
return /*#__PURE__*/React.createElement(Sider, {
|
|
151
165
|
width: 287,
|
|
152
166
|
collapsible: true,
|
|
@@ -161,10 +175,7 @@ var Sidebar = function Sidebar(_ref) {
|
|
|
161
175
|
items: items,
|
|
162
176
|
selectedKeys: selectedKey ? [selectedKey] : [],
|
|
163
177
|
className: style.menu
|
|
164
|
-
})), /*#__PURE__*/React.createElement(
|
|
165
|
-
to: PLATFORM_PATH,
|
|
166
|
-
className: style.buttons
|
|
167
|
-
}, collapsed ? /*#__PURE__*/React.createElement("div", {
|
|
178
|
+
})), /*#__PURE__*/React.createElement(LogoWrapper, logoWrapperProps, collapsed ? /*#__PURE__*/React.createElement("div", {
|
|
168
179
|
className: style.emblem
|
|
169
180
|
}, /*#__PURE__*/React.createElement(DsgLogoEmblem, null)) : imageSrc ? /*#__PURE__*/React.createElement("img", {
|
|
170
181
|
src: imageSrc,
|
|
@@ -35,12 +35,14 @@ var Login = function Login() {
|
|
|
35
35
|
imageSrc = _useState2[0],
|
|
36
36
|
setImageSrc = _useState2[1];
|
|
37
37
|
var loginValue = useCallback(function (formdata) {
|
|
38
|
+
var _companyInfo$;
|
|
38
39
|
var data = {
|
|
39
40
|
formdata: formdata,
|
|
40
|
-
navigate: navigate
|
|
41
|
+
navigate: navigate,
|
|
42
|
+
mainPage: companyInfo === null || companyInfo === void 0 || (_companyInfo$ = companyInfo[0]) === null || _companyInfo$ === void 0 ? void 0 : _companyInfo$.mainPage
|
|
41
43
|
};
|
|
42
44
|
dispatch(login(data));
|
|
43
|
-
}, [dispatch, navigate]);
|
|
45
|
+
}, [dispatch, navigate, companyInfo]);
|
|
44
46
|
var getBase64FromURL = useCallback(/*#__PURE__*/function () {
|
|
45
47
|
var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(url) {
|
|
46
48
|
var res;
|
|
@@ -74,12 +76,12 @@ var Login = function Login() {
|
|
|
74
76
|
useEffect(function () {
|
|
75
77
|
var fetchImage = /*#__PURE__*/function () {
|
|
76
78
|
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
77
|
-
var _companyInfo
|
|
79
|
+
var _companyInfo$2;
|
|
78
80
|
var base64;
|
|
79
81
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
80
82
|
while (1) switch (_context2.prev = _context2.next) {
|
|
81
83
|
case 0:
|
|
82
|
-
if (!(companyInfo !== null && companyInfo !== void 0 && (_companyInfo$ = companyInfo[0]) !== null && _companyInfo$ !== void 0 && _companyInfo
|
|
84
|
+
if (!(companyInfo !== null && companyInfo !== void 0 && (_companyInfo$2 = companyInfo[0]) !== null && _companyInfo$2 !== void 0 && _companyInfo$2.filePath)) {
|
|
83
85
|
_context2.next = 5;
|
|
84
86
|
break;
|
|
85
87
|
}
|
|
@@ -52,7 +52,11 @@ export var login = createAsyncThunk("/login", /*#__PURE__*/function () {
|
|
|
52
52
|
localStorage.setItem("refreshToken", response === null || response === void 0 ? void 0 : response.data.refreshToken);
|
|
53
53
|
succesMessage("Sistemə daxil olunur...");
|
|
54
54
|
dispatch(setLoading(false));
|
|
55
|
-
data
|
|
55
|
+
if (data !== null && data !== void 0 && data.mainPage) {
|
|
56
|
+
window.location.href = data === null || data === void 0 ? void 0 : data.mainPage;
|
|
57
|
+
} else {
|
|
58
|
+
data === null || data === void 0 || data.navigate(PLATFORM_PATH);
|
|
59
|
+
}
|
|
56
60
|
return _context2.abrupt("return", response === null || response === void 0 ? void 0 : response.data);
|
|
57
61
|
case 14:
|
|
58
62
|
_context2.prev = 14;
|