import { useLocation } from 'react-router-dom'
import DashboardSidebar from '../common/DashboardSidebar'
import ClientIcon from '../../Icons/ClientIcon'
import SalesIcon from '../../Icons/SalesIcon'
import SalesOrderIcon from '../../Icons/SalesOrderIcon'
const items = [
{
key: 'overview',
label: 'Overview',
icon: ,
path: '/dashboard/sales/overview'
},
{ type: 'divider' },
{
key: 'clients',
label: 'Clients',
icon: ,
path: '/dashboard/sales/clients'
},
{
key: 'salesorders',
label: 'Sales Orders',
icon: ,
path: '/dashboard/sales/salesorders'
}
]
const routeKeyMap = {
'/dashboard/sales/overview': 'overview',
'/dashboard/sales/clients': 'clients',
'/dashboard/sales/salesorders': 'salesorders'
}
const SalesSidebar = (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] : 'overview'
})()
return
}
export default SalesSidebar