tooot/src/screens/Tabs/Me/Root/Logout.tsx

46 lines
1.2 KiB
TypeScript
Raw Normal View History

2020-12-30 14:33:33 +01:00
import Button from '@components/Button'
import haptics from '@components/haptics'
import { removeAccount, useGlobalStorage } from '@utils/storage/actions'
2020-12-30 14:33:33 +01:00
import React from 'react'
2020-11-29 18:08:31 +01:00
import { useTranslation } from 'react-i18next'
2020-12-26 23:05:17 +01:00
import { Alert } from 'react-native'
2020-11-24 00:18:47 +01:00
const Logout: React.FC = () => {
2022-12-23 15:53:40 +01:00
const { t } = useTranslation(['common', 'screenTabs'])
const [accountActive] = useGlobalStorage.string('account.active')
2020-11-24 00:18:47 +01:00
return (
2020-12-26 23:05:17 +01:00
<Button
type='text'
2022-12-23 15:53:40 +01:00
content={t('screenTabs:me.root.logout.button')}
2020-12-26 23:05:17 +01:00
destructive
onPress={() =>
2022-12-23 15:53:40 +01:00
Alert.alert(
t('screenTabs:me.root.logout.alert.title'),
t('screenTabs:me.root.logout.alert.message'),
[
{
text: t('screenTabs:me.root.logout.alert.buttons.logout'),
style: 'destructive',
onPress: () => {
if (accountActive) {
haptics('Light')
removeAccount(accountActive, false)
2022-12-23 15:53:40 +01:00
}
2020-12-26 23:05:17 +01:00
}
2022-12-23 15:53:40 +01:00
},
{
text: t('common:buttons.cancel'),
style: 'default'
2020-12-26 23:05:17 +01:00
}
2022-12-23 15:53:40 +01:00
]
)
2020-12-26 23:05:17 +01:00
}
2023-05-15 22:30:18 +02:00
style={{ flex: 1 }}
2020-12-26 23:05:17 +01:00
/>
2020-11-24 00:18:47 +01:00
)
}
export default Logout