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:
@@ -23,6 +23,7 @@ void main() {
|
||||
'employee_count': 50,
|
||||
'annual_revenue': 1000000,
|
||||
'founded_year': 2015,
|
||||
'role': 'admin',
|
||||
'is_verified': true,
|
||||
'is_compliant': false,
|
||||
'compliance_notes': 'Pending documents',
|
||||
@@ -60,6 +61,7 @@ void main() {
|
||||
expect(customer.id, '123');
|
||||
expect(customer.firstName, 'John');
|
||||
expect(customer.lastName, 'Doe');
|
||||
expect(customer.role, 'admin');
|
||||
expect(customer.isVerified, true);
|
||||
expect(customer.isCompliant, false);
|
||||
expect(customer.address?.city, 'Tehran');
|
||||
@@ -106,6 +108,7 @@ void main() {
|
||||
employeeCount: 200,
|
||||
annualRevenue: 5000000,
|
||||
foundedYear: 2010,
|
||||
role: 'admin',
|
||||
isVerified: false,
|
||||
isCompliant: true,
|
||||
complianceNotes: 'Verified',
|
||||
@@ -150,6 +153,7 @@ void main() {
|
||||
employeeCount: 50,
|
||||
annualRevenue: 1000000,
|
||||
foundedYear: 2015,
|
||||
role: 'admin',
|
||||
isVerified: true,
|
||||
isCompliant: true,
|
||||
complianceNotes: 'OK',
|
||||
@@ -184,10 +188,12 @@ void main() {
|
||||
|
||||
final updated = customer.copyWith(
|
||||
firstName: 'NewName',
|
||||
role: 'analyst',
|
||||
isVerified: false,
|
||||
);
|
||||
|
||||
expect(updated.firstName, 'NewName');
|
||||
expect(updated.role, 'analyst');
|
||||
expect(updated.isVerified, false);
|
||||
expect(updated.id, '123');
|
||||
});
|
||||
@@ -199,6 +205,7 @@ void main() {
|
||||
|
||||
expect(customer.id, isNull);
|
||||
expect(customer.firstName, isNull);
|
||||
expect(customer.role, isNull);
|
||||
expect(customer.isVerified, isNull);
|
||||
});
|
||||
|
||||
@@ -207,6 +214,7 @@ void main() {
|
||||
'id': 'A1',
|
||||
'first_name': 'Ali',
|
||||
'last_name': 'Rezaei',
|
||||
'role': 'admin',
|
||||
'is_verified': true,
|
||||
'address': {'city': 'Tehran'},
|
||||
'contactPersons': {'first_name': 'Sara', 'is_primary': true},
|
||||
@@ -217,6 +225,7 @@ void main() {
|
||||
|
||||
expect(output['id'], 'A1');
|
||||
expect(output['first_name'], 'Ali');
|
||||
expect(output['role'], 'admin');
|
||||
expect(output['is_verified'], true);
|
||||
final addressJson = (output['address'] as Address).toJson();
|
||||
final contactJson = (output['contactPersons'] as ContactPerson).toJson();
|
||||
|
||||
Reference in New Issue
Block a user