File tree Expand file tree Collapse file tree
src/components/Breadcrumbs Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import { Breadcrumbs , Link , Typography } from '@mui/material' ;
2- import { useNavigate } from 'react-router-dom' ;
2+ import { Link as RouterLink } from 'react-router-dom' ;
33import { IFFBreadcrumb } from '../../interfaces' ;
44
55interface Props {
66 breadcrumbs : IFFBreadcrumb [ ] ;
77}
88
99export const FFBreadcrumb : React . FC < Props > = ( { breadcrumbs } ) => {
10- const navigate = useNavigate ( ) ;
11-
1210 return (
1311 < Breadcrumbs >
14- { breadcrumbs . map ( ( b , idx ) => (
15- < Link
16- key = { idx }
17- underline = { idx !== breadcrumbs . length - 1 ? 'hover' : 'none' }
18- color = { idx !== breadcrumbs . length - 1 ? 'inherit' : 'text.primary' }
19- sx = { {
20- cursor : idx !== breadcrumbs . length - 1 ? 'pointer' : 'default' ,
21- } }
22- onClick = { b . link ? ( ) => navigate ( b . link ?? '' ) : undefined }
23- >
24- < Typography
25- variant = "h5"
12+ { breadcrumbs . map ( ( b , idx ) => {
13+ const isLast = idx === breadcrumbs . length - 1 ;
14+ const link = b . link ;
15+ if ( link && ! isLast ) {
16+ return (
17+ < Link
18+ key = { idx }
19+ component = { RouterLink }
20+ to = { link }
21+ underline = "hover"
22+ color = "inherit"
23+ sx = { { cursor : 'pointer' } }
24+ >
25+ < Typography
26+ variant = "h5"
27+ sx = { {
28+ fontWeight : 'bold' ,
29+ fontSize : '14' ,
30+ } }
31+ >
32+ { b . content }
33+ </ Typography >
34+ </ Link >
35+ ) ;
36+ }
37+
38+ return (
39+ < Link
40+ key = { idx }
41+ underline = { ! isLast ? 'hover' : 'none' }
42+ color = { ! isLast ? 'inherit' : 'text.primary' }
2643 sx = { {
27- fontWeight : 'bold' ,
28- fontSize : '14' ,
44+ cursor : 'default' ,
2945 } }
3046 >
31- { b . content }
32- </ Typography >
33- </ Link >
34- ) ) }
47+ < Typography
48+ variant = "h5"
49+ sx = { {
50+ fontWeight : 'bold' ,
51+ fontSize : '14' ,
52+ } }
53+ >
54+ { b . content }
55+ </ Typography >
56+ </ Link >
57+ ) ;
58+ } ) }
3559 </ Breadcrumbs >
3660 ) ;
3761} ;
You can’t perform that action at this time.
0 commit comments