diff --git a/src/components/common/BreadcrumbCommon/BreadcrumbCommon.tsx b/src/components/common/BreadcrumbCommon/BreadcrumbCommon.tsx index ef82ad16c..cc5733342 100644 --- a/src/components/common/BreadcrumbCommon/BreadcrumbCommon.tsx +++ b/src/components/common/BreadcrumbCommon/BreadcrumbCommon.tsx @@ -1,4 +1,5 @@ import React from 'react' +import { ROUTE } from 'src/utils/constanst.utils' import s from './BreadcrumbCommon.module.scss' import BreadcrumbItem from './components/BreadcrumbItem/BreadcrumbItem' import BreadcrumbSeparator from './components/BreadcrumbSeparator/BreadcrumbSeparator' @@ -8,56 +9,29 @@ interface BreadcrumbCommonProps { showHomePage?: boolean; } -const BreadcrumbCommon = ({ crumbs, showHomePage=true } : BreadcrumbCommonProps) => { +const BreadcrumbCommon = ({ crumbs, showHomePage = true }: BreadcrumbCommonProps) => { return (
{ - showHomePage && crumbs[0].link==="/" && crumbs.map((crumb, i) => { - if (i === 0) { - return ( - - ) - } - if (i === crumbs.length-1) { - return ( - - {crumb.name} - - ) - } - return ( - - - - ) - }) + + showHomePage && } { - !showHomePage && crumbs.map((crumb, i) => { - if (i === 0) { - return - } - if (i === 1) { - return ( - - ) - } - if (i === crumbs.length-1) { - return ( - - {crumb.name} + crumbs.length > 0 && <> + + { + crumbs.slice(0, crumbs.length - 1).map((crumb) => ( + < BreadcrumbSeparator key={crumb.name}> + - ) - } - return ( - - - - ) - }) + ))} + < BreadcrumbSeparator> + {crumbs[crumbs.length - 1].name} + + } -
+ ) } -export default BreadcrumbCommon +export default BreadcrumbCommon \ No newline at end of file diff --git a/src/components/common/BreadcrumbCommon/components/BreadcrumbItem/BreadcrumbItem.tsx b/src/components/common/BreadcrumbCommon/components/BreadcrumbItem/BreadcrumbItem.tsx index 13f980ea9..24f58a066 100644 --- a/src/components/common/BreadcrumbCommon/components/BreadcrumbItem/BreadcrumbItem.tsx +++ b/src/components/common/BreadcrumbCommon/components/BreadcrumbItem/BreadcrumbItem.tsx @@ -15,4 +15,4 @@ const BreadcrumbItem = ({ text, href }: BreadcrumbItemProps) => { ) } -export default BreadcrumbItem +export default BreadcrumbItem \ No newline at end of file