feat: pedir nombre al primer login + avatar con iniciales
- Detectar usuario nuevo (nombre == telefono) y redirigir a pantalla setup-name antes del dashboard - SetupNameView: bienvenida con campo de nombre obligatorio - AuthProvider.updateName() para guardar via PATCH /users/me - NavbarAvatar: iniciales con color por inicial del nombre en lugar de no-image.jpg cuando no hay foto - Perfil: mismo avatar de iniciales en la pantalla de perfil Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
7349d4e3fd
commit
bfa494b7fe
@@ -81,7 +81,14 @@ class AuthProvider extends ChangeNotifier {
|
||||
userAverageScore = await _loadAverageScore(user!.id);
|
||||
authStatus = AuthStatus.authenticated;
|
||||
notifyListeners();
|
||||
NavigationService.replaceTo(Flurorouter.dashboardRoute);
|
||||
// Usuario nuevo: el backend usa el teléfono como nombre por defecto
|
||||
final name = user!.name.trim();
|
||||
final isNewUser = name.isEmpty || name == phoneNumber || name == phoneNumber.replaceAll('+57', '');
|
||||
if (isNewUser) {
|
||||
NavigationService.replaceTo(Flurorouter.setupNameRoute);
|
||||
} else {
|
||||
NavigationService.replaceTo(Flurorouter.dashboardRoute);
|
||||
}
|
||||
} catch (e) {
|
||||
authStatus = AuthStatus.notAuthenticated;
|
||||
notifyListeners();
|
||||
@@ -89,6 +96,17 @@ class AuthProvider extends ChangeNotifier {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> updateName(String name) async {
|
||||
try {
|
||||
await _api.patch('/users/me', {'name': name.trim()});
|
||||
user = await _fetchMe();
|
||||
notifyListeners();
|
||||
} catch (_) {
|
||||
NotificationsService.showSnackBarError('Error al guardar el nombre');
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> verifyPhoneNumberForLink(String phoneNumber) async {
|
||||
try {
|
||||
await _api.post('/auth/send-otp', {'phone': phoneNumber});
|
||||
|
||||
Reference in New Issue
Block a user