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