Fix logout error
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
import {useState} from 'react'
|
import {useState} from 'react'
|
||||||
import {styled} from '@mui/material/styles'
|
import {styled} from '@mui/material/styles'
|
||||||
import PropTypes from 'prop-types'
|
import PropTypes from 'prop-types'
|
||||||
import Link from 'next/link'
|
|
||||||
import {signOut} from 'next-auth/client'
|
import {signOut} from 'next-auth/client'
|
||||||
import {Tooltip, Fab, Zoom} from '@mui/material'
|
import {Tooltip, Fab, Zoom} from '@mui/material'
|
||||||
import ExitToAppIcon from '@mui/icons-material/ExitToApp'
|
import ExitToAppIcon from '@mui/icons-material/ExitToApp'
|
||||||
@@ -23,43 +22,33 @@ const Root = styled('div')(() => ({
|
|||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
|
|
||||||
const siteUrl = process.env.NEXT_PUBLIC_SITE_URL || 'http://localhost:3000'
|
|
||||||
|
|
||||||
const DekoneksonTooltip = Tooltip
|
const DekoneksonTooltip = Tooltip
|
||||||
|
|
||||||
function Dekoneksyon({chimen, tooltipPlacement}) {
|
function Dekoneksyon({tooltipPlacement}) {
|
||||||
const [esOuve, meteEsOuve] = useState(false)
|
const [esOuve, meteEsOuve] = useState(false)
|
||||||
|
|
||||||
const handleDekonekte = event => {
|
|
||||||
event.preventDefault()
|
|
||||||
signOut({callbackUrl: `${siteUrl}${chimen}`})
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
(
|
(
|
||||||
<Root>
|
<Root>
|
||||||
<Link passHref href='/api/auth/signout'>
|
<DekoneksonTooltip
|
||||||
<DekoneksonTooltip
|
title='Dékoneksyon'
|
||||||
title='Dékoneksyon'
|
placement={tooltipPlacement}
|
||||||
placement={tooltipPlacement}
|
TransitionComponent={Zoom}
|
||||||
TransitionComponent={Zoom}
|
classes={{
|
||||||
classes={{
|
tooltip: classes.tooltip
|
||||||
tooltip: classes.tooltip
|
}}
|
||||||
}}
|
>
|
||||||
|
<Fab
|
||||||
|
className={classes.dekoneksyon}
|
||||||
|
color='secondary'
|
||||||
|
aria-label='logout'
|
||||||
|
size='small'
|
||||||
|
onClick={() => meteEsOuve(true)}
|
||||||
>
|
>
|
||||||
<Fab
|
<ExitToAppIcon />
|
||||||
className={classes.dekoneksyon}
|
</Fab>
|
||||||
sx={{position: 'absolute', marginTop: 6}}
|
</DekoneksonTooltip>
|
||||||
color='secondary'
|
<Alet esOuve={esOuve} meteEsOuve={meteEsOuve} handleKonfime={() => signOut()} />
|
||||||
aria-label='logout'
|
|
||||||
size='small'
|
|
||||||
onClick={() => meteEsOuve(true)}
|
|
||||||
>
|
|
||||||
<ExitToAppIcon />
|
|
||||||
</Fab>
|
|
||||||
</DekoneksonTooltip>
|
|
||||||
</Link>
|
|
||||||
<Alet esOuve={esOuve} meteEsOuve={meteEsOuve} handleKonfime={handleDekonekte} />
|
|
||||||
</Root>
|
</Root>
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@@ -70,7 +59,6 @@ Dekoneksyon.defaultProps = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Dekoneksyon.propTypes = {
|
Dekoneksyon.propTypes = {
|
||||||
chimen: PropTypes.string.isRequired,
|
|
||||||
tooltipPlacement: PropTypes.string
|
tooltipPlacement: PropTypes.string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user