|
1 | 1 | import { useAuthControllerDelete } from '@baca/api/query/auth/auth' |
2 | | -import { ControlledField } from '@baca/components' |
| 2 | +import { ProfileDetailsForm } from '@baca/components/screens/profile/ProfileDetailsForm' |
3 | 3 | import { ProfileHeader } from '@baca/components/screens/profile/ProfileHeader' |
4 | | -import { isWeb } from '@baca/constants' |
5 | 4 | import { Button, Text, Spacer, Row, Box, useBottomSheet } from '@baca/design-system' |
6 | | -import { |
7 | | - useCallback, |
8 | | - useTranslation, |
9 | | - useUpdateProfileForm, |
10 | | - useScreenOptions, |
11 | | - useWeb, |
12 | | -} from '@baca/hooks' |
| 5 | +import { useCallback, useTranslation, useUpdateProfileForm, useScreenOptions } from '@baca/hooks' |
13 | 6 | import { signOut } from '@baca/store/auth' |
14 | 7 | import { showErrorToast } from '@baca/utils' |
15 | 8 | import { useRouter } from 'expo-router' |
16 | 9 |
|
17 | 10 | export const ProfileScreen = () => { |
18 | 11 | const { t } = useTranslation() |
19 | 12 | const { back } = useRouter() |
20 | | - const { shouldApplyMobileStyles } = useWeb() |
21 | 13 | const { mutateAsync: removeUserAccount, isLoading } = useAuthControllerDelete() |
22 | | - const { control, errors, isSubmitting, setFocus, submit } = useUpdateProfileForm() |
| 14 | + const { isSubmitting, submit } = useUpdateProfileForm() |
23 | 15 |
|
24 | 16 | const { bottomSheetComponentRenderFunction, closeBottomSheet, presentBottomSheet } = |
25 | 17 | useBottomSheet({ |
@@ -73,99 +65,30 @@ export const ProfileScreen = () => { |
73 | 65 | title: t('navigation.screen_titles.profile'), |
74 | 66 | }) |
75 | 67 |
|
76 | | - const focusLastNameInput = useCallback(() => setFocus('lastName'), [setFocus]) |
77 | | - |
78 | 68 | return ( |
79 | 69 | <Box p={4}> |
80 | 70 | <ProfileHeader /> |
81 | 71 | <Spacer y={4} /> |
82 | | - <Box borderColor="border.secondary" borderTopWidth={1} py={6}> |
83 | | - <Box |
84 | | - justifyContent="space-between" |
85 | | - flexDirection={isWeb && !shouldApplyMobileStyles ? 'row' : 'column'} |
86 | | - mb={isWeb ? 10 : 0} |
87 | | - maxW={800} |
88 | | - > |
89 | | - <Text.SmBold flex={1}>{t('form.labels.first_name')}</Text.SmBold> |
90 | | - <Box flex={isWeb ? 2 : 0}> |
91 | | - <ControlledField.Input |
92 | | - {...{ control, errors }} |
93 | | - autoCapitalize="none" |
94 | | - inputMode="text" |
95 | | - name="firstName" |
96 | | - onFocus={focusLastNameInput} |
97 | | - placeholder={t('form.placeholders.email')} |
98 | | - testID="emailInput" |
99 | | - {...(!isWeb && { |
100 | | - label: t('form.labels.first_name'), |
101 | | - })} |
102 | | - /> |
103 | | - </Box> |
104 | | - </Box> |
105 | | - <Box |
106 | | - justifyContent="space-between" |
107 | | - flexDirection={isWeb && !shouldApplyMobileStyles ? 'row' : 'column'} |
108 | | - mb={isWeb ? 10 : 0} |
109 | | - maxW={800} |
| 72 | + <ProfileDetailsForm /> |
| 73 | + <Row maxW={800} justifyContent="flex-end"> |
| 74 | + <Button.SecondaryColor |
| 75 | + disabled={isSubmitting} |
| 76 | + loading={isSubmitting} |
| 77 | + onPress={back} |
| 78 | + testID="backProfileButton" |
110 | 79 | > |
111 | | - <Text.SmBold flex={1}>{t('form.labels.last_name')}</Text.SmBold> |
112 | | - <Box flex={isWeb ? 2 : 0}> |
113 | | - <ControlledField.Input |
114 | | - {...{ control, errors }} |
115 | | - autoCapitalize="none" |
116 | | - inputMode="text" |
117 | | - name="lastName" |
118 | | - placeholder={t('form.placeholders.last_name')} |
119 | | - testID="lastNameInput" |
120 | | - {...(!isWeb && { |
121 | | - label: t('form.labels.last_name'), |
122 | | - })} |
123 | | - /> |
124 | | - </Box> |
125 | | - </Box> |
126 | | - <Box |
127 | | - justifyContent="space-between" |
128 | | - flexDirection={isWeb && !shouldApplyMobileStyles ? 'row' : 'column'} |
129 | | - mb={isWeb ? 10 : 0} |
130 | | - maxW={800} |
| 80 | + {t('common.cancel')} |
| 81 | + </Button.SecondaryColor> |
| 82 | + <Spacer x="4" /> |
| 83 | + <Button |
| 84 | + disabled={isSubmitting} |
| 85 | + loading={isSubmitting} |
| 86 | + onPress={submit} |
| 87 | + testID="saveProfileUpdateButton" |
131 | 88 | > |
132 | | - <Text.SmBold flex={1}>{t('form.labels.email')}</Text.SmBold> |
133 | | - <Box flex={isWeb ? 2 : 0}> |
134 | | - <ControlledField.Input |
135 | | - {...{ control, errors }} |
136 | | - autoCapitalize="none" |
137 | | - inputMode="email" |
138 | | - isDisabled |
139 | | - name="email" |
140 | | - onSubmitEditing={submit} |
141 | | - placeholder={t('form.placeholders.email')} |
142 | | - testID="emailInput" |
143 | | - {...(!isWeb && { |
144 | | - label: t('form.labels.email'), |
145 | | - })} |
146 | | - /> |
147 | | - </Box> |
148 | | - </Box> |
149 | | - <Row maxW={800} justifyContent="flex-end"> |
150 | | - <Button.SecondaryColor |
151 | | - disabled={isSubmitting} |
152 | | - loading={isSubmitting} |
153 | | - onPress={back} |
154 | | - testID="backProfileButton" |
155 | | - > |
156 | | - {t('common.cancel')} |
157 | | - </Button.SecondaryColor> |
158 | | - <Spacer x="4" /> |
159 | | - <Button |
160 | | - disabled={isSubmitting} |
161 | | - loading={isSubmitting} |
162 | | - onPress={submit} |
163 | | - testID="saveProfileUpdateButton" |
164 | | - > |
165 | | - {t('common.save')} |
166 | | - </Button> |
167 | | - </Row> |
168 | | - </Box> |
| 89 | + {t('common.save')} |
| 90 | + </Button> |
| 91 | + </Row> |
169 | 92 | <Box borderColor="border.secondary" borderTopWidth={1} my={4} py={6} alignItems="flex-start"> |
170 | 93 | <Button |
171 | 94 | leftIconName="delete-bin-line" |
|
0 commit comments