update menu event alarm

This commit is contained in:
2025-10-23 12:57:54 +07:00
parent 4f518dba9c
commit 8c9ef41704
3 changed files with 46 additions and 86 deletions

View File

@@ -32,9 +32,6 @@ import IndexEventAlarm from './pages/eventAlarm/IndexEventAlarm';
import IndexRole from './pages/role/IndexRole';
import IndexUser from './pages/user/IndexUser';
// Shift Management
import IndexMember from './pages/shiftManagement/member/IndexMember';
import SvgTest from './pages/home/SvgTest';
import SvgOverview from './pages/home/SvgOverview';
import SvgCompressorA from './pages/home/SvgCompressorA';
@@ -81,21 +78,18 @@ const App = () => {
<Route path="status" element={<IndexStatus />} />
</Route>
<Route path="/jadwal-shift" element={<ProtectedRoute />}>
<Route index element={<IndexJadwalShift />} />
</Route>
<Route path="/history" element={<ProtectedRoute />}>
<Route path="/report" element={<ProtectedRoute />}>
<Route path="trending" element={<IndexTrending />} />
<Route path="report" element={<IndexReport />} />
</Route>
<Route path="/notification" element={<ProtectedRoute />}>
<Route index element={<IndexNotification />} />
<Route path="/history" element={<ProtectedRoute />}>
<Route path="alarm" element={<IndexEventAlarm />} />
<Route path="event" element={<IndexEventAlarm />} />
</Route>
<Route path="/event-alarm" element={<ProtectedRoute />}>
<Route index element={<IndexEventAlarm />} />
<Route path="/notification" element={<ProtectedRoute />}>
<Route index element={<IndexNotification />} />
</Route>
<Route path="/role" element={<ProtectedRoute />}>
@@ -106,8 +100,8 @@ const App = () => {
<Route index element={<IndexUser />} />
</Route>
<Route path="/shift-management" element={<ProtectedRoute />}>
<Route path="member" element={<IndexMember />} />
<Route path="/jadwal-shift" element={<ProtectedRoute />}>
<Route index element={<IndexJadwalShift />} />
</Route>
{/* Catch-all */}

View File

@@ -29,6 +29,8 @@ import {
DesktopOutlined,
NodeExpandOutlined,
GroupOutlined,
SlidersOutlined,
SnippetsOutlined,
} from '@ant-design/icons';
const { Text } = Typography;
@@ -93,7 +95,7 @@ const allItems = [
{
key: 'master-plant-section',
icon: <ProductOutlined style={{ fontSize: '19px' }} />,
label: <Link to="/master/plant-section">Plant Section</Link>,
label: <Link to="/master/plant-section">Plant Sub Section</Link>,
},
{
key: 'master-brand-device',
@@ -127,20 +129,37 @@ const allItems = [
},
],
},
{
key: 'report',
icon: <SnippetsOutlined style={{ fontSize: '19px' }} />,
label: 'Report',
children: [
{
key: 'report-trending',
icon: <LineChartOutlined style={{ fontSize: '19px' }} />,
label: <Link to="/report/trending">Trending</Link>,
},
{
key: 'report-report',
icon: <FileTextOutlined style={{ fontSize: '19px' }} />,
label: <Link to="/report/report">Report</Link>,
},
],
},
{
key: 'history',
icon: <HistoryOutlined style={{ fontSize: '19px' }} />,
label: 'History',
children: [
{
key: 'history-trending',
icon: <LineChartOutlined style={{ fontSize: '19px' }} />,
label: <Link to="/history/trending">Trending</Link>,
key: 'history-alarm',
icon: <AlertOutlined style={{ fontSize: '19px' }} />,
label: <Link to="/history/alarm">Alarm</Link>,
},
{
key: 'history-report',
icon: <FileTextOutlined style={{ fontSize: '19px' }} />,
label: <Link to="/history/report">Report</Link>,
key: 'history-event',
icon: <SlidersOutlined style={{ fontSize: '19px' }} />,
label: <Link to="/history/event">Event</Link>,
},
],
},
@@ -149,16 +168,7 @@ const allItems = [
icon: <BellOutlined style={{ fontSize: '19px' }} />,
label: (
<Link to="/notification" className="fontMenus">
Notifikasi
</Link>
),
},
{
key: 'event-alarm',
icon: <AlertOutlined style={{ fontSize: '19px' }} />,
label: (
<Link to="/event-alarm" className="fontMenus">
Event Alarm
Notification
</Link>
),
},
@@ -206,9 +216,7 @@ const LayoutMenu = () => {
if (pathname === '/user') return 'user';
if (pathname === '/role') return 'role';
if (pathname === '/notification') return 'notification';
if (pathname === '/event-alarm') return 'event-alarm';
if (pathname === '/jadwal-shift') return 'jadwal-shift';
if (pathname === '/dashboard-svg') return 'dashboard-svg';
// Handle master routes
if (pathname.startsWith('/master/')) {
@@ -216,24 +224,24 @@ const LayoutMenu = () => {
return `master-${subPath}`;
}
// Handle master routes
// Handle dashboard svg routes
if (pathname.startsWith('/dashboard-svg/')) {
const subPath = pathParts[1];
return `dashboard-svg-${subPath}`;
}
// Handle report routes
if (pathname.startsWith('/report/')) {
const subPath = pathParts[1];
return `report-${subPath}`;
}
// Handle history routes
if (pathname.startsWith('/history/')) {
const subPath = pathParts[1];
return `history-${subPath}`;
}
// Handle shift management routes
if (pathname.startsWith('/shift-management/')) {
const subPath = pathParts[1];
return `shift-${subPath}`;
}
return 'home'; // default
};
@@ -241,8 +249,8 @@ const LayoutMenu = () => {
const getParentKey = (key) => {
if (key.startsWith('master-')) return 'master';
if (key.startsWith('dashboard-svg-')) return 'dashboard-svg';
if (key.startsWith('report-')) return 'report';
if (key.startsWith('history-')) return 'history';
if (key.startsWith('shift-')) return 'shift-management';
return null;
};

View File

@@ -104,8 +104,8 @@ const ListEventAlarm = memo(function ListEventAlarm(props) {
width: '15%',
},
];
const [trigerFilter, setTrigerFilter] = useState(false);
const [alarmsData] = useState(initialAlarmsData);
const defaultFilter = { search: '' };
const [formDataFilter, setFormDataFilter] = useState(defaultFilter);
@@ -115,50 +115,8 @@ const ListEventAlarm = memo(function ListEventAlarm(props) {
// Dummy data function to simulate API call
const getAllEventAlarm = async (params) => {
// Simulate API delay
await new Promise((resolve) => setTimeout(resolve, 300));
// Extract URLSearchParams
const searchParam = params.get('search') || '';
const page = parseInt(params.get('page')) || 1;
const limit = parseInt(params.get('limit')) || 10;
console.log('getAllEventAlarm called with:', { searchParam, page, limit });
// Filter by search
let filteredAlarms = alarmsData;
if (searchParam) {
const searchLower = searchParam.toLowerCase();
filteredAlarms = alarmsData.filter(
(alarm) =>
alarm.tanggal.toLowerCase().includes(searchLower) ||
alarm.plant_sub_section.toLowerCase().includes(searchLower) ||
alarm.device.toLowerCase().includes(searchLower) ||
alarm.tag.toLowerCase().includes(searchLower) ||
alarm.engineer.toLowerCase().includes(searchLower)
);
}
// Pagination logic
const totalData = filteredAlarms.length;
const totalPages = Math.ceil(totalData / limit);
const startIndex = (page - 1) * limit;
const endIndex = startIndex + limit;
const paginatedData = filteredAlarms.slice(startIndex, endIndex);
return {
status: 200,
statusCode: 200,
data: {
data: paginatedData,
total: totalData,
paging: {
page: page,
limit: limit,
total: totalData,
page_total: totalPages,
},
},
data: initialAlarmsData,
};
};
@@ -172,7 +130,7 @@ const ListEventAlarm = memo(function ListEventAlarm(props) {
} else {
navigate('/signin');
}
}, [props.actionMode, alarmsData]);
}, [props.actionMode]);
const doFilter = () => {
setTrigerFilter((prev) => !prev);