import { useAuthControllerDelete } from '@/api/query/auth/auth'
import { Button, Text, Spacer, Row, Box, useBottomSheet } from '@/design-system'
import { useCallback, useTranslation } from '@/hooks'
import { signOut } from '@/store/auth'
import { showErrorToast } from '@/utils'
export const ProfileDeleteAccountButton = () => {
const { t } = useTranslation()
const { mutateAsync: removeUserAccount, isPending } = useAuthControllerDelete()
const { bottomSheetComponentRenderFunction, closeBottomSheet, presentBottomSheet } =
useBottomSheet({
title: '',
isDivider: false,
})
const handleRemoveUserAccount = useCallback(async () => {
try {
await removeUserAccount()
signOut()
} catch {
showErrorToast({
description: t('errors.something_went_wrong'),
})
}
}, [removeUserAccount, t])
const bottomSheet = bottomSheetComponentRenderFunction(
{t('profile_screen.are_you_sure')}
{t('profile_screen.remove_account_desc')}
,
{
name: 'delete-bin-line',
color: 'featured.icon.light.fg.error',
bgColor: 'bg.error.secondary',
}
)
return (
{bottomSheet}
)
}