2024-05-20 04:17:09 +04:00
|
|
|
|
'use client'
|
|
|
|
|
|
|
|
|
|
|
|
import PropTypes from 'prop-types'
|
|
|
|
|
|
import {signOut} from 'next-auth/react'
|
|
|
|
|
|
import {useRouter} from 'next/navigation'
|
|
|
|
|
|
import Box from '@mui/material/Box'
|
|
|
|
|
|
import Stack from '@mui/material/Stack'
|
|
|
|
|
|
import Fab from '@mui/material/Fab'
|
2024-05-20 14:43:29 +04:00
|
|
|
|
import {styled} from '@mui/material/styles'
|
|
|
|
|
|
import Tooltip, {tooltipClasses} from '@mui/material/Tooltip'
|
2024-05-20 04:17:09 +04:00
|
|
|
|
import LogoutIcon from '@mui/icons-material/Logout'
|
|
|
|
|
|
import LoginIcon from '@mui/icons-material/Login'
|
|
|
|
|
|
import PersonAddIcon from '@mui/icons-material/PersonAdd'
|
|
|
|
|
|
|
2024-05-20 14:43:29 +04:00
|
|
|
|
const LightTooltip = styled(({className, ...props}) => (
|
|
|
|
|
|
<Tooltip {...props} classes={{popper: className}} />
|
|
|
|
|
|
))(({theme}) => ({
|
|
|
|
|
|
[`& .${tooltipClasses.tooltip}`]: {
|
|
|
|
|
|
backgroundColor: theme.palette.common.white,
|
|
|
|
|
|
color: 'rgba(0, 0, 0, 0.87)',
|
|
|
|
|
|
boxShadow: theme.shadows[1],
|
|
|
|
|
|
fontSize: 15,
|
|
|
|
|
|
},
|
|
|
|
|
|
}))
|
|
|
|
|
|
|
2024-05-20 04:17:09 +04:00
|
|
|
|
export default function Sign({session}) {
|
|
|
|
|
|
const router = useRouter()
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
2024-05-20 14:43:29 +04:00
|
|
|
|
<Box sx={{display: 'flex', justifyContent: session ? 'start' : 'center', marginTop: 1}}>
|
2024-05-20 04:17:09 +04:00
|
|
|
|
{session ? (
|
2024-05-20 14:43:29 +04:00
|
|
|
|
<LightTooltip title='Se déconnecter' placement='right'>
|
|
|
|
|
|
<Fab size='large' color='error' onClick={() => signOut()}>
|
|
|
|
|
|
<LogoutIcon fontSize='large' />
|
2024-05-20 04:17:09 +04:00
|
|
|
|
</Fab>
|
2024-05-20 14:43:29 +04:00
|
|
|
|
</LightTooltip>
|
2024-05-20 04:17:09 +04:00
|
|
|
|
) : (
|
|
|
|
|
|
<Stack direction='row' spacing={2}>
|
2024-05-20 14:43:29 +04:00
|
|
|
|
<LightTooltip title='Se connecter' placement='left'>
|
|
|
|
|
|
<Fab size='large' color='success' onClick={() => router.push('/login')}>
|
|
|
|
|
|
<LoginIcon fontSize='large' />
|
2024-05-20 04:17:09 +04:00
|
|
|
|
</Fab>
|
2024-05-20 14:43:29 +04:00
|
|
|
|
</LightTooltip>
|
|
|
|
|
|
<LightTooltip title='S’enregistrer' placement='right'>
|
|
|
|
|
|
<Fab size='large' color='success' onClick={() => router.push('/register')}>
|
|
|
|
|
|
<PersonAddIcon fontSize='large' />
|
2024-05-20 04:17:09 +04:00
|
|
|
|
</Fab>
|
2024-05-20 14:43:29 +04:00
|
|
|
|
</LightTooltip>
|
2024-05-20 04:17:09 +04:00
|
|
|
|
</Stack>
|
|
|
|
|
|
)}
|
|
|
|
|
|
</Box>
|
|
|
|
|
|
)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Sign.propTypes = {
|
|
|
|
|
|
session: PropTypes.object
|
|
|
|
|
|
}
|