207 lines
5.7 KiB
JavaScript
207 lines
5.7 KiB
JavaScript
import { useLocation } from 'react-router-dom'
|
|
import DashboardSidebar from '../common/DashboardSidebar'
|
|
import FilamentIcon from '../../Icons/FilamentIcon'
|
|
import PartIcon from '../../Icons/PartIcon'
|
|
import ProductIcon from '../../Icons/ProductIcon'
|
|
import VendorIcon from '../../Icons/VendorIcon'
|
|
import MaterialIcon from '../../Icons/MaterialIcon'
|
|
import NoteTypeIcon from '../../Icons/NoteTypeIcon'
|
|
import SettingsIcon from '../../Icons/SettingsIcon'
|
|
import AuditLogIcon from '../../Icons/AuditLogIcon'
|
|
import DeveloperIcon from '../../Icons/DeveloperIcon'
|
|
import PersonIcon from '../../Icons/PersonIcon'
|
|
import HostIcon from '../../Icons/HostIcon'
|
|
import DocumentPrinterIcon from '../../Icons/DocumentPrinterIcon'
|
|
import DocumentTemplateIcon from '../../Icons/DocumentTemplateIcon'
|
|
import DocumentIcon from '../../Icons/DocumentIcon'
|
|
import DocumentSizeIcon from '../../Icons/DocumentSizeIcon'
|
|
import DocumentJobIcon from '../../Icons/DocumentJobIcon'
|
|
import FileIcon from '../../Icons/FileIcon'
|
|
import CourierIcon from '../../Icons/CourierIcon'
|
|
import CourierServiceIcon from '../../Icons/CourierServiceIcon'
|
|
import TaxRateIcon from '../../Icons/TaxRateIcon'
|
|
import TaxRecordIcon from '../../Icons/TaxRecordIcon'
|
|
|
|
const items = [
|
|
{
|
|
key: 'filaments',
|
|
icon: <FilamentIcon />,
|
|
label: 'Filaments',
|
|
path: '/dashboard/management/filaments'
|
|
},
|
|
{
|
|
key: 'parts',
|
|
icon: <PartIcon />,
|
|
label: 'Parts',
|
|
path: '/dashboard/management/parts'
|
|
},
|
|
{
|
|
key: 'products',
|
|
icon: <ProductIcon />,
|
|
label: 'Products',
|
|
path: '/dashboard/management/products'
|
|
},
|
|
{
|
|
key: 'vendors',
|
|
icon: <VendorIcon />,
|
|
label: 'Vendors',
|
|
path: '/dashboard/management/vendors'
|
|
},
|
|
{
|
|
key: 'materials',
|
|
icon: <MaterialIcon />,
|
|
label: 'Materials',
|
|
path: '/dashboard/management/materials'
|
|
},
|
|
{ type: 'divider' },
|
|
{
|
|
key: 'couriers',
|
|
icon: <CourierIcon />,
|
|
label: 'Couriers',
|
|
path: '/dashboard/management/couriers'
|
|
},
|
|
{
|
|
key: 'courierServices',
|
|
icon: <CourierServiceIcon />,
|
|
label: 'Courier Services',
|
|
path: '/dashboard/management/courierservices'
|
|
},
|
|
{ type: 'divider' },
|
|
{
|
|
key: 'taxRates',
|
|
icon: <TaxRateIcon />,
|
|
label: 'Tax Rates',
|
|
path: '/dashboard/management/taxrates'
|
|
},
|
|
{
|
|
key: 'taxRecords',
|
|
icon: <TaxRecordIcon />,
|
|
label: 'Tax Records',
|
|
path: '/dashboard/management/taxrecords'
|
|
},
|
|
{ type: 'divider' },
|
|
{
|
|
key: 'noteTypes',
|
|
icon: <NoteTypeIcon />,
|
|
label: 'Note Types',
|
|
path: '/dashboard/management/notetypes'
|
|
},
|
|
{
|
|
key: 'documents',
|
|
icon: <DocumentIcon />,
|
|
label: 'Documents',
|
|
children: [
|
|
{
|
|
key: 'documentPrinters',
|
|
icon: <DocumentPrinterIcon />,
|
|
label: 'Document Printers',
|
|
path: '/dashboard/management/documentprinters'
|
|
},
|
|
{
|
|
key: 'documentJobs',
|
|
icon: <DocumentJobIcon />,
|
|
label: 'Document Jobs',
|
|
path: '/dashboard/management/documentjobs'
|
|
},
|
|
{
|
|
key: 'documentTemplates',
|
|
icon: <DocumentTemplateIcon />,
|
|
label: 'Document Templates',
|
|
path: '/dashboard/management/documenttemplates'
|
|
},
|
|
{
|
|
key: 'documentSizes',
|
|
icon: <DocumentSizeIcon />,
|
|
label: 'Document Sizes',
|
|
path: '/dashboard/management/documentsizes'
|
|
}
|
|
]
|
|
},
|
|
{ type: 'divider' },
|
|
{
|
|
key: 'hosts',
|
|
icon: <HostIcon />,
|
|
label: 'Hosts',
|
|
path: '/dashboard/management/hosts'
|
|
},
|
|
{ type: 'divider' },
|
|
{
|
|
key: 'users',
|
|
icon: <PersonIcon />,
|
|
label: 'Users',
|
|
path: '/dashboard/management/users'
|
|
},
|
|
{
|
|
key: 'settings',
|
|
icon: <SettingsIcon />,
|
|
label: 'Settings',
|
|
path: '/dashboard/management/settings'
|
|
},
|
|
{
|
|
key: 'files',
|
|
icon: <FileIcon />,
|
|
label: 'Files',
|
|
path: '/dashboard/management/files'
|
|
},
|
|
{
|
|
key: 'auditLogs',
|
|
icon: <AuditLogIcon />,
|
|
label: 'Audit Logs',
|
|
path: '/dashboard/management/auditlogs'
|
|
}
|
|
]
|
|
|
|
if (import.meta.env.MODE === 'development') {
|
|
items.push(
|
|
{ type: 'divider' },
|
|
{
|
|
key: 'developer',
|
|
icon: <DeveloperIcon />,
|
|
label: 'Developer',
|
|
path: '/dashboard/developer/sessionstorage'
|
|
}
|
|
)
|
|
}
|
|
|
|
const routeKeyMap = {
|
|
'/dashboard/management/filaments': 'filaments',
|
|
'/dashboard/management/parts': 'parts',
|
|
'/dashboard/management/users': 'users',
|
|
'/dashboard/management/products': 'products',
|
|
'/dashboard/management/vendors': 'vendors',
|
|
'/dashboard/management/couriers': 'couriers',
|
|
'/dashboard/management/courierservices': 'courierServices',
|
|
'/dashboard/management/taxrates': 'taxRates',
|
|
'/dashboard/management/taxrecords': 'taxRecords',
|
|
'/dashboard/management/materials': 'materials',
|
|
'/dashboard/management/notetypes': 'noteTypes',
|
|
'/dashboard/management/settings': 'settings',
|
|
'/dashboard/management/auditlogs': 'auditLogs',
|
|
'/dashboard/management/files': 'files',
|
|
'/dashboard/management/hosts': 'hosts',
|
|
'/dashboard/management/documentsizes': 'documentSizes',
|
|
'/dashboard/management/documentprinters': 'documentPrinters',
|
|
'/dashboard/management/documenttemplates': 'documentTemplates',
|
|
'/dashboard/management/documentjobs': 'documentJobs'
|
|
}
|
|
|
|
const ManagementSidebar = (props) => {
|
|
const location = useLocation()
|
|
const selectedKey = (() => {
|
|
const match = Object.keys(routeKeyMap).find((path) => {
|
|
const pathSplit = path.split('/')
|
|
const locationPathSplit = location.pathname.split('/')
|
|
if (pathSplit.length > locationPathSplit.length) return false
|
|
for (let i = 0; i < pathSplit.length; i++) {
|
|
if (pathSplit[i] !== locationPathSplit[i]) return false
|
|
}
|
|
return true
|
|
})
|
|
return match ? routeKeyMap[match] : 'filaments'
|
|
})()
|
|
|
|
return <DashboardSidebar items={items} selectedKey={selectedKey} {...props} />
|
|
}
|
|
|
|
export default ManagementSidebar
|