import { ReactElement } from 'react'; import { Link as RouterLink } from 'react-router-dom'; // @mui import { Box, Link, Typography, BreadcrumbsProps, Breadcrumbs as MUIBreadcrumbs, } from '@mui/material'; // ---------------------------------------------------------------------- type TLink = { href?: string; name: string; icon?: ReactElement; }; export interface Props extends BreadcrumbsProps { links: TLink[]; activeLast?: boolean; } export default function Breadcrumbs({ links, activeLast = false, ...other }: Props) { const currentLink = links[links.length - 1].name; const listDefault = links.map((link) => ); const listActiveLast = links.map((link) => (
{link.name !== currentLink ? ( ) : ( {currentLink} )}
)); return ( } {...other} > {activeLast ? listDefault : listActiveLast} ); } // ---------------------------------------------------------------------- type LinkItemProps = { link: TLink; }; function LinkItem({ link }: LinkItemProps) { const { href, name, icon } = link; return ( div': { display: 'inherit' }, }} > {icon && {icon}} {name} ); }