// Dependencies import { navigate } from '@freesewing/utils' // Context import { LoadingStatusContext } from '@freesewing/react/context/LoadingStatus' import { ModalContext } from '@freesewing/react/context/Modal' // Hooks import React, { useContext } from 'react' import { useAccount } from '@freesewing/react/hooks/useAccount' import { useBackend } from '@freesewing/react/hooks/useBackend' // Components import { BackIcon as ExitIcon, TrashIcon } from '@freesewing/react/components/Icon' import { IconButton } from '@freesewing/react/components/Button' import { ModalWrapper } from '@freesewing/react/components/Modal' /** * A component to handle the removal of a user's account * * @component * @returns {JSX.Element} */ export const Remove = () => { // Hooks const backend = useBackend() const { signOut, account } = useAccount() // Context const { setLoadingStatus } = useContext(LoadingStatusContext) const { setModal, clearModal } = useContext(ModalContext) // Helper method to remove the account const removeAccount = async () => { setLoadingStatus([true, 'Talking to the backend']) const [status, body] = await backend.removeAccount() if (status === 200 && body.result === 'success') { setLoadingStatus([true, 'Done. Or rather, gone.', true, true]) signOut() navigate('/') } else setLoadingStatus([true, 'An error occured. Please report this', true, false]) } if (account.control === 5) return ( <>

This button is red for a reason.

Remove your FreeSewing account ) return (
setModal(

There is no way back from this

If this is what you want, then go ahead.

Remove your FreeSewing account Back to safety
) } > Remove your FreeSewing account
) }