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

51 lines
1.4 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 { StyleConstants } from '@utils/styles/constants'
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
style={{
marginHorizontal: StyleConstants.Spacing.Global.PagePadding * 2,
2022-02-19 17:15:44 +01:00
marginTop: StyleConstants.Spacing.Global.PagePadding,
marginBottom: StyleConstants.Spacing.Global.PagePadding * 2
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)
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
}
/>
2020-11-24 00:18:47 +01:00
)
}
export default Logout