|
1 | | -import { useAuthControllerDelete } from '@baca/api/query/auth/auth' |
| 1 | +import { ProfileDeleteAccountButton } from '@baca/components/screens/profile/ProfileDeleteAccountButton' |
2 | 2 | import { ProfileDetailsForm } from '@baca/components/screens/profile/ProfileDetailsForm' |
3 | 3 | import { ProfileHeader } from '@baca/components/screens/profile/ProfileHeader' |
4 | | -import { Button, Text, Spacer, Row, Box, useBottomSheet } from '@baca/design-system' |
5 | | -import { useCallback, useTranslation, useUpdateProfileForm, useScreenOptions } from '@baca/hooks' |
6 | | -import { signOut } from '@baca/store/auth' |
7 | | -import { showErrorToast } from '@baca/utils' |
| 4 | +import { Button, Spacer, Row, Box } from '@baca/design-system' |
| 5 | +import { useTranslation, useUpdateProfileForm, useScreenOptions } from '@baca/hooks' |
8 | 6 | import { useRouter } from 'expo-router' |
9 | 7 |
|
10 | 8 | export const ProfileScreen = () => { |
11 | 9 | const { t } = useTranslation() |
12 | 10 | const { back } = useRouter() |
13 | | - const { mutateAsync: removeUserAccount, isLoading } = useAuthControllerDelete() |
14 | 11 | const { isSubmitting, submit } = useUpdateProfileForm() |
15 | 12 |
|
16 | | - const { bottomSheetComponentRenderFunction, closeBottomSheet, presentBottomSheet } = |
17 | | - useBottomSheet({ |
18 | | - title: '', |
19 | | - isDivider: false, |
20 | | - }) |
21 | | - |
22 | | - const handleRemoveUserAccount = useCallback(async () => { |
23 | | - try { |
24 | | - await removeUserAccount() |
25 | | - signOut() |
26 | | - } catch { |
27 | | - showErrorToast({ |
28 | | - description: t('errors.something_went_wrong'), |
29 | | - }) |
30 | | - } |
31 | | - }, [removeUserAccount, t]) |
32 | | - |
33 | | - const bottomSheet = bottomSheetComponentRenderFunction( |
34 | | - <Box px={4} pb={10}> |
35 | | - <Text.LgSemibold color="text.primary" pt={4} pb={2}> |
36 | | - {t('profile_screen.are_you_sure')} |
37 | | - </Text.LgSemibold> |
38 | | - <Text.SmRegular color="text.secondary" lineHeight="md"> |
39 | | - {t('profile_screen.remove_account_desc')} |
40 | | - </Text.SmRegular> |
41 | | - <Row w="full" justifyContent="space-between" pt={8}> |
42 | | - <Button variant="SecondaryGray" flex={1} borderRadius={8} onPress={closeBottomSheet}> |
43 | | - {t('common.cancel')} |
44 | | - </Button> |
45 | | - <Spacer x={3} /> |
46 | | - <Button |
47 | | - onPress={handleRemoveUserAccount} |
48 | | - variant="PrimaryDestructive" |
49 | | - flex={1} |
50 | | - borderRadius={8} |
51 | | - loading={isLoading} |
52 | | - > |
53 | | - {t('profile_screen.remove_account')} |
54 | | - </Button> |
55 | | - </Row> |
56 | | - </Box>, |
57 | | - { |
58 | | - name: 'delete-bin-line', |
59 | | - color: 'featured.icon.light.fg.error', |
60 | | - bgColor: 'bg.error.secondary', |
61 | | - } |
62 | | - ) |
63 | | - |
64 | 13 | useScreenOptions({ |
65 | 14 | title: t('navigation.screen_titles.profile'), |
66 | 15 | }) |
@@ -89,17 +38,7 @@ export const ProfileScreen = () => { |
89 | 38 | {t('common.save')} |
90 | 39 | </Button> |
91 | 40 | </Row> |
92 | | - <Box borderColor="border.secondary" borderTopWidth={1} my={4} py={6} alignItems="flex-start"> |
93 | | - <Button |
94 | | - leftIconName="delete-bin-line" |
95 | | - variant="SecondaryDestructive" |
96 | | - borderRadius={8} |
97 | | - onPress={presentBottomSheet} |
98 | | - > |
99 | | - {t('profile_screen.remove_account')} |
100 | | - </Button> |
101 | | - {bottomSheet} |
102 | | - </Box> |
| 41 | + <ProfileDeleteAccountButton /> |
103 | 42 | </Box> |
104 | 43 | ) |
105 | 44 | } |
0 commit comments