hidden jadwal shift and master-shift
This commit is contained in:
@@ -76,7 +76,7 @@ const allItems = [
|
||||
icon: <NodeExpandOutlined style={{ fontSize: '19px' }} />,
|
||||
label: <Link to="/dashboard-svg/compressor-c">Compressor C</Link>,
|
||||
},
|
||||
]
|
||||
],
|
||||
},
|
||||
{
|
||||
key: 'dashboard-svg-airdryer',
|
||||
@@ -103,7 +103,7 @@ const allItems = [
|
||||
icon: <NodeExpandOutlined style={{ fontSize: '19px' }} />,
|
||||
label: <Link to="/dashboard-svg/airdryer-c">Air Dryer C</Link>,
|
||||
},
|
||||
]
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -142,11 +142,11 @@ const allItems = [
|
||||
icon: <SafetyOutlined style={{ fontSize: '19px' }} />,
|
||||
label: <Link to="/master/status">Status</Link>,
|
||||
},
|
||||
{
|
||||
key: 'master-shift',
|
||||
icon: <ClockCircleOutlined style={{ fontSize: '19px' }} />,
|
||||
label: <Link to="/master/shift">Shift</Link>,
|
||||
},
|
||||
// {
|
||||
// key: 'master-shift',
|
||||
// icon: <ClockCircleOutlined style={{ fontSize: '19px' }} />,
|
||||
// label: <Link to="/master/shift">Shift</Link>,
|
||||
// },
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -219,15 +219,15 @@ const allItems = [
|
||||
</Link>
|
||||
),
|
||||
},
|
||||
{
|
||||
key: 'jadwal-shift',
|
||||
icon: <CalendarOutlined style={{ fontSize: '19px' }} />,
|
||||
label: (
|
||||
<Link to="/jadwal-shift" className="fontMenus">
|
||||
Jadwal Shift
|
||||
</Link>
|
||||
),
|
||||
},
|
||||
// {
|
||||
// key: 'jadwal-shift',
|
||||
// icon: <CalendarOutlined style={{ fontSize: '19px' }} />,
|
||||
// label: (
|
||||
// <Link to="/jadwal-shift" className="fontMenus">
|
||||
// Jadwal Shift
|
||||
// </Link>
|
||||
// ),
|
||||
// },
|
||||
];
|
||||
|
||||
const LayoutMenu = () => {
|
||||
@@ -255,11 +255,11 @@ const LayoutMenu = () => {
|
||||
const masterKeyMap = {
|
||||
'plant-sub-section': 'master-plant-sub-section',
|
||||
'brand-device': 'master-brand-device',
|
||||
'device': 'master-device',
|
||||
'unit': 'master-unit',
|
||||
'tag': 'master-tag',
|
||||
'status': 'master-status',
|
||||
'shift': 'master-shift'
|
||||
device: 'master-device',
|
||||
unit: 'master-unit',
|
||||
tag: 'master-tag',
|
||||
status: 'master-status',
|
||||
shift: 'master-shift',
|
||||
};
|
||||
return masterKeyMap[subPath] || `master-${subPath}`;
|
||||
}
|
||||
@@ -276,7 +276,7 @@ const LayoutMenu = () => {
|
||||
if (subPath === 'airdryer-a') return 'dashboard-svg-airdryer-airdryer-a';
|
||||
if (subPath === 'airdryer-b') return 'dashboard-svg-airdryer-airdryer-b';
|
||||
if (subPath === 'airdryer-c') return 'dashboard-svg-airdryer-airdryer-c';
|
||||
|
||||
|
||||
return `dashboard-svg-${subPath}`;
|
||||
}
|
||||
|
||||
@@ -284,8 +284,8 @@ const LayoutMenu = () => {
|
||||
if (pathname.startsWith('/report/')) {
|
||||
const subPath = pathParts[1];
|
||||
const reportKeyMap = {
|
||||
'trending': 'report-trending',
|
||||
'report': 'report-report'
|
||||
trending: 'report-trending',
|
||||
report: 'report-report',
|
||||
};
|
||||
return reportKeyMap[subPath] || `report-${subPath}`;
|
||||
}
|
||||
@@ -294,8 +294,8 @@ const LayoutMenu = () => {
|
||||
if (pathname.startsWith('/history/')) {
|
||||
const subPath = pathParts[1];
|
||||
const historyKeyMap = {
|
||||
'alarm': 'history-alarm',
|
||||
'event': 'history-event'
|
||||
alarm: 'history-alarm',
|
||||
event: 'history-event',
|
||||
};
|
||||
return historyKeyMap[subPath] || `history-${subPath}`;
|
||||
}
|
||||
@@ -306,7 +306,7 @@ const LayoutMenu = () => {
|
||||
// Function to get parent keys from menu key
|
||||
const getParentKeys = (key) => {
|
||||
const parentKeys = [];
|
||||
|
||||
|
||||
if (key.startsWith('dashboard-svg-compressor-')) {
|
||||
parentKeys.push('dashboard-svg', 'dashboard-svg-compressor');
|
||||
} else if (key.startsWith('dashboard-svg-airdryer-')) {
|
||||
@@ -320,7 +320,7 @@ const LayoutMenu = () => {
|
||||
} else if (key.startsWith('history-')) {
|
||||
parentKeys.push('history');
|
||||
}
|
||||
|
||||
|
||||
return parentKeys;
|
||||
};
|
||||
|
||||
@@ -330,7 +330,7 @@ const LayoutMenu = () => {
|
||||
setSelectedKeys([currentKey]);
|
||||
|
||||
const parentKeys = getParentKeys(currentKey);
|
||||
|
||||
|
||||
// Always keep the parent menus open when a child is selected
|
||||
if (parentKeys.length > 0) {
|
||||
setStateOpenKeys(parentKeys);
|
||||
@@ -359,13 +359,13 @@ const LayoutMenu = () => {
|
||||
|
||||
const onOpenChange = (openKeys) => {
|
||||
const currentOpenKey = openKeys.find((key) => stateOpenKeys.indexOf(key) === -1);
|
||||
|
||||
|
||||
// If clicking on a menu that was previously closed
|
||||
if (currentOpenKey !== undefined) {
|
||||
const repeatIndex = openKeys
|
||||
.filter((key) => key !== currentOpenKey)
|
||||
.findIndex((key) => levelKeys[key] === levelKeys[currentOpenKey]);
|
||||
|
||||
|
||||
setStateOpenKeys(
|
||||
openKeys
|
||||
.filter((_, index) => index !== repeatIndex)
|
||||
@@ -376,12 +376,10 @@ const LayoutMenu = () => {
|
||||
// but keep other parent menus open if they have active children
|
||||
const currentKey = getMenuKeyFromPath(location.pathname);
|
||||
const necessaryParentKeys = getParentKeys(currentKey);
|
||||
|
||||
|
||||
// Filter out only the menus that are necessary to keep open
|
||||
const filteredOpenKeys = openKeys.filter(key =>
|
||||
necessaryParentKeys.includes(key)
|
||||
);
|
||||
|
||||
const filteredOpenKeys = openKeys.filter((key) => necessaryParentKeys.includes(key));
|
||||
|
||||
setStateOpenKeys(filteredOpenKeys);
|
||||
}
|
||||
};
|
||||
@@ -391,9 +389,7 @@ const LayoutMenu = () => {
|
||||
|
||||
const karyawan = () => {
|
||||
return allItems
|
||||
.filter(
|
||||
(item) => item.key !== 'setting'
|
||||
)
|
||||
.filter((item) => item.key !== 'setting')
|
||||
.map((item) => {
|
||||
if (item.key === 'master') {
|
||||
return {
|
||||
@@ -403,7 +399,7 @@ const LayoutMenu = () => {
|
||||
return item;
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
const items = isAdmin === 1 ? allItems : karyawan();
|
||||
|
||||
return (
|
||||
@@ -423,4 +419,4 @@ const LayoutMenu = () => {
|
||||
/>
|
||||
);
|
||||
};
|
||||
export default LayoutMenu;
|
||||
export default LayoutMenu;
|
||||
|
||||
Reference in New Issue
Block a user