update info
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -103,6 +103,36 @@ class UserInfo extends _$UserInfo {
|
||||
});
|
||||
}
|
||||
|
||||
/// Update user information
|
||||
///
|
||||
/// Sends updated user data to the API and refreshes the state.
|
||||
///
|
||||
/// [data] should contain:
|
||||
/// - full_name: String
|
||||
/// - date_of_birth: String (YYYY-MM-DD)
|
||||
/// - gender: String
|
||||
/// - company_name: String?
|
||||
/// - tax_code: String?
|
||||
/// - avatar_base64: String? (base64 encoded)
|
||||
/// - id_card_front_base64: String? (base64 encoded)
|
||||
/// - id_card_back_base64: String? (base64 encoded)
|
||||
/// - certificates_base64: List<String> (base64 encoded)
|
||||
///
|
||||
/// Usage:
|
||||
/// ```dart
|
||||
/// await ref.read(userInfoProvider.notifier).updateUserInfo(updateData);
|
||||
/// ```
|
||||
Future<void> updateUserInfo(Map<String, dynamic> data) async {
|
||||
// Set loading state
|
||||
state = const AsyncValue.loading();
|
||||
|
||||
// Update via repository and fetch fresh data
|
||||
state = await AsyncValue.guard(() async {
|
||||
final repository = await ref.read(userInfoRepositoryProvider.future);
|
||||
return await repository.updateUserInfo(data);
|
||||
});
|
||||
}
|
||||
|
||||
/// Update user info locally
|
||||
///
|
||||
/// Updates the cached state without fetching from API.
|
||||
|
||||
@@ -232,7 +232,7 @@ final class UserInfoProvider
|
||||
UserInfo create() => UserInfo();
|
||||
}
|
||||
|
||||
String _$userInfoHash() => r'74fe20082e7acbb23f9606bd01fdf43fd4c5a893';
|
||||
String _$userInfoHash() => r'ed28fdf0213dfd616592b9735cd291f147867047';
|
||||
|
||||
/// User Info Provider
|
||||
///
|
||||
|
||||
Reference in New Issue
Block a user