|
1 | 1 | import { useAuthControllerDelete } from '@baca/api/query/auth/auth' |
2 | 2 | import { ControlledField } from '@baca/components' |
| 3 | +import { isWeb } from '@baca/constants' |
3 | 4 | import { Button, Text, Spacer, Row, Box, useBottomSheet } from '@baca/design-system' |
4 | | -import { useCallback, useTranslation, useUpdateProfileForm, useScreenOptions } from '@baca/hooks' |
| 5 | +import { |
| 6 | + useCallback, |
| 7 | + useTranslation, |
| 8 | + useUpdateProfileForm, |
| 9 | + useScreenOptions, |
| 10 | + useWeb, |
| 11 | +} from '@baca/hooks' |
5 | 12 | import { signOut } from '@baca/store/auth' |
6 | 13 | import { showErrorToast } from '@baca/utils' |
7 | 14 | import { useRouter } from 'expo-router' |
8 | 15 |
|
9 | 16 | export const ProfileScreen = () => { |
10 | 17 | const { t } = useTranslation() |
11 | 18 | const { back } = useRouter() |
| 19 | + const { shouldApplyMobileStyles } = useWeb() |
12 | 20 | const { mutateAsync: removeUserAccount, isLoading } = useAuthControllerDelete() |
13 | 21 | const { control, errors, isSubmitting, setFocus, submit } = useUpdateProfileForm() |
14 | 22 |
|
@@ -71,36 +79,69 @@ export const ProfileScreen = () => { |
71 | 79 | <Text.LgBold>{t('profile_screen.profile')}</Text.LgBold> |
72 | 80 | <Text.MdRegular>{t('profile_screen.update_your_details')}</Text.MdRegular> |
73 | 81 | <Box borderColor="utility.gray.300" borderBottomWidth={2} borderTopWidth={2} my={4} py={4}> |
74 | | - <ControlledField.Input |
75 | | - {...{ control, errors }} |
76 | | - autoCapitalize="none" |
77 | | - inputMode="text" |
78 | | - label={t('form.labels.first_name')} |
79 | | - name="firstName" |
80 | | - onFocus={focusLastNameInput} |
81 | | - placeholder={t('form.placeholders.email')} |
82 | | - testID="emailInput" |
83 | | - /> |
84 | | - <ControlledField.Input |
85 | | - {...{ control, errors }} |
86 | | - autoCapitalize="none" |
87 | | - inputMode="text" |
88 | | - label={t('form.labels.last_name')} |
89 | | - name="lastName" |
90 | | - placeholder={t('form.placeholders.last_name')} |
91 | | - testID="lastNameInput" |
92 | | - /> |
93 | | - <ControlledField.Input |
94 | | - {...{ control, errors }} |
95 | | - autoCapitalize="none" |
96 | | - inputMode="email" |
97 | | - isDisabled |
98 | | - label={t('form.labels.email')} |
99 | | - name="email" |
100 | | - onSubmitEditing={submit} |
101 | | - placeholder={t('form.placeholders.email')} |
102 | | - testID="emailInput" |
103 | | - /> |
| 82 | + <Box |
| 83 | + justifyContent="space-between" |
| 84 | + flexDirection={isWeb && !shouldApplyMobileStyles ? 'row' : 'column'} |
| 85 | + mb={isWeb ? 10 : 0} |
| 86 | + > |
| 87 | + <Text.SmBold flex={1}>{t('form.labels.first_name')}</Text.SmBold> |
| 88 | + <Box flex={isWeb ? 1 : 0}> |
| 89 | + <ControlledField.Input |
| 90 | + {...{ control, errors }} |
| 91 | + autoCapitalize="none" |
| 92 | + inputMode="text" |
| 93 | + name="firstName" |
| 94 | + onFocus={focusLastNameInput} |
| 95 | + placeholder={t('form.placeholders.email')} |
| 96 | + testID="emailInput" |
| 97 | + {...(!isWeb && { |
| 98 | + label: t('form.labels.first_name'), |
| 99 | + })} |
| 100 | + /> |
| 101 | + </Box> |
| 102 | + </Box> |
| 103 | + <Box |
| 104 | + justifyContent="space-between" |
| 105 | + flexDirection={isWeb && !shouldApplyMobileStyles ? 'row' : 'column'} |
| 106 | + mb={isWeb ? 10 : 0} |
| 107 | + > |
| 108 | + <Text.SmBold flex={1}>{t('form.labels.last_name')}</Text.SmBold> |
| 109 | + <Box flex={isWeb ? 1 : 0}> |
| 110 | + <ControlledField.Input |
| 111 | + {...{ control, errors }} |
| 112 | + autoCapitalize="none" |
| 113 | + inputMode="text" |
| 114 | + name="lastName" |
| 115 | + placeholder={t('form.placeholders.last_name')} |
| 116 | + testID="lastNameInput" |
| 117 | + {...(!isWeb && { |
| 118 | + label: t('form.labels.last_name'), |
| 119 | + })} |
| 120 | + /> |
| 121 | + </Box> |
| 122 | + </Box> |
| 123 | + <Box |
| 124 | + justifyContent="space-between" |
| 125 | + flexDirection={isWeb && !shouldApplyMobileStyles ? 'row' : 'column'} |
| 126 | + mb={isWeb ? 10 : 0} |
| 127 | + > |
| 128 | + <Text.SmBold flex={1}>{t('form.labels.last_name')}</Text.SmBold> |
| 129 | + <Box flex={isWeb ? 1 : 0}> |
| 130 | + <ControlledField.Input |
| 131 | + {...{ control, errors }} |
| 132 | + autoCapitalize="none" |
| 133 | + inputMode="email" |
| 134 | + isDisabled |
| 135 | + name="email" |
| 136 | + onSubmitEditing={submit} |
| 137 | + placeholder={t('form.placeholders.email')} |
| 138 | + testID="emailInput" |
| 139 | + {...(!isWeb && { |
| 140 | + label: t('form.labels.email'), |
| 141 | + })} |
| 142 | + /> |
| 143 | + </Box> |
| 144 | + </Box> |
104 | 145 | </Box> |
105 | 146 | <Row justifyContent="flex-end"> |
106 | 147 | <Button.SecondaryColor |
|
0 commit comments