2022-04-08 07:00:31 -04:00
|
|
|
import { useState, useCallback } from 'react'
|
|
|
|
import { useTranslation } from 'react-i18next'
|
|
|
|
import LeaveModal from './leave/modal'
|
2023-07-14 05:12:12 -04:00
|
|
|
import getMeta from '../../../utils/meta'
|
2024-05-15 10:31:00 -04:00
|
|
|
import OLButton from '@/features/ui/components/ol/ol-button'
|
2022-04-08 07:00:31 -04:00
|
|
|
|
|
|
|
function LeaveSection() {
|
|
|
|
const { t } = useTranslation()
|
|
|
|
|
|
|
|
const [isModalOpen, setIsModalOpen] = useState(false)
|
|
|
|
|
|
|
|
const handleClose = useCallback(() => {
|
|
|
|
setIsModalOpen(false)
|
|
|
|
}, [])
|
|
|
|
|
|
|
|
const handleOpen = useCallback(() => {
|
|
|
|
setIsModalOpen(true)
|
|
|
|
}, [])
|
|
|
|
|
2023-07-14 05:12:12 -04:00
|
|
|
// Prevent managed users deleting their own accounts
|
|
|
|
if (getMeta('ol-cannot-delete-own-account')) {
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
{t('need_to_leave')} {t('contact_group_admin')}
|
|
|
|
</>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2022-04-08 07:00:31 -04:00
|
|
|
return (
|
|
|
|
<>
|
|
|
|
{t('need_to_leave')}{' '}
|
2024-05-15 10:31:00 -04:00
|
|
|
<OLButton
|
2024-05-21 08:16:19 -04:00
|
|
|
className="btn-inline-link"
|
2024-04-23 10:12:25 -04:00
|
|
|
variant="danger"
|
|
|
|
onClick={handleOpen}
|
|
|
|
>
|
2022-04-08 07:00:31 -04:00
|
|
|
{t('delete_your_account')}
|
2024-05-15 10:31:00 -04:00
|
|
|
</OLButton>
|
2022-04-08 07:00:31 -04:00
|
|
|
<LeaveModal isOpen={isModalOpen} handleClose={handleClose} />
|
|
|
|
</>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
export default LeaveSection
|