From 61cf6533778df529d613e8344a0150e9bef5f433 Mon Sep 17 00:00:00 2001 From: Valentin Charbonnier Date: Thu, 18 Jan 2024 18:00:52 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Missing=20navabar?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Navbar.tsx | 73 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 src/components/Navbar.tsx diff --git a/src/components/Navbar.tsx b/src/components/Navbar.tsx new file mode 100644 index 0000000..1371af4 --- /dev/null +++ b/src/components/Navbar.tsx @@ -0,0 +1,73 @@ +import { AppBar, Toolbar, Typography, Button, IconButton } from '@mui/material'; +import '../styles.css'; +import { makeStyles } from '@mui/styles'; +import React, { useContext } from 'react'; +import AuthContext from "@contexts/AuthContext"; +import { Link } from 'react-router-dom'; +import theme from '../theme'; +import { useTranslation } from "react-i18next"; +import LanguageSwitcher from './LanguageSwitcher'; +import useNightMode from '../hooks/backend/userService/useNightMode'; // Assurez-vous que le chemin d'accès est correct +import Brightness7Icon from '@mui/icons-material/Brightness7'; // icône de soleil +import Brightness4Icon from '@mui/icons-material/Brightness4'; // icône de lune + +const useStyles = makeStyles({ + title: { + flexGrow: 1, + }, + navButton: { + '&:hover': { + color: theme.palette.primary.main , + backgroundColor: 'white !important', + }, + }, +}); + + +const Navbar = () => { + const { isLoggedIn, logout } = useContext(AuthContext); + const { t } = useTranslation(); + const { isNightMode, toggleNightMode } = useNightMode(); + + const handleLogout = () => { + logout(); + }; + + const handleToggleNightMode = () => { + toggleNightMode().then(() => { + window.location.reload(); + }).catch(err => { + console.error('Erreur while switching night mode', err); + }); + }; + + const classes = useStyles(); + + return ( + + + + {t('navbar.dashboard')} + + + {isNightMode ? : } + + + {!isLoggedIn && ( + <> + + + )} + {isLoggedIn && ( + <> + + + + + )} + + + ); +}; + +export default Navbar; \ No newline at end of file