All files / src/components NavigationTabs.tsx

0% Statements 0/30
0% Branches 0/1
0% Functions 0/1
0% Lines 0/30

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42                                                                                   
import React from 'react'
import { Tabs, Tab, Box } from '@mui/material'
import { useNavigate } from 'react-router-dom'
 
interface NavigationTabsProps {
  currentPath: string
}
 
export const NavigationTabs: React.FC<NavigationTabsProps> = ({ currentPath }) => {
  const navigate = useNavigate()
 
  const tabs = [
    { label: 'Téléversement', path: '/' },
    { label: 'Extraction', path: '/extraction' },
    { label: 'Analyse', path: '/analyse' },
    { label: 'Contexte', path: '/contexte' },
    { label: 'Conseil', path: '/conseil' },
  ]
 
  const currentTabIndex = tabs.findIndex(tab => tab.path === currentPath)
 
  const handleTabChange = (_event: React.SyntheticEvent, newValue: number) => {
    navigate(tabs[newValue].path)
  }
 
  return (
    <Box sx={{ borderBottom: 1, borderColor: 'divider' }}>
      <Tabs
        value={currentTabIndex >= 0 ? currentTabIndex : 0}
        onChange={handleTabChange}
        aria-label="navigation tabs"
        variant="scrollable"
        scrollButtons="auto"
      >
        {tabs.map((tab, index) => (
          <Tab key={index} label={tab.label} />
        ))}
      </Tabs>
    </Box>
  )
}