feat: enhance admin and profile repositories with token handling; update dropdown initial values in various screens

This commit is contained in:
Nils-Johan Gynther
2026-04-23 21:34:08 +02:00
parent 111d196403
commit b589f7415d
15 changed files with 63 additions and 36 deletions
@@ -16,9 +16,10 @@ class ProfileRepository {
ProfileRepository(this._apiClient, this._ref);
Future<UserProfile> getMe() async {
final token = await _ref.read(authStateProvider.future);
final data = await guardedApiCall(
_ref,
() => _apiClient.getJson(UserApiPaths.me),
() => _apiClient.getJson(UserApiPaths.me, token: token),
);
return UserProfile.fromJson(data);
}
@@ -28,6 +29,7 @@ class ProfileRepository {
String? firstName,
String? lastName,
}) async {
final token = await _ref.read(authStateProvider.future);
final body = <String, dynamic>{
if (email != null) 'email': email,
if (firstName != null) 'firstName': firstName,
@@ -35,7 +37,7 @@ class ProfileRepository {
};
final data = await guardedApiCall(
_ref,
() => _apiClient.patchJson(UserApiPaths.me, body: body),
() => _apiClient.patchJson(UserApiPaths.me, body: body, token: token),
);
return UserProfile.fromJson(data);
}