frontend: make profile page a bit more connected with the rest of the UI

Also add avatar editing cap
Pedro Lucas Porcellis porcellis@eletrotupi.com 1 month ago 9c325461c9a095ff81f4e5e2e53c8623c83aba91
Parents: 316a81f
1 file(s) changed
  • frontend/app/profile.tsx +86 -48
frontend/app/profile.tsx
@@ -18,6 +18,9 @@ import { useThemeColor } from '@/hooks/use-theme-color';
18 18 import { Button, Input } from '@/components/ui';
19 19 import { useAuth } from '@/context/AuthContext';
20 20 import { apiClient } from '@/lib/api'
21 + import { Card } from '@/components/ui/Cards';
22 + import AvatarUpload from '@/components/ui/AvatarUpload';
23 + import { Typography, Spacing, Colors } from '@/constants/theme';
21 24
22 25 export default function Profile() {
23 26 const { user, updateAuthUser } = useAuth();
@@ -37,6 +40,8 @@ useEffect(() => {
37 40 setFirstName(user.firstName)
38 41 setLastName(user.lastName)
39 42 setEmail(user.email)
43 +
44 + console.log("User@profile", user);
40 45 }, [user])
41 46
42 47 const backgroundColor = useThemeColor({}, 'background');
@@ -106,6 +111,19 @@ Alert.alert('Erro: ', 'Falha ao tentar atualizar o usuário');
106 111 }
107 112 }
108 113
114 + const onChangeAvatar = (userData) => {
115 + const { id, avatarKey, avatarURL, firstName, lastName, email } = userData;
116 +
117 + updateAuthUser({
118 + id,
119 + avatarKey,
120 + avatarURL,
121 + firstName,
122 + lastName,
123 + email
124 + });
125 + }
126 +
109 127 return (
110 128 <SafeAreaView style={[styles.container, { backgroundColor }]}>
111 129 <StatusBar style={'dark'} />
@@ -117,60 +135,73 @@ <ScrollView
117 135 contentContainerStyle={styles.scrollContainer}
118 136 showsVerticalScrollIndicator={false}
119 137 >
120 - <View style={styles.header}>
121 - <Text style={[styles.title, { color: textColor }]}>Edite o seu perfil</Text>
122 - <Text style={[styles.subtitle, { color: textColor, opacity: 0.7 }]}>
123 - Altere suas configurações
124 - </Text>
125 - </View>
138 + <AvatarUpload
139 + currentAvatar={user.avatarURL}
140 + onUploadSuccess={onChangeAvatar}
141 + onRemoveSuccess={onChangeAvatar} />
126 142
127 143 <View style={styles.form}>
128 - <Input
129 - label="Primeiro Nome"
130 - type="text"
131 - value={firstName}
132 - onChangeText={setFirstName}
133 - placeholder="Qual seu nome?"
134 - error={errors.firstName}
135 - />
144 + <Card style={styles.cardBlock}>
145 + <Input
146 + label="Primeiro Nome"
147 + type="text"
148 + value={firstName}
149 + onChangeText={setFirstName}
150 + placeholder="Qual seu nome?"
151 + variant="darkGhost"
152 + error={errors.firstName}
153 + />
136 154
137 - <Input
138 - label="Sobrenome"
139 - type="text"
140 - value={lastName}
141 - onChangeText={setLastName}
142 - placeholder="Qual seu sobrenome?"
143 - error={errors.lastName}
144 - />
155 + <Input
156 + label="Sobrenome"
157 + type="text"
158 + value={lastName}
159 + variant="darkGhost"
160 + onChangeText={setLastName}
161 + placeholder="Qual seu sobrenome?"
162 + error={errors.lastName}
163 + />
164 + </Card>
145 165
146 - <Input
147 - label="Email"
148 - type="text"
149 - value={email}
150 - onChangeText={setEmail}
151 - placeholder="Qual seu email?"
152 - error={errors.email}
153 - />
166 + <Card style={styles.cardBlock}>
167 + <Input
168 + label="Email"
169 + type="text"
170 + value={email}
171 + variant="darkGhost"
172 + onChangeText={setEmail}
173 + placeholder="Qual seu email?"
174 + error={errors.email}
175 + />
176 + </Card>
154 177
155 - <Input
156 - label="Nova senha"
157 - type="password"
158 - value={password}
159 - onChangeText={setPassword}
160 - placeholder="Digite uma nova senha"
161 - error={errors.password}
162 - showPasswordToggle
163 - />
178 + <Card style={styles.cardBlock}>
179 + <Input
180 + label="Nova senha"
181 + type="password"
182 + value={password}
183 + onChangeText={setPassword}
184 + placeholder="Digite uma nova senha"
185 + error={errors.password}
186 + variant="darkGhost"
187 + showPasswordToggle
188 + />
164 189
165 - <Input
166 - label="Confirmar nova senha"
167 - type="password"
168 - value={confirmPassword}
169 - onChangeText={setConfirmPassword}
170 - placeholder="Confirme a nova senha"
171 - error={errors.confirmPassword}
172 - showPasswordToggle
173 - />
190 + <Input
191 + label="Confirmar nova senha"
192 + type="password"
193 + value={confirmPassword}
194 + onChangeText={setConfirmPassword}
195 + placeholder="Confirme a nova senha"
196 + error={errors.confirmPassword}
197 + variant="darkGhost"
198 + showPasswordToggle
199 + />
200 +
201 + <Text style={styles.cardBlockHint}>
202 + Preencha apenas se quiser mudar a sua senha
203 + </Text>
204 + </Card>
174 205
175 206 <Button
176 207 title="Atualizar perfil"
@@ -233,4 +264,11 @@ },
233 264 footerText: {
234 265 fontSize: 14,
235 266 },
267 + cardBlock: {
268 + padding: Spacing.cardGap
269 + },
270 + cardBlockHint: {
271 + ...Typography.cardHint,
272 + color: Colors.light.textSecondary
273 + }
236 274 });