phx-react 1.3.1287 → 1.3.1289
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/dist/cjs/components/MainWrapV4/MainWrapV4.d.ts +30 -0
- package/dist/cjs/components/MainWrapV4/MainWrapV4.js +879 -0
- package/dist/cjs/components/MainWrapV4/MainWrapV4.js.map +1 -0
- package/dist/cjs/components/MainWrapV4/appearance/appearance-styled.d.ts +8 -0
- package/dist/cjs/components/MainWrapV4/appearance/appearance-styled.js +42 -0
- package/dist/cjs/components/MainWrapV4/appearance/appearance-styled.js.map +1 -0
- package/dist/cjs/components/MainWrapV4/assets/Icon.d.ts +97 -0
- package/dist/cjs/components/MainWrapV4/assets/Icon.js +197 -0
- package/dist/cjs/components/MainWrapV4/assets/Icon.js.map +1 -0
- package/dist/cjs/components/MainWrapV4/components/nav-item.d.ts +11 -0
- package/dist/cjs/components/MainWrapV4/components/nav-item.js +30 -0
- package/dist/cjs/components/MainWrapV4/components/nav-item.js.map +1 -0
- package/dist/cjs/components/MainWrapV4/components/other-menu.d.ts +8 -0
- package/dist/cjs/components/MainWrapV4/components/other-menu.js +145 -0
- package/dist/cjs/components/MainWrapV4/components/other-menu.js.map +1 -0
- package/dist/cjs/components/MainWrapV4/components/side-bar.d.ts +13 -0
- package/dist/cjs/components/MainWrapV4/components/side-bar.js +123 -0
- package/dist/cjs/components/MainWrapV4/components/side-bar.js.map +1 -0
- package/dist/cjs/components/MainWrapV4/constant.d.ts +5 -0
- package/dist/cjs/components/MainWrapV4/constant.js +10 -0
- package/dist/cjs/components/MainWrapV4/constant.js.map +1 -0
- package/dist/cjs/components/MainWrapV4/index.d.ts +1 -0
- package/dist/cjs/components/MainWrapV4/index.js +5 -0
- package/dist/cjs/components/MainWrapV4/index.js.map +1 -0
- package/dist/cjs/components/MainWrapV4/navigator/nav-mobile-content.d.ts +2 -0
- package/dist/cjs/components/MainWrapV4/navigator/nav-mobile-content.js +118 -0
- package/dist/cjs/components/MainWrapV4/navigator/nav-mobile-content.js.map +1 -0
- package/dist/cjs/components/MainWrapV4/navigator/nav-mobile.d.ts +2 -0
- package/dist/cjs/components/MainWrapV4/navigator/nav-mobile.js +28 -0
- package/dist/cjs/components/MainWrapV4/navigator/nav-mobile.js.map +1 -0
- package/dist/cjs/components/MainWrapV4/svg.d.ts +5 -0
- package/dist/cjs/components/MainWrapV4/svg.js +2 -0
- package/dist/cjs/components/MainWrapV4/svg.js.map +1 -0
- package/dist/cjs/components/MainWrapV4/types/appearance.d.ts +19 -0
- package/dist/cjs/components/MainWrapV4/types/appearance.js +3 -0
- package/dist/cjs/components/MainWrapV4/types/appearance.js.map +1 -0
- package/dist/cjs/components/MainWrapV4/types/index.d.ts +9 -0
- package/dist/cjs/components/MainWrapV4/types/index.js +3 -0
- package/dist/cjs/components/MainWrapV4/types/index.js.map +1 -0
- package/dist/cjs/components/TableV3/HeaderTable.js +1 -1
- package/dist/cjs/components/TableV3/HeaderTable.js.map +1 -1
- package/dist/cjs/components/TableV3/RowTable.js +1 -1
- package/dist/cjs/components/TableV3/RowTable.js.map +1 -1
- package/dist/cjs/index.d.ts +2 -1
- package/dist/cjs/index.js +4 -2
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/components/MainWrapV4/MainWrapV4.d.ts +30 -0
- package/dist/esm/components/MainWrapV4/MainWrapV4.js +875 -0
- package/dist/esm/components/MainWrapV4/MainWrapV4.js.map +1 -0
- package/dist/esm/components/MainWrapV4/appearance/appearance-styled.d.ts +8 -0
- package/dist/esm/components/MainWrapV4/appearance/appearance-styled.js +39 -0
- package/dist/esm/components/MainWrapV4/appearance/appearance-styled.js.map +1 -0
- package/dist/esm/components/MainWrapV4/assets/Icon.d.ts +97 -0
- package/dist/esm/components/MainWrapV4/assets/Icon.js +193 -0
- package/dist/esm/components/MainWrapV4/assets/Icon.js.map +1 -0
- package/dist/esm/components/MainWrapV4/components/nav-item.d.ts +11 -0
- package/dist/esm/components/MainWrapV4/components/nav-item.js +26 -0
- package/dist/esm/components/MainWrapV4/components/nav-item.js.map +1 -0
- package/dist/esm/components/MainWrapV4/components/other-menu.d.ts +8 -0
- package/dist/esm/components/MainWrapV4/components/other-menu.js +141 -0
- package/dist/esm/components/MainWrapV4/components/other-menu.js.map +1 -0
- package/dist/esm/components/MainWrapV4/components/side-bar.d.ts +13 -0
- package/dist/esm/components/MainWrapV4/components/side-bar.js +120 -0
- package/dist/esm/components/MainWrapV4/components/side-bar.js.map +1 -0
- package/dist/esm/components/MainWrapV4/constant.d.ts +5 -0
- package/dist/esm/components/MainWrapV4/constant.js +7 -0
- package/dist/esm/components/MainWrapV4/constant.js.map +1 -0
- package/dist/esm/components/MainWrapV4/index.d.ts +1 -0
- package/dist/esm/components/MainWrapV4/index.js +2 -0
- package/dist/esm/components/MainWrapV4/index.js.map +1 -0
- package/dist/esm/components/MainWrapV4/navigator/nav-mobile-content.d.ts +2 -0
- package/dist/esm/components/MainWrapV4/navigator/nav-mobile-content.js +115 -0
- package/dist/esm/components/MainWrapV4/navigator/nav-mobile-content.js.map +1 -0
- package/dist/esm/components/MainWrapV4/navigator/nav-mobile.d.ts +2 -0
- package/dist/esm/components/MainWrapV4/navigator/nav-mobile.js +24 -0
- package/dist/esm/components/MainWrapV4/navigator/nav-mobile.js.map +1 -0
- package/dist/esm/components/MainWrapV4/svg.d.ts +5 -0
- package/dist/esm/components/MainWrapV4/svg.js +2 -0
- package/dist/esm/components/MainWrapV4/svg.js.map +1 -0
- package/dist/esm/components/MainWrapV4/types/appearance.d.ts +19 -0
- package/dist/esm/components/MainWrapV4/types/appearance.js +2 -0
- package/dist/esm/components/MainWrapV4/types/appearance.js.map +1 -0
- package/dist/esm/components/MainWrapV4/types/index.d.ts +9 -0
- package/dist/esm/components/MainWrapV4/types/index.js +2 -0
- package/dist/esm/components/MainWrapV4/types/index.js.map +1 -0
- package/dist/esm/components/TableV3/HeaderTable.js +1 -1
- package/dist/esm/components/TableV3/HeaderTable.js.map +1 -1
- package/dist/esm/components/TableV3/RowTable.js +1 -1
- package/dist/esm/components/TableV3/RowTable.js.map +1 -1
- package/dist/esm/index.d.ts +2 -1
- package/dist/esm/index.js +2 -1
- package/dist/esm/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,879 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PHXMainWrapV4 = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var fontawesome_svg_core_1 = require("@fortawesome/fontawesome-svg-core");
|
|
6
|
+
var free_solid_svg_icons_1 = require("@fortawesome/free-solid-svg-icons");
|
|
7
|
+
var react_1 = require("@headlessui/react");
|
|
8
|
+
var solid_1 = require("@heroicons/react/20/solid");
|
|
9
|
+
var outline_1 = require("@heroicons/react/24/outline");
|
|
10
|
+
var solid_2 = require("@heroicons/react/24/solid");
|
|
11
|
+
var axios_1 = tslib_1.__importDefault(require("axios"));
|
|
12
|
+
var js_cookie_1 = tslib_1.__importDefault(require("js-cookie"));
|
|
13
|
+
var image_1 = tslib_1.__importDefault(require("next/image"));
|
|
14
|
+
var react_2 = tslib_1.__importStar(require("react"));
|
|
15
|
+
var clientQueryV3_1 = tslib_1.__importDefault(require("../Func/clientQueryV3"));
|
|
16
|
+
var getCookieSession_1 = tslib_1.__importDefault(require("../Func/getCookieSession"));
|
|
17
|
+
var getEnvPublic_1 = tslib_1.__importDefault(require("../Func/getEnvPublic"));
|
|
18
|
+
var sessionStore_1 = require("../Func/sessionStore");
|
|
19
|
+
var constants_1 = require("../../utils/constants");
|
|
20
|
+
var appearance_styled_1 = tslib_1.__importDefault(require("./appearance/appearance-styled"));
|
|
21
|
+
var Icon_1 = require("./assets/Icon");
|
|
22
|
+
var side_bar_1 = tslib_1.__importDefault(require("./components/side-bar"));
|
|
23
|
+
var nav_mobile_1 = tslib_1.__importDefault(require("./navigator/nav-mobile"));
|
|
24
|
+
var LoadingProvider_1 = require("../LoadingProvider");
|
|
25
|
+
var query_1 = require("../../query");
|
|
26
|
+
var saveCookiesClient_1 = tslib_1.__importDefault(require("../Func/saveCookiesClient"));
|
|
27
|
+
var page_tracker_1 = require("../../stores/page-tracker/page-tracker");
|
|
28
|
+
var helpers_1 = require("../../helpers/helpers");
|
|
29
|
+
var Skeleton_1 = require("../Skeleton");
|
|
30
|
+
var Modal_1 = require("../Modal");
|
|
31
|
+
var ToolTip_1 = tslib_1.__importDefault(require("../ToolTip/ToolTip"));
|
|
32
|
+
var Banner_1 = require("../Banner");
|
|
33
|
+
var types_1 = require("../types");
|
|
34
|
+
var Card_1 = require("../Card");
|
|
35
|
+
fontawesome_svg_core_1.library.add(free_solid_svg_icons_1.fas);
|
|
36
|
+
var PHXMainWrapV4 = function (_a) {
|
|
37
|
+
var _b, _c, _d;
|
|
38
|
+
var children = _a.children, getDataCookies = _a.getDataCookies, _e = _a.logoHeight, logoHeight = _e === void 0 ? '28px' : _e, _f = _a.multipleMenu, multipleMenu = _f === void 0 ? false : _f, params = _a.params, pathName = _a.pathName, router = _a.router;
|
|
39
|
+
var pid = (params ? params : {}).pid;
|
|
40
|
+
var _g = (0, react_2.useState)(false), modal = _g[0], setModal = _g[1];
|
|
41
|
+
var _h = (0, react_2.useState)(true), setOpenSubMenu = _h[1];
|
|
42
|
+
var _j = (0, react_2.useState)(''), campaignName = _j[0], setCampaignName = _j[1];
|
|
43
|
+
var _k = (0, react_2.useState)(false), sidebarOpen = _k[0], setSidebarOpen = _k[1];
|
|
44
|
+
var _l = (0, react_2.useState)([]), subNavigation = _l[0], setSubNavigation = _l[1];
|
|
45
|
+
var _m = (0, react_2.useState)([]), navigation = _m[0], setNavigation = _m[1];
|
|
46
|
+
var _o = (0, react_2.useState)(false), modalSignOut = _o[0], setModalSignOut = _o[1];
|
|
47
|
+
var _p = (0, react_2.useState)(true), showBanner = _p[0], setShowBanner = _p[1];
|
|
48
|
+
var _q = (0, react_2.useState)(true), isLoading = _q[0], setIsLoading = _q[1];
|
|
49
|
+
var sessionCookie = (0, react_2.useRef)((0, getCookieSession_1.default)());
|
|
50
|
+
var userSessionInfo = (_b = sessionCookie.current) === null || _b === void 0 ? void 0 : _b.user_info;
|
|
51
|
+
var schoolInfoId = userSessionInfo === null || userSessionInfo === void 0 ? void 0 : userSessionInfo.school_id;
|
|
52
|
+
var userId = userSessionInfo === null || userSessionInfo === void 0 ? void 0 : userSessionInfo.id;
|
|
53
|
+
var setGlobalLoading = (0, LoadingProvider_1.useLoading)().setLoading;
|
|
54
|
+
var _r = (0, react_2.useState)(true), showSubMenu = _r[0], setShowSubMenu = _r[1];
|
|
55
|
+
var _s = (0, react_2.useState)({
|
|
56
|
+
menuDefault: [],
|
|
57
|
+
loadingMenu: true,
|
|
58
|
+
loadingSchool: true,
|
|
59
|
+
listSchool: [],
|
|
60
|
+
logo: {
|
|
61
|
+
path: '',
|
|
62
|
+
height: logoHeight,
|
|
63
|
+
},
|
|
64
|
+
menu: [],
|
|
65
|
+
schoolId: null,
|
|
66
|
+
configLayout: undefined,
|
|
67
|
+
perCode: [],
|
|
68
|
+
roleCode: [],
|
|
69
|
+
isLoadingPermission: true,
|
|
70
|
+
sourceAvatar: ((_c = userSessionInfo === null || userSessionInfo === void 0 ? void 0 : userSessionInfo.user_avatar) === null || _c === void 0 ? void 0 : _c.size_small) || (userSessionInfo === null || userSessionInfo === void 0 ? void 0 : userSessionInfo.avatar) || constants_1.DEFAULT_AVATAR,
|
|
71
|
+
}), dataInitMain = _s[0], setDataInitMain = _s[1];
|
|
72
|
+
var locationPathname = typeof window !== 'undefined' ? window.location.pathname : '';
|
|
73
|
+
var locationArr = locationPathname.split('/').filter(Boolean);
|
|
74
|
+
var basePath = locationArr.slice(0, locationArr.length - pathName.split('/').filter(Boolean).length).join('/');
|
|
75
|
+
var pathNameWithBasePath = "".concat(basePath ? "".concat('/' + basePath) : '').concat(pathName);
|
|
76
|
+
function enablePer(code, arr) {
|
|
77
|
+
if (!code)
|
|
78
|
+
return true;
|
|
79
|
+
return arr === null || arr === void 0 ? void 0 : arr.some(function (item) { return item === code; });
|
|
80
|
+
}
|
|
81
|
+
// Lấy code phân quyền trong menu từ path hiện tại
|
|
82
|
+
function getCodesByPath(dataMenu, currentPath) {
|
|
83
|
+
var lastMatchingCode = null;
|
|
84
|
+
var normalizedPath = currentPath.replace(/\/$/, '');
|
|
85
|
+
function traverse(items, prefix) {
|
|
86
|
+
for (var _i = 0, items_1 = items; _i < items_1.length; _i++) {
|
|
87
|
+
var item = items_1[_i];
|
|
88
|
+
var fullPath = item.path.startsWith('/') ? prefix + item.path : item.path;
|
|
89
|
+
var normalizedFullPath = fullPath.replace(/\/$/, '');
|
|
90
|
+
if (normalizedPath === normalizedFullPath || normalizedPath.startsWith(normalizedFullPath + '/')) {
|
|
91
|
+
lastMatchingCode = item.code;
|
|
92
|
+
}
|
|
93
|
+
if (item.child) {
|
|
94
|
+
traverse(item.child, prefix);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
for (var _i = 0, dataMenu_1 = dataMenu; _i < dataMenu_1.length; _i++) {
|
|
99
|
+
var rootItem = dataMenu_1[_i];
|
|
100
|
+
var rootPath = rootItem.path;
|
|
101
|
+
var prefix = rootPath.split('/').slice(0, 2).join('/');
|
|
102
|
+
traverse([rootItem], prefix);
|
|
103
|
+
}
|
|
104
|
+
return lastMatchingCode ? lastMatchingCode : null;
|
|
105
|
+
}
|
|
106
|
+
// code phân quyền path hiện tại
|
|
107
|
+
var currentCode = getCodesByPath(dataInitMain.menuDefault, locationPathname);
|
|
108
|
+
var currentMenuByPath = navigation === null || navigation === void 0 ? void 0 : navigation.find(function (nav) { var _a; return (_a = nav === null || nav === void 0 ? void 0 : nav.child) === null || _a === void 0 ? void 0 : _a.some(function (c) { var _a; return (c === null || c === void 0 ? void 0 : c.code) === currentCode || ((_a = c === null || c === void 0 ? void 0 : c.child) === null || _a === void 0 ? void 0 : _a.some(function (x) { return (x === null || x === void 0 ? void 0 : x.code) === currentCode; })); }); });
|
|
109
|
+
var requireLoginValidation = function () {
|
|
110
|
+
(0, sessionStore_1.clearSession)();
|
|
111
|
+
var currentURL = window.location.href;
|
|
112
|
+
var url = currentURL.split('/');
|
|
113
|
+
var loginPush = "".concat(url[0], "//").concat(url[2], "/login-sso");
|
|
114
|
+
window.location.replace(loginPush);
|
|
115
|
+
};
|
|
116
|
+
var checkIsQuitJob = function (_a) {
|
|
117
|
+
var profileStaff = _a.profileStaff, profileTeacher = _a.profileTeacher;
|
|
118
|
+
try {
|
|
119
|
+
// xóa cookies với những tài khoản giáo viên, nhân viên đã nghỉ việc
|
|
120
|
+
var staffIsQuitJob = profileStaff === null || profileStaff === void 0 ? void 0 : profileStaff.is_quit_job;
|
|
121
|
+
var teacherIsQuitJob = profileTeacher === null || profileTeacher === void 0 ? void 0 : profileTeacher.is_quit_job;
|
|
122
|
+
if (staffIsQuitJob || teacherIsQuitJob) {
|
|
123
|
+
console.log('Phiên đăng nhập đã hết hạn');
|
|
124
|
+
Object.keys(js_cookie_1.default.get()).forEach(function (cookieName) {
|
|
125
|
+
js_cookie_1.default.remove(cookieName);
|
|
126
|
+
});
|
|
127
|
+
requireLoginValidation();
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
catch (error) {
|
|
131
|
+
console.log(error);
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
var fetchDataPer = function () { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
|
135
|
+
var res, userPermissions, rolePermissions, allPermissions, permissionCodes, routePermissions, actionPermissions, actionPermissionMap, uniqueRoutePermissions, error_1;
|
|
136
|
+
var _a, _b, _c, _d;
|
|
137
|
+
return tslib_1.__generator(this, function (_e) {
|
|
138
|
+
switch (_e.label) {
|
|
139
|
+
case 0:
|
|
140
|
+
_e.trys.push([0, 2, , 3]);
|
|
141
|
+
return [4 /*yield*/, (0, clientQueryV3_1.default)({
|
|
142
|
+
query: query_1.GET_PERMISSION_DETAIL_USER_V3,
|
|
143
|
+
variables: { id: userId, school_id: schoolInfoId },
|
|
144
|
+
})];
|
|
145
|
+
case 1:
|
|
146
|
+
res = _e.sent();
|
|
147
|
+
userPermissions = (_b = (_a = res.data) === null || _a === void 0 ? void 0 : _a.permission_user) !== null && _b !== void 0 ? _b : [];
|
|
148
|
+
rolePermissions = (_d = (_c = res.data) === null || _c === void 0 ? void 0 : _c.permission_role) !== null && _d !== void 0 ? _d : [];
|
|
149
|
+
allPermissions = tslib_1.__spreadArray(tslib_1.__spreadArray([], userPermissions, true), rolePermissions, true);
|
|
150
|
+
permissionCodes = allPermissions.map(function (p) { return p.permission; });
|
|
151
|
+
routePermissions = permissionCodes.filter(function (p) { return !p.is_action; }).map(function (p) { return p.code; });
|
|
152
|
+
actionPermissions = permissionCodes.filter(function (p) { return p.is_action; }).map(function (p) { return p.code; });
|
|
153
|
+
actionPermissionMap = Object.fromEntries(actionPermissions.map(function (code) { return [code, true]; }));
|
|
154
|
+
uniqueRoutePermissions = Array.from(new Set(routePermissions));
|
|
155
|
+
return [2 /*return*/, { uniqueRoutePermissions: uniqueRoutePermissions, actionPermissionMap: actionPermissionMap }];
|
|
156
|
+
case 2:
|
|
157
|
+
error_1 = _e.sent();
|
|
158
|
+
console.error('Error fetching school data:', error_1);
|
|
159
|
+
return [2 /*return*/, { uniqueRoutePermissions: null, actionPermissionMap: null }];
|
|
160
|
+
case 3: return [2 /*return*/];
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
}); };
|
|
164
|
+
var getProfileByUser = function () { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
|
165
|
+
var response, profileUser, avatar, email, full_name, profile_staff, profile_teacher, user_avatar, user_roles, error_2;
|
|
166
|
+
return tslib_1.__generator(this, function (_a) {
|
|
167
|
+
switch (_a.label) {
|
|
168
|
+
case 0:
|
|
169
|
+
_a.trys.push([0, 2, , 3]);
|
|
170
|
+
return [4 /*yield*/, (0, clientQueryV3_1.default)({
|
|
171
|
+
query: query_1.QUERY_GET_PROFILE_USER,
|
|
172
|
+
variables: {
|
|
173
|
+
user_id: userId,
|
|
174
|
+
},
|
|
175
|
+
})];
|
|
176
|
+
case 1:
|
|
177
|
+
response = _a.sent();
|
|
178
|
+
profileUser = response.data.users_by_pk;
|
|
179
|
+
avatar = profileUser.avatar, email = profileUser.email, full_name = profileUser.full_name, profile_staff = profileUser.profile_staff, profile_teacher = profileUser.profile_teacher, user_avatar = profileUser.user_avatar, user_roles = profileUser.user_roles;
|
|
180
|
+
// check user is quit job
|
|
181
|
+
checkIsQuitJob({
|
|
182
|
+
profileStaff: profile_staff,
|
|
183
|
+
profileTeacher: profile_teacher,
|
|
184
|
+
});
|
|
185
|
+
// renew list role in cookie
|
|
186
|
+
return [2 /*return*/, {
|
|
187
|
+
avatar: avatar,
|
|
188
|
+
user_avatar: user_avatar,
|
|
189
|
+
full_name: full_name,
|
|
190
|
+
email: email,
|
|
191
|
+
user_code: (profile_staff === null || profile_staff === void 0 ? void 0 : profile_staff.user_code) || (profile_teacher === null || profile_teacher === void 0 ? void 0 : profile_teacher.user_code) || '',
|
|
192
|
+
user_roles: user_roles,
|
|
193
|
+
}];
|
|
194
|
+
case 2:
|
|
195
|
+
error_2 = _a.sent();
|
|
196
|
+
console.log(error_2);
|
|
197
|
+
return [2 /*return*/];
|
|
198
|
+
case 3: return [2 /*return*/];
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
}); };
|
|
202
|
+
var fetchDataSchool = function () { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
|
203
|
+
var id, _a, group_id, school_name_id, school_id, settingSiteDb, res, dataSchool, settingFetchData, cleanedJsonString, error_3;
|
|
204
|
+
var _b, _c, _d, _e;
|
|
205
|
+
return tslib_1.__generator(this, function (_f) {
|
|
206
|
+
switch (_f.label) {
|
|
207
|
+
case 0:
|
|
208
|
+
if (!userSessionInfo)
|
|
209
|
+
return [2 /*return*/];
|
|
210
|
+
id = userSessionInfo.id, _a = userSessionInfo.school, group_id = _a.school_name.group_id, school_name_id = _a.school_name_id, school_id = userSessionInfo.school_id;
|
|
211
|
+
setIsLoading(true);
|
|
212
|
+
settingSiteDb = undefined;
|
|
213
|
+
_f.label = 1;
|
|
214
|
+
case 1:
|
|
215
|
+
_f.trys.push([1, 3, , 4]);
|
|
216
|
+
return [4 /*yield*/, (0, clientQueryV3_1.default)({
|
|
217
|
+
query: query_1.GET_SCHOOL_V3,
|
|
218
|
+
variables: { group_id: group_id, school_name_id: school_name_id, user_id: id },
|
|
219
|
+
isDelay: false,
|
|
220
|
+
})];
|
|
221
|
+
case 2:
|
|
222
|
+
res = _f.sent();
|
|
223
|
+
dataSchool = (_c = (_b = res === null || res === void 0 ? void 0 : res.data) === null || _b === void 0 ? void 0 : _b.school_name[0]) === null || _c === void 0 ? void 0 : _c.schools;
|
|
224
|
+
settingFetchData = (_e = (_d = res === null || res === void 0 ? void 0 : res.data) === null || _d === void 0 ? void 0 : _d.setting_site[0]) === null || _e === void 0 ? void 0 : _e.value_setting;
|
|
225
|
+
if (settingFetchData) {
|
|
226
|
+
cleanedJsonString = settingFetchData.replace(/^"(.*)"$/, '$1');
|
|
227
|
+
settingSiteDb = JSON.parse(cleanedJsonString);
|
|
228
|
+
}
|
|
229
|
+
setIsLoading(false);
|
|
230
|
+
return [2 /*return*/, {
|
|
231
|
+
settingSiteDb: settingSiteDb,
|
|
232
|
+
loadingSchool: dataSchool.length === 0,
|
|
233
|
+
listSchool: dataSchool,
|
|
234
|
+
schoolId: school_id,
|
|
235
|
+
}];
|
|
236
|
+
case 3:
|
|
237
|
+
error_3 = _f.sent();
|
|
238
|
+
setIsLoading(false);
|
|
239
|
+
console.error('Error fetching school data:', error_3);
|
|
240
|
+
return [2 /*return*/];
|
|
241
|
+
case 4: return [2 /*return*/];
|
|
242
|
+
}
|
|
243
|
+
});
|
|
244
|
+
}); };
|
|
245
|
+
var fetchDataMenu = function () { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
|
246
|
+
var envPublic, menuUrl, logoMenuTop, data, menuJson;
|
|
247
|
+
return tslib_1.__generator(this, function (_a) {
|
|
248
|
+
switch (_a.label) {
|
|
249
|
+
case 0: return [4 /*yield*/, (0, getEnvPublic_1.default)()];
|
|
250
|
+
case 1:
|
|
251
|
+
envPublic = _a.sent();
|
|
252
|
+
menuUrl = envPublic === null || envPublic === void 0 ? void 0 : envPublic.SCHOOL_MENU_V2;
|
|
253
|
+
logoMenuTop = envPublic === null || envPublic === void 0 ? void 0 : envPublic.SCHOOL_TOP_MENU_LOGO;
|
|
254
|
+
if (!menuUrl || !logoMenuTop) {
|
|
255
|
+
console.error('menu or logo not found');
|
|
256
|
+
}
|
|
257
|
+
return [4 /*yield*/, fetch(menuUrl)];
|
|
258
|
+
case 2:
|
|
259
|
+
data = _a.sent();
|
|
260
|
+
return [4 /*yield*/, data.json()];
|
|
261
|
+
case 3:
|
|
262
|
+
menuJson = _a.sent();
|
|
263
|
+
return [2 /*return*/, {
|
|
264
|
+
loadingMenu: false,
|
|
265
|
+
logo: { path: logoMenuTop, height: logoHeight },
|
|
266
|
+
menu: menuJson,
|
|
267
|
+
}];
|
|
268
|
+
}
|
|
269
|
+
});
|
|
270
|
+
}); };
|
|
271
|
+
var detectEnvByDomain = function (domain, configEnv) {
|
|
272
|
+
for (var _i = 0, _a = Object.entries(configEnv); _i < _a.length; _i++) {
|
|
273
|
+
var _b = _a[_i], env = _b[0], pattern = _b[1];
|
|
274
|
+
if (env.startsWith('_comment'))
|
|
275
|
+
continue; // bỏ qua comment
|
|
276
|
+
var regex = new RegExp(pattern.replace(/\\\\/g, '\\'));
|
|
277
|
+
if (regex.test(domain))
|
|
278
|
+
return env;
|
|
279
|
+
}
|
|
280
|
+
return 'stg';
|
|
281
|
+
};
|
|
282
|
+
var getEnvByConfig = function (configEnv) {
|
|
283
|
+
var domain = window.location.hostname;
|
|
284
|
+
var env = detectEnvByDomain(domain, configEnv);
|
|
285
|
+
return "config_menu_".concat(env, ":disable");
|
|
286
|
+
};
|
|
287
|
+
var isConfigEnvValid = function (code, configDisable) {
|
|
288
|
+
return configDisable.length === 0 || !(configDisable === null || configDisable === void 0 ? void 0 : configDisable.includes(code));
|
|
289
|
+
};
|
|
290
|
+
var funcMenuByConfigEnv = function (menuJson, configDisable) {
|
|
291
|
+
var menuWithConfigEnv = [];
|
|
292
|
+
for (var _i = 0, menuJson_1 = menuJson; _i < menuJson_1.length; _i++) {
|
|
293
|
+
var item = menuJson_1[_i];
|
|
294
|
+
if (!isConfigEnvValid(item === null || item === void 0 ? void 0 : item.code, configDisable))
|
|
295
|
+
continue;
|
|
296
|
+
var menuItem = tslib_1.__assign(tslib_1.__assign({}, item), { child: [] });
|
|
297
|
+
var menuSecondLevel = (item === null || item === void 0 ? void 0 : item.child) || [];
|
|
298
|
+
for (var _a = 0, _b = menuSecondLevel || []; _a < _b.length; _a++) {
|
|
299
|
+
var childItem = _b[_a];
|
|
300
|
+
if (!isConfigEnvValid(childItem === null || childItem === void 0 ? void 0 : childItem.code, configDisable))
|
|
301
|
+
continue;
|
|
302
|
+
var childMenuItem = tslib_1.__assign(tslib_1.__assign({}, childItem), { child: [] });
|
|
303
|
+
var menuThirdLevel = (childItem === null || childItem === void 0 ? void 0 : childItem.child) || [];
|
|
304
|
+
for (var _c = 0, menuThirdLevel_1 = menuThirdLevel; _c < menuThirdLevel_1.length; _c++) {
|
|
305
|
+
var subChildItem = menuThirdLevel_1[_c];
|
|
306
|
+
if (!isConfigEnvValid(subChildItem === null || subChildItem === void 0 ? void 0 : subChildItem.code, configDisable))
|
|
307
|
+
continue;
|
|
308
|
+
childMenuItem.child.push(subChildItem);
|
|
309
|
+
}
|
|
310
|
+
menuItem.child.push(childMenuItem);
|
|
311
|
+
}
|
|
312
|
+
menuWithConfigEnv.push(menuItem);
|
|
313
|
+
}
|
|
314
|
+
return menuWithConfigEnv;
|
|
315
|
+
};
|
|
316
|
+
var fetchInitData = function () { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
|
317
|
+
var _a, loadingMenu, logo, menu, profileNew, dataPer, dataSchool, actionPermissionMap, uniqueRoutePermissions, config_env, enviromentByDomainConfig, menuJson, configDisable, currentSession;
|
|
318
|
+
var _b;
|
|
319
|
+
return tslib_1.__generator(this, function (_c) {
|
|
320
|
+
switch (_c.label) {
|
|
321
|
+
case 0: return [4 /*yield*/, fetchDataMenu()];
|
|
322
|
+
case 1:
|
|
323
|
+
_a = _c.sent(), loadingMenu = _a.loadingMenu, logo = _a.logo, menu = _a.menu;
|
|
324
|
+
return [4 /*yield*/, getProfileByUser()];
|
|
325
|
+
case 2:
|
|
326
|
+
profileNew = _c.sent();
|
|
327
|
+
return [4 /*yield*/, fetchDataPer()];
|
|
328
|
+
case 3:
|
|
329
|
+
dataPer = _c.sent();
|
|
330
|
+
return [4 /*yield*/, fetchDataSchool()];
|
|
331
|
+
case 4:
|
|
332
|
+
dataSchool = _c.sent();
|
|
333
|
+
actionPermissionMap = dataPer.actionPermissionMap, uniqueRoutePermissions = dataPer.uniqueRoutePermissions;
|
|
334
|
+
config_env = menu.config_env;
|
|
335
|
+
enviromentByDomainConfig = getEnvByConfig(config_env);
|
|
336
|
+
menuJson = menu.menu;
|
|
337
|
+
configDisable = menu[enviromentByDomainConfig];
|
|
338
|
+
setDataInitMain({
|
|
339
|
+
menuDefault: menuJson,
|
|
340
|
+
logo: logo,
|
|
341
|
+
menu: funcMenuByConfigEnv(menuJson, configDisable),
|
|
342
|
+
loadingMenu: loadingMenu,
|
|
343
|
+
schoolId: (dataSchool === null || dataSchool === void 0 ? void 0 : dataSchool.schoolId) || null,
|
|
344
|
+
loadingSchool: !!(dataSchool === null || dataSchool === void 0 ? void 0 : dataSchool.loadingSchool),
|
|
345
|
+
listSchool: (dataSchool === null || dataSchool === void 0 ? void 0 : dataSchool.listSchool) || [],
|
|
346
|
+
isLoadingPermission: false,
|
|
347
|
+
perCode: uniqueRoutePermissions,
|
|
348
|
+
roleCode: (profileNew === null || profileNew === void 0 ? void 0 : profileNew.user_roles.map(function (userRole) { var _a; return (_a = userRole === null || userRole === void 0 ? void 0 : userRole.role) === null || _a === void 0 ? void 0 : _a.role_code; })) || [],
|
|
349
|
+
configLayout: (dataSchool === null || dataSchool === void 0 ? void 0 : dataSchool.settingSiteDb) || undefined,
|
|
350
|
+
sourceAvatar: ((_b = profileNew === null || profileNew === void 0 ? void 0 : profileNew.user_avatar) === null || _b === void 0 ? void 0 : _b.size_small) || (profileNew === null || profileNew === void 0 ? void 0 : profileNew.avatar) || constants_1.DEFAULT_AVATAR,
|
|
351
|
+
});
|
|
352
|
+
currentSession = (0, getCookieSession_1.default)();
|
|
353
|
+
(0, saveCookiesClient_1.default)({
|
|
354
|
+
value: tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({}, currentSession), (actionPermissionMap && {
|
|
355
|
+
action_permission: actionPermissionMap || [],
|
|
356
|
+
})), { setting_site: (dataSchool === null || dataSchool === void 0 ? void 0 : dataSchool.settingSiteDb) || {} }), (profileNew && {
|
|
357
|
+
user_info: tslib_1.__assign(tslib_1.__assign({}, userSessionInfo), profileNew),
|
|
358
|
+
})),
|
|
359
|
+
});
|
|
360
|
+
return [2 /*return*/];
|
|
361
|
+
}
|
|
362
|
+
});
|
|
363
|
+
}); };
|
|
364
|
+
(0, react_2.useEffect)(function () {
|
|
365
|
+
if (!userSessionInfo) {
|
|
366
|
+
// Require login if production mode
|
|
367
|
+
requireLoginValidation();
|
|
368
|
+
return;
|
|
369
|
+
}
|
|
370
|
+
fetchInitData();
|
|
371
|
+
}, []);
|
|
372
|
+
var isEqualUrl = function (parentHref, pathNameCompare) {
|
|
373
|
+
if (!parentHref || !pathNameCompare) {
|
|
374
|
+
return false;
|
|
375
|
+
}
|
|
376
|
+
var pathNameSplit = pathNameCompare.split('/');
|
|
377
|
+
var hrefSplit = parentHref.split('/');
|
|
378
|
+
if (!pathNameSplit || !hrefSplit) {
|
|
379
|
+
return false;
|
|
380
|
+
}
|
|
381
|
+
var urlRouter;
|
|
382
|
+
var currentMenu;
|
|
383
|
+
if (multipleMenu) {
|
|
384
|
+
urlRouter = pathNameSplit[1] + pathNameSplit[2];
|
|
385
|
+
currentMenu = hrefSplit[1] + hrefSplit[2];
|
|
386
|
+
}
|
|
387
|
+
else {
|
|
388
|
+
urlRouter = pathNameSplit[1];
|
|
389
|
+
currentMenu = hrefSplit[1];
|
|
390
|
+
}
|
|
391
|
+
return urlRouter === currentMenu;
|
|
392
|
+
};
|
|
393
|
+
var isBelongParentWithMicroservice = function (parentSplit, pathNameSplit) {
|
|
394
|
+
if (parentSplit.length > 2) {
|
|
395
|
+
var compareLength = parentSplit.length;
|
|
396
|
+
for (var i = 1; i < compareLength; i++) {
|
|
397
|
+
if (parentSplit[i] !== pathNameSplit[i])
|
|
398
|
+
return false;
|
|
399
|
+
}
|
|
400
|
+
return true;
|
|
401
|
+
}
|
|
402
|
+
else {
|
|
403
|
+
return parentSplit[1] === pathNameSplit[3];
|
|
404
|
+
}
|
|
405
|
+
};
|
|
406
|
+
var isBelongParent = function (parentUrl, pathNameCompare, isMicroservice) {
|
|
407
|
+
var parentSplit = parentUrl.split('/');
|
|
408
|
+
var pathNameSplit = pathNameCompare.split('/');
|
|
409
|
+
if (isMicroservice) {
|
|
410
|
+
return isBelongParentWithMicroservice(parentSplit, pathNameSplit);
|
|
411
|
+
}
|
|
412
|
+
if (parentSplit.length > 2 && !parentSplit.includes('list')) {
|
|
413
|
+
return parentSplit[1] === pathNameSplit[2] && parentSplit[2] === pathNameSplit[3];
|
|
414
|
+
}
|
|
415
|
+
else {
|
|
416
|
+
return parentSplit[1] === pathNameSplit[2];
|
|
417
|
+
}
|
|
418
|
+
};
|
|
419
|
+
var checkAdmissions = function (path) {
|
|
420
|
+
var pathNameSplit = path.split('/');
|
|
421
|
+
return pathNameSplit[1] === 'admissions';
|
|
422
|
+
};
|
|
423
|
+
var loadParentNavigation = function (path) {
|
|
424
|
+
var mainNavigation = dataInitMain.menu;
|
|
425
|
+
var naviSize = mainNavigation.length;
|
|
426
|
+
for (var i = 0; i < naviSize; i++) {
|
|
427
|
+
var item = mainNavigation[i];
|
|
428
|
+
item.current = false;
|
|
429
|
+
if (item.path === path || isEqualUrl(item.path, path)) {
|
|
430
|
+
item.current = true;
|
|
431
|
+
// Find sub modules
|
|
432
|
+
var itemLength = item.child.length;
|
|
433
|
+
var listChildren = [];
|
|
434
|
+
for (var j = 0; j < itemLength; j++) {
|
|
435
|
+
var childItem = item.child[j];
|
|
436
|
+
// Active child item
|
|
437
|
+
childItem.current = isBelongParent(childItem.path, path, !!(childItem === null || childItem === void 0 ? void 0 : childItem.isMicroservice));
|
|
438
|
+
if (childItem.child) {
|
|
439
|
+
var childItemLength = childItem.child.length;
|
|
440
|
+
var count = 0;
|
|
441
|
+
for (var k = 0; k < childItemLength; k++) {
|
|
442
|
+
var subChild = childItem.child[k];
|
|
443
|
+
subChild.current = isBelongParent(subChild.path, path, !!(childItem === null || childItem === void 0 ? void 0 : childItem.isMicroservice));
|
|
444
|
+
if (isBelongParent(subChild.path, path, !!(childItem === null || childItem === void 0 ? void 0 : childItem.isMicroservice)) ||
|
|
445
|
+
isBelongParent(childItem.path, path, !!(childItem === null || childItem === void 0 ? void 0 : childItem.isMicroservice))) {
|
|
446
|
+
count++;
|
|
447
|
+
}
|
|
448
|
+
var isSameSubChildPath = (subChild === null || subChild === void 0 ? void 0 : subChild.isMicroservice)
|
|
449
|
+
? subChild.path === (childItem === null || childItem === void 0 ? void 0 : childItem.path)
|
|
450
|
+
: subChild.path === (childItem === null || childItem === void 0 ? void 0 : childItem.pathInternal);
|
|
451
|
+
var isPathInternal = (childItem === null || childItem === void 0 ? void 0 : childItem.isMicroservice) ? isSameSubChildPath : subChild.path === childItem.path;
|
|
452
|
+
childItem.showChild = count > 0;
|
|
453
|
+
if (isPathInternal)
|
|
454
|
+
childItem.current = false;
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
listChildren.push(childItem);
|
|
458
|
+
}
|
|
459
|
+
setSubNavigation(listChildren);
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
setNavigation(mainNavigation);
|
|
463
|
+
};
|
|
464
|
+
var loadChildrenCampaign = function (path) {
|
|
465
|
+
var mainNavigation = dataInitMain.menu;
|
|
466
|
+
var naviSize = mainNavigation.length;
|
|
467
|
+
for (var i = 0; i < naviSize; i++) {
|
|
468
|
+
var item = mainNavigation[i];
|
|
469
|
+
item.current = false;
|
|
470
|
+
if (item.path === path || isEqualUrl(item.path, path)) {
|
|
471
|
+
item.current = true;
|
|
472
|
+
// Find sub modules
|
|
473
|
+
// const itemLength = item.child.length;
|
|
474
|
+
var campaign = item.child.filter(function (child) { return child.path === '/campaign/list'; });
|
|
475
|
+
var listCampaign = campaign[0];
|
|
476
|
+
var itemLength = listCampaign === null || listCampaign === void 0 ? void 0 : listCampaign.childrenByParentDetail.length;
|
|
477
|
+
var listChildren = [];
|
|
478
|
+
for (var j = 0; j < itemLength; j++) {
|
|
479
|
+
var childItem = listCampaign === null || listCampaign === void 0 ? void 0 : listCampaign.childrenByParentDetail[j];
|
|
480
|
+
// Active child item
|
|
481
|
+
childItem.current = isBelongParent(childItem.path, path, false);
|
|
482
|
+
if (childItem.child) {
|
|
483
|
+
var childItemLength = childItem.child.length;
|
|
484
|
+
for (var k = 0; k < childItemLength; k++) {
|
|
485
|
+
var subChild = childItem.child[k];
|
|
486
|
+
subChild.current = isBelongParent(subChild.path, path, false);
|
|
487
|
+
if (isBelongParent(subChild.path, path, false) || isBelongParent(childItem.path, path, false)) {
|
|
488
|
+
childItem.showChild = true;
|
|
489
|
+
}
|
|
490
|
+
childItem.current = subChild.path !== childItem.path;
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
listChildren.push(childItem);
|
|
494
|
+
}
|
|
495
|
+
setSubNavigation(listChildren);
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
setNavigation(mainNavigation);
|
|
499
|
+
};
|
|
500
|
+
var checkChildrenCampaign = function (path) {
|
|
501
|
+
var _a;
|
|
502
|
+
var campaignMenu = (_a = dataInitMain.menu) === null || _a === void 0 ? void 0 : _a.find(function (item) { return item.path === '/admissions/campaign/list'; });
|
|
503
|
+
var campaignChild = campaignMenu === null || campaignMenu === void 0 ? void 0 : campaignMenu.child;
|
|
504
|
+
var listChild = campaignChild === null || campaignChild === void 0 ? void 0 : campaignChild.find(function (item) { return item.path === '/campaign/list'; });
|
|
505
|
+
var isChild = listChild === null || listChild === void 0 ? void 0 : listChild.childrenByParentDetail.find(function (item) { return isBelongParent(item.path, path, false); });
|
|
506
|
+
return isChild !== undefined;
|
|
507
|
+
};
|
|
508
|
+
(0, react_2.useEffect)(function () {
|
|
509
|
+
var isAdmissions = checkAdmissions(pathNameWithBasePath);
|
|
510
|
+
if (isAdmissions && checkChildrenCampaign(pathNameWithBasePath)) {
|
|
511
|
+
if (pathNameWithBasePath.includes('/admissions/overview/list/') && pid) {
|
|
512
|
+
(0, clientQueryV3_1.default)({
|
|
513
|
+
query: query_1.getCampaignNameV3,
|
|
514
|
+
variables: { id: pid },
|
|
515
|
+
isDelay: false,
|
|
516
|
+
}).then(function (res) {
|
|
517
|
+
var data = res.data.admissions_campaigns_by_pk;
|
|
518
|
+
setCampaignName(data.campaign_name);
|
|
519
|
+
js_cookie_1.default.set('campaign_name', JSON.stringify(data.campaign_name));
|
|
520
|
+
});
|
|
521
|
+
loadChildrenCampaign(pathNameWithBasePath);
|
|
522
|
+
}
|
|
523
|
+
else if (pathNameWithBasePath === '/admissions/campaign/list') {
|
|
524
|
+
loadParentNavigation(pathNameWithBasePath);
|
|
525
|
+
}
|
|
526
|
+
else {
|
|
527
|
+
loadChildrenCampaign(pathNameWithBasePath);
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
else {
|
|
531
|
+
loadParentNavigation(pathNameWithBasePath);
|
|
532
|
+
}
|
|
533
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
534
|
+
}, [dataInitMain, pid, pathNameWithBasePath]);
|
|
535
|
+
(0, react_2.useEffect)(function () {
|
|
536
|
+
var isAdmissions = checkAdmissions(pathNameWithBasePath);
|
|
537
|
+
if (isAdmissions) {
|
|
538
|
+
if (pathNameWithBasePath === '/admissions/campaign/list' || !checkChildrenCampaign(pathNameWithBasePath)) {
|
|
539
|
+
setOpenSubMenu(true);
|
|
540
|
+
}
|
|
541
|
+
else {
|
|
542
|
+
setOpenSubMenu(true);
|
|
543
|
+
var campaign_name = js_cookie_1.default.get('campaign_name');
|
|
544
|
+
setCampaignName(campaign_name ? JSON.parse(campaign_name) : campaignName);
|
|
545
|
+
loadChildrenCampaign(pathNameWithBasePath);
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
else {
|
|
549
|
+
setOpenSubMenu(true);
|
|
550
|
+
}
|
|
551
|
+
}, [pathNameWithBasePath, dataInitMain]);
|
|
552
|
+
var loadSubNavigation = function (path, isChild, childPath) {
|
|
553
|
+
var subLength = subNavigation.length;
|
|
554
|
+
var newSub = [];
|
|
555
|
+
for (var i = 0; i < subLength; i++) {
|
|
556
|
+
var item = subNavigation[i];
|
|
557
|
+
item.current = item.path === path && !isChild;
|
|
558
|
+
if (item.child) {
|
|
559
|
+
item.showChild = item.path === path;
|
|
560
|
+
for (var j = 0; j < item.child.length; j++) {
|
|
561
|
+
var child = item.child[j];
|
|
562
|
+
child.current = child.path === childPath;
|
|
563
|
+
if (child.path === item.path) {
|
|
564
|
+
item.current = false;
|
|
565
|
+
child.current = childPath ? child.path === childPath : child.path === path;
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
newSub.push(item);
|
|
570
|
+
}
|
|
571
|
+
setSubNavigation(newSub);
|
|
572
|
+
};
|
|
573
|
+
var subNavigationTriggerClicked = function (item, parent) {
|
|
574
|
+
if (parent) {
|
|
575
|
+
loadSubNavigation(parent.path, true, item.path);
|
|
576
|
+
}
|
|
577
|
+
else {
|
|
578
|
+
loadSubNavigation(item.path, false);
|
|
579
|
+
}
|
|
580
|
+
var queryString = window.location.search;
|
|
581
|
+
var urlParams = new URLSearchParams(queryString);
|
|
582
|
+
var campaign = Number(urlParams.get('campaignId'));
|
|
583
|
+
setGlobalLoading(true);
|
|
584
|
+
// handle for admissions
|
|
585
|
+
if (campaign) {
|
|
586
|
+
router.push("".concat(item.path, "?campaignId=").concat(campaign));
|
|
587
|
+
}
|
|
588
|
+
else {
|
|
589
|
+
router.push(item.path);
|
|
590
|
+
}
|
|
591
|
+
};
|
|
592
|
+
var topMenuLogoFromEnv = dataInitMain.logo.path;
|
|
593
|
+
var handleModalSignOut = function () { return setModalSignOut(true); };
|
|
594
|
+
var handleRedirectRouter = function (path) {
|
|
595
|
+
var currentURL = window.location.href;
|
|
596
|
+
var url = currentURL.split('/');
|
|
597
|
+
var pushPath = "".concat(url[0], "//").concat(url[2], "/").concat(path);
|
|
598
|
+
window.location.replace(pushPath);
|
|
599
|
+
};
|
|
600
|
+
var callApiLogoutToken = function () { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
|
601
|
+
var error_4;
|
|
602
|
+
return tslib_1.__generator(this, function (_a) {
|
|
603
|
+
switch (_a.label) {
|
|
604
|
+
case 0:
|
|
605
|
+
_a.trys.push([0, 2, , 3]);
|
|
606
|
+
return [4 /*yield*/, axios_1.default.post("/api/authenticate/logout", {}, {
|
|
607
|
+
withCredentials: true,
|
|
608
|
+
})];
|
|
609
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
610
|
+
case 2:
|
|
611
|
+
error_4 = _a.sent();
|
|
612
|
+
console.error(error_4);
|
|
613
|
+
return [2 /*return*/];
|
|
614
|
+
case 3: return [2 /*return*/];
|
|
615
|
+
}
|
|
616
|
+
});
|
|
617
|
+
}); };
|
|
618
|
+
var handleSignOut = function () { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
|
619
|
+
return tslib_1.__generator(this, function (_a) {
|
|
620
|
+
switch (_a.label) {
|
|
621
|
+
case 0:
|
|
622
|
+
setModalSignOut(false);
|
|
623
|
+
Object.keys(js_cookie_1.default.get()).forEach(function (cookieName) {
|
|
624
|
+
js_cookie_1.default.remove(cookieName);
|
|
625
|
+
});
|
|
626
|
+
return [4 /*yield*/, callApiLogoutToken()];
|
|
627
|
+
case 1:
|
|
628
|
+
_a.sent();
|
|
629
|
+
console.log('Đăng xuất tài khoản');
|
|
630
|
+
handleRedirectRouter('login-sso');
|
|
631
|
+
return [2 /*return*/];
|
|
632
|
+
}
|
|
633
|
+
});
|
|
634
|
+
}); };
|
|
635
|
+
var handleProfilePage = function () {
|
|
636
|
+
handleRedirectRouter('profile');
|
|
637
|
+
};
|
|
638
|
+
var handleBackMenu = function () {
|
|
639
|
+
router.push('/campaign/list');
|
|
640
|
+
loadParentNavigation('/admissions/campaign/list');
|
|
641
|
+
};
|
|
642
|
+
var checkChildBefore = function (item, currentItem) {
|
|
643
|
+
var currentIndexActive = item.find(function (s) { return s.current; });
|
|
644
|
+
return currentIndexActive ? currentIndexActive.id > currentItem.id : false;
|
|
645
|
+
};
|
|
646
|
+
var _t = (0, react_2.useState)(null), selected = _t[0], setSelected = _t[1];
|
|
647
|
+
var handleOpenModal = function (id) {
|
|
648
|
+
setModal(id !== dataInitMain.schoolId);
|
|
649
|
+
setSelected(id);
|
|
650
|
+
};
|
|
651
|
+
var handlePrimaryModal = function () {
|
|
652
|
+
var currentSession = (0, getCookieSession_1.default)();
|
|
653
|
+
var userInfo = currentSession === null || currentSession === void 0 ? void 0 : currentSession.user_info;
|
|
654
|
+
if (userInfo) {
|
|
655
|
+
try {
|
|
656
|
+
var newSchoolId = selected;
|
|
657
|
+
var schoolIdCurrent = userInfo.school_id;
|
|
658
|
+
if (newSchoolId && newSchoolId !== schoolIdCurrent) {
|
|
659
|
+
var userInfoNew = tslib_1.__assign(tslib_1.__assign({}, userInfo), { school_id: newSchoolId });
|
|
660
|
+
(0, saveCookiesClient_1.default)({
|
|
661
|
+
value: tslib_1.__assign(tslib_1.__assign({}, currentSession), { user_info: userInfoNew }),
|
|
662
|
+
});
|
|
663
|
+
window.location.reload();
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
catch (error) {
|
|
667
|
+
console.error(error);
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
setModal(false);
|
|
671
|
+
};
|
|
672
|
+
// settings page
|
|
673
|
+
var isSettings = function () {
|
|
674
|
+
var pathNameSplit = pathNameWithBasePath.split('/');
|
|
675
|
+
return pathNameSplit[1] === 'setting';
|
|
676
|
+
};
|
|
677
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
678
|
+
// const checkLogoHeader = dataInitMain.configLayout?.logo_dashboard || topMenuLogoFromEnv || DEFAULT_LOGO_DASHBOARD
|
|
679
|
+
var isActivityHistory = function () {
|
|
680
|
+
var pathNameSplit = pathNameWithBasePath.split('/');
|
|
681
|
+
return pathNameSplit[1] === constants_1.PATH_ACTIVITY_HISTORY;
|
|
682
|
+
};
|
|
683
|
+
var _u = (0, react_2.useState)(constants_1.MENU_ACTIVITY_HISTORY_CHILD), activityHistoryChild = _u[0], setActivityHistoryChild = _u[1];
|
|
684
|
+
var handleClickActivityHistoryChild = function (clickedItem) {
|
|
685
|
+
var updated = activityHistoryChild.map(function (item) { return (tslib_1.__assign(tslib_1.__assign({}, item), { current: item.code === clickedItem.code })); });
|
|
686
|
+
setActivityHistoryChild(updated);
|
|
687
|
+
};
|
|
688
|
+
(0, react_2.useEffect)(function () {
|
|
689
|
+
if (basePath === constants_1.PATH_ACTIVITY_HISTORY) {
|
|
690
|
+
setActivityHistoryChild(function (prev) {
|
|
691
|
+
return prev.map(function (item) { return (tslib_1.__assign(tslib_1.__assign({}, item), { current: pathNameWithBasePath.endsWith(item.path) })); });
|
|
692
|
+
});
|
|
693
|
+
}
|
|
694
|
+
else {
|
|
695
|
+
setActivityHistoryChild([]);
|
|
696
|
+
}
|
|
697
|
+
}, [pathNameWithBasePath, basePath]);
|
|
698
|
+
return (react_2.default.createElement(react_2.default.Fragment, null,
|
|
699
|
+
react_2.default.createElement(page_tracker_1.PageTracker, null),
|
|
700
|
+
react_2.default.createElement("div", { className: 'flex min-h-full flex-col' },
|
|
701
|
+
react_2.default.createElement(appearance_styled_1.default, { configLayout: dataInitMain === null || dataInitMain === void 0 ? void 0 : dataInitMain.configLayout, settingSiteCookie: getDataCookies ? (_d = (0, helpers_1.decryptCookie)(getDataCookies)) === null || _d === void 0 ? void 0 : _d.setting_site : null }),
|
|
702
|
+
react_2.default.createElement("header", { className: 'fixed top-0 z-50 flex h-10 min-w-full items-center justify-between bg-gray-100 pl-1.5 pr-2 ' },
|
|
703
|
+
react_2.default.createElement("div", { className: 'flex items-center gap-x-3' },
|
|
704
|
+
react_2.default.createElement("a", { className: 'flex w-full items-center', href: '/' }, topMenuLogoFromEnv ? (react_2.default.createElement(react_2.default.Fragment, null, isLoading ? (react_2.default.createElement("div", { className: 'header-loading-logo ml-3 h-8 w-full animate-pulse' })) : (react_2.default.createElement("img", { alt: 'Logo', className: ' h-5 w-auto',
|
|
705
|
+
// src={checkLogoHeader}
|
|
706
|
+
src: 'https://sisv2-cdn.phx-smartschool.com/library/book-copy/11-17-2025/22cef182-c958-4e1c-b4a0-66eede72166a-logo.png', style: { maxWidth: '12rem' } })))) : (react_2.default.createElement(react_2.default.Fragment, null))),
|
|
707
|
+
react_2.default.createElement("div", { className: 'flex items-center lg:hidden' },
|
|
708
|
+
react_2.default.createElement("button", { className: 'bg-grey-100 mr-3 inline-flex items-center justify-center rounded-md p-1 text-gray-200 hover:bg-white hover:text-gray-600', onClick: function () { return setSidebarOpen(true); }, type: 'button' },
|
|
709
|
+
react_2.default.createElement("span", { className: 'sr-only' }, "Open sidebar"),
|
|
710
|
+
react_2.default.createElement(outline_1.Bars3Icon, { "aria-hidden": 'true', className: 'h-6 w-6' })))),
|
|
711
|
+
react_2.default.createElement("div", { className: 'flex items-center gap-x-8' },
|
|
712
|
+
react_2.default.createElement("div", { className: '-m-1.5 p-1.5' },
|
|
713
|
+
react_2.default.createElement(react_1.Menu, { as: 'div', className: 'relative ml-3' },
|
|
714
|
+
react_2.default.createElement("div", null,
|
|
715
|
+
react_2.default.createElement(react_1.Menu.Button, { className: 'flex max-w-xs items-center rounded-full bg-gray-800 text-sm focus:outline-none focus:ring-2 focus:ring-white focus:ring-offset-2 focus:ring-offset-gray-800' },
|
|
716
|
+
react_2.default.createElement("span", { className: 'sr-only' }, "Open user menu"),
|
|
717
|
+
isLoading ? (react_2.default.createElement("div", { className: 'flex animate-pulse' },
|
|
718
|
+
react_2.default.createElement("div", { className: 'header-loading-avatar h-6 w-6 rounded-full' }))) : (react_2.default.createElement("img", { alt: '', className: 'h-6 w-6 rounded-full', src: dataInitMain.sourceAvatar })))),
|
|
719
|
+
react_2.default.createElement(react_1.Transition, { as: react_2.Fragment, enter: 'transition ease-out duration-100', enterFrom: 'transform opacity-0 scale-95', enterTo: 'transform opacity-100 scale-100', leave: 'transition ease-in duration-75', leaveFrom: 'transform opacity-100 scale-100', leaveTo: 'transform opacity-0 scale-95' },
|
|
720
|
+
react_2.default.createElement(react_1.Menu.Items, { className: ' shadow-lg absolute right-0 z-10 mt-2 w-[340px] origin-top-right rounded-md bg-white px-2 ring-1 ring-black ring-opacity-5 focus:outline-none' },
|
|
721
|
+
react_2.default.createElement(react_1.Menu.Item, null,
|
|
722
|
+
react_2.default.createElement("div", { "aria-hidden": true, className: 'px-2 pb-2 pt-4 text-sm font-semibold text-gray-900 ' }, "Ch\u1ECDn tr\u01B0\u1EDDng")),
|
|
723
|
+
!dataInitMain.loadingSchool ? (react_2.default.createElement(react_2.default.Fragment, null, dataInitMain.listSchool
|
|
724
|
+
.filter(function (val) {
|
|
725
|
+
if (!enablePer(constants_1.switchSchool, dataInitMain.perCode)) {
|
|
726
|
+
return val.id === dataInitMain.schoolId;
|
|
727
|
+
}
|
|
728
|
+
else {
|
|
729
|
+
return true;
|
|
730
|
+
}
|
|
731
|
+
})
|
|
732
|
+
.map(function (item) { return (react_2.default.createElement(react_1.Menu.Item, { key: item.id },
|
|
733
|
+
react_2.default.createElement("div", { "aria-hidden": true, className: "".concat(item.id === dataInitMain.schoolId &&
|
|
734
|
+
dataInitMain.listSchool.length > 1 &&
|
|
735
|
+
!enablePer(constants_1.switchSchool, dataInitMain.perCode) === false
|
|
736
|
+
? 'rounded-lg bg-zinc-200 font-semibold text-gray-900 '
|
|
737
|
+
: 'font-normal ', " \n ").concat(item.id !== dataInitMain.schoolId &&
|
|
738
|
+
(dataInitMain.listSchool.length === 1 ||
|
|
739
|
+
!enablePer(constants_1.switchSchool, dataInitMain.perCode)) === false
|
|
740
|
+
? 'cursor-pointer hover:rounded-lg hover:bg-gray-100'
|
|
741
|
+
: '', "\n relative mb-1 flex items-center justify-between px-2 py-1.5 text-sm text-gray-900"), onClick: function () { return handleOpenModal(item.id); } },
|
|
742
|
+
react_2.default.createElement("p", { className: 'max-w-[95%] truncate' }, item.name),
|
|
743
|
+
item.id === dataInitMain.schoolId &&
|
|
744
|
+
dataInitMain.listSchool.length > 1 &&
|
|
745
|
+
!enablePer(constants_1.switchSchool, dataInitMain.perCode) === false && (react_2.default.createElement(solid_2.CheckIcon, { "aria-hidden": 'true', className: 'h-4 w-4' }))))); }))) : (react_2.default.createElement(Skeleton_1.PHXSkeleton, { className: 'flex-1 px-2 py-2', type: 'single' })),
|
|
746
|
+
react_2.default.createElement("div", { className: 'border-b pt-1.5' }),
|
|
747
|
+
react_2.default.createElement(react_1.Menu.Item, null,
|
|
748
|
+
react_2.default.createElement("div", { "aria-hidden": true, className: 'px-2 pb-2 pt-4 text-sm font-semibold text-gray-900' }, "T\u00F9y ch\u1ECDn")),
|
|
749
|
+
react_2.default.createElement(react_1.Menu.Item, null,
|
|
750
|
+
react_2.default.createElement("div", { "aria-hidden": true, className: 'cursor-pointer px-2 py-1.5 text-sm text-gray-900 hover:rounded-lg hover:bg-gray-100', onClick: handleProfilePage }, "Th\u00F4ng tin c\u00E1 nh\u00E2n")),
|
|
751
|
+
react_2.default.createElement(react_1.Menu.Item, null,
|
|
752
|
+
react_2.default.createElement("div", { "aria-hidden": true, className: 'mb-2.5 cursor-pointer px-2 py-1.5 text-sm text-[#8e1f0c] hover:rounded-lg hover:bg-gray-100', onClick: handleModalSignOut }, "\u0110\u0103ng xu\u1EA5t"))))))))),
|
|
753
|
+
react_2.default.createElement("div", null,
|
|
754
|
+
react_2.default.createElement(Modal_1.PHXModal, { dangerActionText: '\u0110\u0103ng xu\u1EA5t', onDangerClick: handleSignOut, onHide: function () { return setModalSignOut(false); }, primaryActionText: '', show: modalSignOut, title: '\u0110\u0103ng xu\u1EA5t' },
|
|
755
|
+
react_2.default.createElement("div", { className: 'text-sm text-gray-700' }, "Khi th\u1EF1c hi\u1EC7n thao t\u00E1c n\u00E0y b\u1EA1n s\u1EBD tho\u00E1t kh\u1ECFi trang qu\u1EA3n tr\u1ECB v\u00E0 tr\u1EDF v\u1EC1 trang \u0111\u0103ng nh\u1EADp"))),
|
|
756
|
+
react_2.default.createElement(Modal_1.PHXModal, { onHide: function () { return setModal(false); }, onPrimaryClick: handlePrimaryModal, primaryActionText: 'X\u00E1c nh\u1EADn', show: modal, title: 'X\u00E1c nh\u1EADn thay \u0111\u1ED5i tr\u01B0\u1EDDng' },
|
|
757
|
+
react_2.default.createElement(Banner_1.PHXBanner, { description: 'Khi thay \u0111\u1ED5i tr\u01B0\u1EDDng t\u1EA5t c\u1EA3 d\u1EEF li\u1EC7u s\u1EBD hi\u1EC3n th\u1ECB theo tr\u01B0\u1EDDng v\u1EEBa \u0111\u01B0\u1EE3c ch\u1ECDn', onClose: function () { return setShowBanner(false); }, show: showBanner, title: 'L\u01B0u \u00FD', type: 'warning' })),
|
|
758
|
+
react_2.default.createElement("div", { className: 'relative flex min-h-screen bg-gray-100' },
|
|
759
|
+
react_2.default.createElement(nav_mobile_1.default, { hiddenSideBar: function () { return setSidebarOpen(false); }, menu: dataInitMain.menu, path: pathNameWithBasePath, pathNameWithBasePath: pathNameWithBasePath, permission: dataInitMain.perCode, router: router, setSidebarOpen: setSidebarOpen, sidebarOpen: sidebarOpen }),
|
|
760
|
+
react_2.default.createElement(side_bar_1.default, { currentMenuCode: (currentMenuByPath === null || currentMenuByPath === void 0 ? void 0 : currentMenuByPath.code) || '', dataInitMain: dataInitMain, enablePer: enablePer, isActivityHistory: isActivityHistory(), isSettings: isSettings(), navigation: navigation, setShowSubMenu: setShowSubMenu, showSubMenu: showSubMenu }),
|
|
761
|
+
react_2.default.createElement(react_1.Transition, { as: react_2.Fragment, enter: 'transition ease-in-out duration-[350ms] transform', enterFrom: '-translate-x-[10rem] opacity-0', enterTo: 'translate-x-0', leave: 'transition ease-in-out duration-[350ms] transform', leaveFrom: 'translate-x-0', leaveTo: '-translate-x-[10rem] opacity-0', show: showSubMenu },
|
|
762
|
+
react_2.default.createElement("aside", { className: "fixed left-[4.35rem] top-10 z-10 hidden h-[calc(100vh-3.1rem)] border-gray-300 bg-gray-100 lg:block lg:flex-shrink-0 ".concat(showSubMenu && 'rounded-bl-2xl rounded-tl-2xl border') },
|
|
763
|
+
react_2.default.createElement("div", { className: 'relative flex h-full w-64 flex-col overflow-y-auto bg-gray-200/20' },
|
|
764
|
+
react_2.default.createElement("div", { className: 'mt-3 flex w-full items-center justify-between pl-5 pr-3' },
|
|
765
|
+
react_2.default.createElement("h1", { className: 'text-base font-semibold text-gray-900' }, currentMenuByPath === null || currentMenuByPath === void 0 ? void 0 : currentMenuByPath.name),
|
|
766
|
+
showSubMenu && (react_2.default.createElement("button", { className: 'inline-blockk flex h-7 w-7 items-center justify-center rounded-md hover:bg-white ', onClick: function () { return setShowSubMenu(false); }, type: 'button' },
|
|
767
|
+
react_2.default.createElement(ToolTip_1.default, { content: '\u0110\u00F3ng thanh b\u00EAn' },
|
|
768
|
+
react_2.default.createElement(image_1.default, { alt: 'icon', height: 18, quality: 100, src: Icon_1.IconV2.CLOSE_SIDEBAR, width: 18 }))))),
|
|
769
|
+
checkAdmissions(pathNameWithBasePath) &&
|
|
770
|
+
checkChildrenCampaign(pathNameWithBasePath) &&
|
|
771
|
+
pathNameWithBasePath !== '/admissions/campaign/list' && (react_2.default.createElement("div", { className: 'mx-1 flex items-center p-2 pb-0' },
|
|
772
|
+
react_2.default.createElement("button", { className: 'mr-1 inline-flex items-center rounded-lg border-gray-300 bg-transparent px-2 py-1 text-xs font-medium text-gray-700 hover:bg-gray-200 active:bg-gray-300 active:pb-[0.2rem] active:pt-[0.3rem] active:shadow-[0rem_0.125rem_0.1rem_0rem_#0004_inset]', onClick: function () { return handleBackMenu(); }, type: 'button' },
|
|
773
|
+
react_2.default.createElement(solid_1.ArrowLeftIcon, { className: 'h-5 w-5' })),
|
|
774
|
+
react_2.default.createElement("p", { className: 'text-sm font-medium text-slate-600' }, campaignName))),
|
|
775
|
+
react_2.default.createElement("div", { className: ' mt-2 overflow-y-auto' },
|
|
776
|
+
subNavigation.map(function (item, subNavIndex) {
|
|
777
|
+
var _a;
|
|
778
|
+
var activeChildIndex = item.child.findIndex(function (c) { return c.current; });
|
|
779
|
+
var isChildActive = activeChildIndex !== -1;
|
|
780
|
+
return (react_2.default.createElement("div", { key: subNavIndex }, ((_a = dataInitMain.roleCode) === null || _a === void 0 ? void 0 : _a.length) > 0 ? (react_2.default.createElement(react_2.default.Fragment, null, enablePer(item.code, dataInitMain.perCode) ? (react_2.default.createElement(react_2.default.Fragment, null,
|
|
781
|
+
(item === null || item === void 0 ? void 0 : item.isMicroservice) ? (react_2.default.createElement("a", { "aria-current": (item === null || item === void 0 ? void 0 : item.current) ? 'page' : undefined, "aria-hidden": true, className: (0, types_1.classNames)((item === null || item === void 0 ? void 0 : item.current)
|
|
782
|
+
? 'rounded-lg bg-white' // màu background menu cha khi active
|
|
783
|
+
: 'hover:rounded-lg hover:bg-white hover:bg-opacity-50', // màu background khi hover vào menu cha
|
|
784
|
+
'mx-3 flex cursor-pointer border-slate-200 p-2'), href: item.path }, !dataInitMain.loadingMenu ? (react_2.default.createElement("div", { className: 'ml-1 flex items-center text-[0.84rem]' },
|
|
785
|
+
react_2.default.createElement("div", { className: 'flex items-center gap-x-3' },
|
|
786
|
+
react_2.default.createElement("p", { className: (0, types_1.classNames)('leading-5', (item === null || item === void 0 ? void 0 : item.current) ? '' : 'font-normal text-[#353A44]') }, item === null || item === void 0 ? void 0 : item.name)),
|
|
787
|
+
react_2.default.createElement("p", { className: 'mt-1 text-slate-500' }, item === null || item === void 0 ? void 0 : item.description))) : (react_2.default.createElement(Skeleton_1.PHXSkeleton, { className: 'mr-3 flex-1', type: 'single' })))) : (react_2.default.createElement("div", { "aria-current": (item === null || item === void 0 ? void 0 : item.current) ? 'page' : undefined, "aria-hidden": true, className: (0, types_1.classNames)((item === null || item === void 0 ? void 0 : item.current)
|
|
788
|
+
? 'rounded-lg bg-white' // màu background menu cha khi active
|
|
789
|
+
: 'hover:rounded-lg hover:bg-white hover:bg-opacity-50', // màu background khi hover vào menu cha
|
|
790
|
+
'mx-3 flex cursor-pointer border-slate-200 p-2'), onClick: function () { return subNavigationTriggerClicked(item); } }, !dataInitMain.loadingMenu ? (react_2.default.createElement("div", { className: 'ml-1 flex items-center text-[0.84rem]' },
|
|
791
|
+
react_2.default.createElement("div", { className: 'flex items-center gap-x-2' },
|
|
792
|
+
react_2.default.createElement(image_1.default, { alt: 'icon', height: 16, quality: 100, src:
|
|
793
|
+
// @ts-ignore
|
|
794
|
+
Icon_1.IconV2["".concat(currentMenuByPath === null || currentMenuByPath === void 0 ? void 0 : currentMenuByPath.code, "_OUTLINE")], width: 16 }),
|
|
795
|
+
react_2.default.createElement("p", { className: (0, types_1.classNames)('font-[450] leading-5', isChildActive || item.current ? 'text-gray-900' : ' text-gray-500') }, item === null || item === void 0 ? void 0 : item.name)),
|
|
796
|
+
react_2.default.createElement("p", { className: 'mt-1 text-slate-500' }, item === null || item === void 0 ? void 0 : item.description))) : (react_2.default.createElement(Skeleton_1.PHXSkeleton, { className: 'mr-3 flex-1', type: 'single' })))),
|
|
797
|
+
item.showChild && item.child && (react_2.default.createElement(react_2.default.Fragment, null, item.child.map(function (
|
|
798
|
+
// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
799
|
+
children, childIndex) { return (react_2.default.createElement("div", { key: childIndex, className: (0, types_1.classNames)('relative') },
|
|
800
|
+
childIndex <= activeChildIndex && (react_2.default.createElement("div", { className: "absolute left-8 z-10 w-[1px] bg-gray-400 ".concat((children === null || children === void 0 ? void 0 : children.current) ? 'h-3' : 'bottom-0', " ").concat(childIndex === 0 ? '-top-1' : ' top-0') })),
|
|
801
|
+
react_2.default.createElement("div", { className: "".concat(childIndex === activeChildIndex ? 'block' : 'hidden') },
|
|
802
|
+
react_2.default.createElement(image_1.default, { alt: 'icon', className: 'absolute left-8 top-0 h-6 w-3', height: 1,
|
|
803
|
+
// @ts-ignore
|
|
804
|
+
src: Icon_1.IconV2.ARROW_RIGHT_SUB_MENU, width: 1 }),
|
|
805
|
+
react_2.default.createElement("div", { className: 'absolute left-[33px] top-0 z-10 h-4 w-[1px] bg-white' })),
|
|
806
|
+
(children === null || children === void 0 ? void 0 : children.isMicroservice) ? (react_2.default.createElement("a", { "aria-hidden": true, className: (0, types_1.classNames)('mx-3 flex cursor-pointer border-slate-200 p-2 text-[0.84rem]', (children === null || children === void 0 ? void 0 : children.current)
|
|
807
|
+
? 'rounded-lg bg-white text-[#353A44]' // màu chữ menu con khi active
|
|
808
|
+
: 'hover:rounded-lg hover:bg-white hover:bg-opacity-50 hover:text-[#353A44]'), href: children.path, onClick: enablePer(children.code, dataInitMain.perCode)
|
|
809
|
+
? undefined
|
|
810
|
+
: function (e) { return e.preventDefault(); } },
|
|
811
|
+
react_2.default.createElement("div", { className: 'flex items-center gap-x-3' },
|
|
812
|
+
react_2.default.createElement("div", { className: 'w-3' }),
|
|
813
|
+
react_2.default.createElement("p", { className: (0, types_1.classNames)('my-[0.05rem] ml-3 leading-5', !enablePer(children.code, dataInitMain.perCode)
|
|
814
|
+
? 'font-normal text-gray-300'
|
|
815
|
+
: (children === null || children === void 0 ? void 0 : children.current)
|
|
816
|
+
? ''
|
|
817
|
+
: 'font-normal text-[#353A44]') }, children.name)))) : (react_2.default.createElement("button", { "aria-hidden": true, className: (0, types_1.classNames)('ml-4 w-[90%]', (children === null || children === void 0 ? void 0 : children.current)
|
|
818
|
+
? 'rounded-lg bg-white text-[#353A44]'
|
|
819
|
+
: 'hover:rounded-lg hover:bg-white hover:bg-opacity-50 hover:text-[#353A44]'), onClick: enablePer(children.code, dataInitMain.perCode)
|
|
820
|
+
? function () { return subNavigationTriggerClicked(children, item); }
|
|
821
|
+
: undefined, type: 'button' },
|
|
822
|
+
react_2.default.createElement("p", { className: (0, types_1.classNames)('px-6 py-2 pl-[2.2rem] text-left text-xs', !enablePer(children.code, dataInitMain.perCode)
|
|
823
|
+
? 'font-normal text-gray-300'
|
|
824
|
+
: (children === null || children === void 0 ? void 0 : children.current)
|
|
825
|
+
? 'font-semibold text-gray-900'
|
|
826
|
+
: 'font-normal text-gray-500') }, children.name))))); }))))) : (react_2.default.createElement("div", { "aria-current": (item === null || item === void 0 ? void 0 : item.current) ? 'page' : undefined, className: (0, types_1.classNames)((item === null || item === void 0 ? void 0 : item.current)
|
|
827
|
+
? 'rounded-lg bg-white '
|
|
828
|
+
: 'hover:rounded-lg hover:bg-white hover:bg-opacity-50', // hover:bg-white
|
|
829
|
+
'mx-3 flex cursor-pointer border-slate-200 p-2') }, !dataInitMain.loadingMenu ? (react_2.default.createElement("div", { className: 'ml-1 flex items-center text-[0.84rem]' },
|
|
830
|
+
react_2.default.createElement("div", { className: 'flex items-center gap-x-3 text-gray-700' },
|
|
831
|
+
react_2.default.createElement("p", { className: (0, types_1.classNames)('font-normal leading-5 text-gray-300') }, item === null || item === void 0 ? void 0 : item.name)),
|
|
832
|
+
react_2.default.createElement("p", { className: 'mt-1 text-slate-500' }, item === null || item === void 0 ? void 0 : item.description))) : (react_2.default.createElement(Skeleton_1.PHXSkeleton, { className: 'mr-3 flex-1', type: 'single' })))))) : (react_2.default.createElement(react_2.default.Fragment, null,
|
|
833
|
+
(item === null || item === void 0 ? void 0 : item.isMicroservice) ? (react_2.default.createElement("a", { "aria-current": (item === null || item === void 0 ? void 0 : item.current) ? 'page' : undefined, "aria-hidden": true, className: (0, types_1.classNames)((item === null || item === void 0 ? void 0 : item.current)
|
|
834
|
+
? 'rounded-lg bg-white' // màu background menu cha khi active
|
|
835
|
+
: 'hover:rounded-lg hover:bg-white hover:bg-opacity-50', // màu background khi hover vào menu cha
|
|
836
|
+
'mx-3 flex cursor-pointer border-slate-200 p-2'), href: item.path }, !dataInitMain.loadingMenu ? (react_2.default.createElement("div", { className: 'ml-1 flex items-center text-[0.84rem]' },
|
|
837
|
+
react_2.default.createElement("div", { className: 'flex items-center gap-x-3' },
|
|
838
|
+
react_2.default.createElement("p", { className: (0, types_1.classNames)('leading-5', (item === null || item === void 0 ? void 0 : item.current) ? '' : 'font-normal text-[#353A44]') }, item === null || item === void 0 ? void 0 : item.name)),
|
|
839
|
+
react_2.default.createElement("p", { className: 'mt-1 text-slate-500' }, item === null || item === void 0 ? void 0 : item.description))) : (react_2.default.createElement(Skeleton_1.PHXSkeleton, { className: 'mr-3 flex-1', type: 'single' })))) : (react_2.default.createElement("div", { "aria-current": (item === null || item === void 0 ? void 0 : item.current) ? 'page' : undefined, "aria-hidden": true, className: (0, types_1.classNames)((item === null || item === void 0 ? void 0 : item.current)
|
|
840
|
+
? 'rounded-lg bg-white' // màu background menu cha khi active
|
|
841
|
+
: 'hover:rounded-lg hover:bg-white hover:bg-opacity-50', // màu background khi hover vào menu cha
|
|
842
|
+
'mx-3 flex cursor-pointer border-slate-200 p-2'), onClick: function () { return subNavigationTriggerClicked(item); } }, !dataInitMain.loadingMenu ? (react_2.default.createElement("div", { className: 'ml-1 flex items-center text-[0.84rem]' },
|
|
843
|
+
react_2.default.createElement("div", { className: 'flex items-center gap-x-3' },
|
|
844
|
+
react_2.default.createElement("p", { className: (0, types_1.classNames)('leading-5', (item === null || item === void 0 ? void 0 : item.current) ? '' : 'font-normal text-[#353A44]') }, item === null || item === void 0 ? void 0 : item.name)),
|
|
845
|
+
react_2.default.createElement("p", { className: 'mt-1 text-slate-500' }, item === null || item === void 0 ? void 0 : item.description))) : (react_2.default.createElement(Skeleton_1.PHXSkeleton, { className: 'mr-3 flex-1', type: 'single' })))),
|
|
846
|
+
item.showChild && item.child && (react_2.default.createElement(react_2.default.Fragment, null, item.child.map(
|
|
847
|
+
// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
848
|
+
function (children, index) { return (react_2.default.createElement("div", { key: index, className: (0, types_1.classNames)('relative', (children === null || children === void 0 ? void 0 : children.current) && 'child-menu-active', checkChildBefore(item.child, children) && 'child-menu-bef') }, (children === null || children === void 0 ? void 0 : children.isMicroservice) ? (react_2.default.createElement("a", { "aria-hidden": true, className: (0, types_1.classNames)('mx-1 flex cursor-pointer border-slate-200 p-2 text-[0.84rem]', (children === null || children === void 0 ? void 0 : children.current)
|
|
849
|
+
? 'rounded-lg bg-white text-gray-900 '
|
|
850
|
+
: 'hover:rounded-lg hover:bg-white hover:bg-opacity-50 hover:text-gray-900'), href: item.path },
|
|
851
|
+
react_2.default.createElement("div", { className: 'flex items-center gap-x-3' },
|
|
852
|
+
react_2.default.createElement("div", { className: 'w-3' }),
|
|
853
|
+
react_2.default.createElement("p", { className: (0, types_1.classNames)('my-[0.05rem] ml-3 leading-5', (children === null || children === void 0 ? void 0 : children.current) ? 'font-semibold' : 'font-normal text-gray-600') }, children.name)))) : (react_2.default.createElement("div", { "aria-hidden": true, className: (0, types_1.classNames)('mx-1 flex cursor-pointer border-slate-200 p-2 text-[0.84rem]', (children === null || children === void 0 ? void 0 : children.current)
|
|
854
|
+
? 'rounded-lg bg-white text-gray-900 '
|
|
855
|
+
: 'hover:rounded-lg hover:bg-white hover:bg-opacity-50 hover:text-gray-900'), onClick: function () { return subNavigationTriggerClicked(children, item); } },
|
|
856
|
+
react_2.default.createElement("div", { className: 'flex items-center gap-x-3' },
|
|
857
|
+
react_2.default.createElement("div", { className: 'w-3' }),
|
|
858
|
+
react_2.default.createElement("p", { className: (0, types_1.classNames)('my-[0.05rem] ml-3 leading-5', (children === null || children === void 0 ? void 0 : children.current) ? 'font-semibold' : 'font-normal text-gray-600') }, children.name)))))); })))))));
|
|
859
|
+
}),
|
|
860
|
+
activityHistoryChild.map(function (item, subNavIndex) { return (react_2.default.createElement("div", { key: subNavIndex },
|
|
861
|
+
react_2.default.createElement("div", { "aria-current": (item === null || item === void 0 ? void 0 : item.current) ? 'page' : undefined, "aria-hidden": true, className: (0, types_1.classNames)((item === null || item === void 0 ? void 0 : item.current) && !dataInitMain.loadingMenu
|
|
862
|
+
? 'rounded-lg bg-white' // màu background menu cha khi active
|
|
863
|
+
: 'hover:rounded-lg hover:bg-white hover:bg-opacity-50', // màu background khi hover vào menu cha
|
|
864
|
+
'mx-3 flex cursor-pointer border-slate-200 p-2'), onClick: function () {
|
|
865
|
+
handleClickActivityHistoryChild(item);
|
|
866
|
+
subNavigationTriggerClicked(item);
|
|
867
|
+
} }, !dataInitMain.loadingMenu ? (react_2.default.createElement("div", { className: 'ml-1 flex items-center text-[0.84rem]' },
|
|
868
|
+
react_2.default.createElement("div", { className: 'flex items-center gap-x-3' },
|
|
869
|
+
react_2.default.createElement("p", { className: (0, types_1.classNames)('leading-5', (item === null || item === void 0 ? void 0 : item.current) ? '' : 'font-normal text-[#353A44]') }, item === null || item === void 0 ? void 0 : item.name)),
|
|
870
|
+
react_2.default.createElement("p", { className: 'mt-1 text-slate-500' }, item === null || item === void 0 ? void 0 : item.description))) : ('')))); }))))),
|
|
871
|
+
react_2.default.createElement("main", { className: 'w-full pb-2.5 pt-10 lg:pl-[4.5rem] lg:pr-[0.5rem]' },
|
|
872
|
+
react_2.default.createElement("div", { className: 'h-full w-full border-gray-300 lg:overflow-y-auto lg:rounded-2xl lg:border-[0.75px]' }, dataInitMain.isLoadingPermission ? ('') : enablePer(currentCode, dataInitMain.perCode) ? (react_2.default.createElement("div", { className: "h-full bg-gray-50 ".concat(showSubMenu ? 'pl-4 lg:pl-[16.9rem]' : 'pl-4', " py-4 pr-4 transition-all duration-300") }, children)) : (react_2.default.createElement(Card_1.PHXCard, null,
|
|
873
|
+
react_2.default.createElement("div", { className: 'mb-10 mt-10 sm:mb-20 sm:mt-20 lg:mb-32 lg:mt-32' },
|
|
874
|
+
react_2.default.createElement("div", { className: 'flex items-center justify-center' },
|
|
875
|
+
react_2.default.createElement(outline_1.LockClosedIcon, { className: 'text-gray-400', height: 70, width: 70 })),
|
|
876
|
+
react_2.default.createElement("div", { className: 'mt-5 flex select-none items-center justify-center text-base font-bold text-gray-800' }, "B\u1EA1n kh\u00F4ng c\u00F3 quy\u1EC1n truy c\u1EADp")))))))));
|
|
877
|
+
};
|
|
878
|
+
exports.PHXMainWrapV4 = PHXMainWrapV4;
|
|
879
|
+
//# sourceMappingURL=MainWrapV4.js.map
|