Enhance Customer model to include role attribute and update related components

- Added a new `role` attribute to the `Customer` model in `customer.dart` and updated the corresponding generated files.
- Modified the `AuthViewModel` to set the user role based on the logged-in user's role.
- Updated UI components in `TenderDetailActions` and `DesktopTendersPage` to conditionally render elements based on the user's role.
- Refactored tests to validate the new role attribute in the `Customer` model.
This commit is contained in:
amirrezaghabeli
2025-10-14 09:12:24 +03:30
parent 504fa1e80a
commit 13dbb5fae5
10 changed files with 109 additions and 53 deletions
+5
View File
@@ -33,11 +33,13 @@ class AuthViewModel with ChangeNotifier {
String? _errorMessage;
Customer? _loggedInUser;
String? successMessage;
Role? _userRole;
bool get isLoading => _isLoading;
bool get isLoggedIn => _isLoggedIn;
String? get errorMessage => _errorMessage;
Customer? get loggedInUser => _loggedInUser;
Role? get userRole => _userRole;
void togglePasswordVisibility() {
_obscurePassword = !_obscurePassword;
@@ -63,6 +65,7 @@ class AuthViewModel with ChangeNotifier {
switch (result) {
case Ok<LoginResponseModel>():
_loggedInUser = result.value.data.customer;
_userRole = _loggedInUser?.role == 'admin' ? Role.admin : Role.analyst;
usernameController.clear();
passwordController.clear();
break;
@@ -123,3 +126,5 @@ class AuthViewModel with ChangeNotifier {
super.dispose();
}
}
enum Role { admin, analyst }