import { Icon, List, ListItemButton, ListItemIcon, ListItemText, styled, Typography, } from '@mui/material'; import { Link } from 'react-router-dom'; import { IconRenderer, StyledProjectIcon, } from 'component/layout/MainLayout/NavigationSidebar/IconRenderer'; import type { LastViewedPage } from 'hooks/useRecentlyVisited'; import type { Theme } from '@mui/material/styles/createTheme'; import useProjectOverview from 'hooks/api/getters/useProjectOverview/useProjectOverview'; import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender'; const listItemButtonStyle = (theme: Theme) => ({ borderRadius: theme.spacing(0.5), borderLeft: `${theme.spacing(0.5)} solid transparent`, '&.Mui-selected': { borderLeft: `${theme.spacing(0.5)} solid ${theme.palette.primary.main}`, }, }); const StyledTypography = styled(Typography)(({ theme }) => ({ fontSize: theme.fontSizes.bodySize, padding: theme.spacing(0, 3), })); const StyledListItemIcon = styled(ListItemIcon)(({ theme }) => ({ minWidth: theme.spacing(4), margin: theme.spacing(0.25, 0), })); const StyledListItemText = styled(ListItemText)(({ theme }) => ({ margin: 0, })); const toListItemButton = ( item: LastViewedPage, routes: Record, index: number, ) => { const key = `recently-visited-${index}`; if (item.featureId && item.projectId) { return ( ); } if (item.projectId) { return ( ); } if (!item.pathName) return null; const name = routes[item.pathName]?.title ?? item.pathName; return ( ); }; const RecentlyVisitedFeatureButton = ({ key, projectId, featureId, }: { key: string; projectId: string; featureId: string }) => { return ( {'flag'} {featureId} ); }; const RecentlyVisitedPathButton = ({ path, key, name, }: { path: string; key: string; name: string }) => { return ( } elseShow={} /> {name} ); }; const RecentlyVisitedProjectButton = ({ projectId, key, }: { projectId: string; key: string }) => { const { project, loading } = useProjectOverview(projectId); const projectDeleted = !project.name && !loading; if (projectDeleted) return null; return ( {project.name} ); }; export const RecentlyVisited = ({ lastVisited, routes, }: { lastVisited: LastViewedPage[]; routes: Record; }) => { const buttons = lastVisited.map((item, index) => toListItemButton(item, routes, index), ); return ( <> Recently visited {buttons} ); };