mirror of
https://github.com/orangecoding/fredy.git
synced 2026-06-16 12:31:07 +00:00
* ui-improvements * improving dashboard and settings * improve job overview * improving job card * improving grid view of listings+ * restructuring settings * next release version
87 lines
2.4 KiB
JavaScript
87 lines
2.4 KiB
JavaScript
/*
|
|
* Copyright (c) 2026 by Christian Kellner.
|
|
* Licensed under Apache-2.0 with Commons Clause and Attribution/Naming Clause
|
|
*/
|
|
|
|
import { useEffect, useState } from 'react';
|
|
import { Button, Nav } from '@douyinfe/semi-ui-19';
|
|
import { IconStar, IconSetting, IconTerminal, IconHistogram, IconSidebar } from '@douyinfe/semi-icons';
|
|
import logoWhite from '../../assets/logo_white.png';
|
|
import heart from '../../assets/heart.png';
|
|
import Logout from '../logout/Logout.jsx';
|
|
import { useLocation, useNavigate } from 'react-router-dom';
|
|
|
|
import './Navigate.less';
|
|
import { useScreenWidth } from '../../hooks/screenWidth.js';
|
|
|
|
export default function Navigation({ isAdmin }) {
|
|
const navigate = useNavigate();
|
|
const location = useLocation();
|
|
|
|
const width = useScreenWidth();
|
|
const [collapsed, setCollapsed] = useState(width <= 850);
|
|
|
|
useEffect(() => {
|
|
if (width <= 850) {
|
|
setCollapsed(true);
|
|
}
|
|
}, [width]);
|
|
|
|
const items = [
|
|
{ itemKey: '/dashboard', text: 'Dashboard', icon: <IconHistogram /> },
|
|
{ itemKey: '/jobs', text: 'Jobs', icon: <IconTerminal /> },
|
|
{
|
|
itemKey: 'listings',
|
|
text: 'Listings',
|
|
icon: <IconStar />,
|
|
items: [
|
|
{ itemKey: '/listings', text: 'Overview' },
|
|
{ itemKey: '/map', text: 'Map View' },
|
|
],
|
|
},
|
|
];
|
|
|
|
if (isAdmin) {
|
|
items.push({
|
|
itemKey: 'settings',
|
|
text: 'Settings',
|
|
icon: <IconSetting />,
|
|
items: [
|
|
{ itemKey: '/users', text: 'User Management' },
|
|
{ itemKey: '/generalSettings', text: 'Settings' },
|
|
],
|
|
});
|
|
} else {
|
|
items.push({
|
|
itemKey: 'settings',
|
|
text: 'Settings',
|
|
icon: <IconSetting />,
|
|
items: [{ itemKey: '/generalSettings', text: 'Settings' }],
|
|
});
|
|
}
|
|
|
|
function parsePathName(name) {
|
|
const split = name.split('/').filter((s) => s.length !== 0);
|
|
return '/' + split[0];
|
|
}
|
|
|
|
return (
|
|
<Nav
|
|
style={{ height: '100%', maxWidth: collapsed ? '60px' : '240px' }}
|
|
items={items}
|
|
isCollapsed={collapsed}
|
|
selectedKeys={[parsePathName(location.pathname)]}
|
|
onSelect={(key) => {
|
|
navigate(key.itemKey);
|
|
}}
|
|
header={<img src={collapsed ? heart : logoWhite} width={collapsed ? '30' : '120'} alt="Fredy Logo" />}
|
|
footer={
|
|
<Nav.Footer className="navigate__footer">
|
|
<Logout text={!collapsed} />
|
|
<Button icon={<IconSidebar />} onClick={() => setCollapsed(!collapsed)} />
|
|
</Nav.Footer>
|
|
}
|
|
/>
|
|
);
|
|
}
|