vistas de ciudadano, escalar animaciones de mascota, implementacion de chatbot para concientizacion, modificacion de datos de ciudadano, modificacion de vista principal
This commit is contained in:
38
recolecta_app/lib/features/profile/data/profile_service.dart
Normal file
38
recolecta_app/lib/features/profile/data/profile_service.dart
Normal file
@@ -0,0 +1,38 @@
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
import '../../../core/network/api_client.dart';
|
||||
import '../models/profile_user.dart';
|
||||
|
||||
final profileServiceProvider = Provider<ProfileService>((ref) {
|
||||
return ProfileService(ref.read(apiClientProvider));
|
||||
});
|
||||
|
||||
class ProfileService {
|
||||
ProfileService(this._dio);
|
||||
final Dio _dio;
|
||||
|
||||
Future<ProfileUser> getMe() async {
|
||||
final res = await _dio.get<Map<String, dynamic>>('/users/me');
|
||||
return ProfileUser.fromJson(res.data!);
|
||||
}
|
||||
|
||||
Future<void> updateMe({String? name, String? email, String? phone}) async {
|
||||
final payload = <String, dynamic>{};
|
||||
if (name != null) payload['name'] = name;
|
||||
if (email != null) payload['email'] = email;
|
||||
if (phone != null) payload['phone'] = phone;
|
||||
if (payload.isEmpty) return;
|
||||
await _dio.patch<void>('/users/me', data: payload);
|
||||
}
|
||||
|
||||
Future<void> changePassword({
|
||||
required String currentPassword,
|
||||
required String newPassword,
|
||||
}) async {
|
||||
await _dio.post<void>(
|
||||
'/users/me/change-password',
|
||||
data: {'current_password': currentPassword, 'new_password': newPassword},
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user