From 13dbb5fae52b5292f8a66c83b54e04a653e0aae1 Mon Sep 17 00:00:00 2001 From: amirrezaghabeli Date: Tue, 14 Oct 2025 09:12:24 +0330 Subject: [PATCH] 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. --- .../services/model/customer/customer.dart | 1 + .../model/customer/customer.freezed.dart | 39 ++++++++------- .../services/model/customer/customer.g.dart | 2 + lib/view_models/auth_view_model.dart | 5 ++ .../detail/widgets/tender_detail_action.dart | 15 ++++-- lib/views/shared/page_selection_dialog.dart | 1 + .../shared/select_submission_dialog.dart | 36 ++++++++++---- lib/views/tenders/pages/d_tenders_page.dart | 6 ++- .../pages/your_tenders_desktop_page.dart | 48 +++++++++++-------- test/model/customer_test.dart | 9 ++++ 10 files changed, 109 insertions(+), 53 deletions(-) diff --git a/lib/data/services/model/customer/customer.dart b/lib/data/services/model/customer/customer.dart index ca2a7b9..f2de936 100644 --- a/lib/data/services/model/customer/customer.dart +++ b/lib/data/services/model/customer/customer.dart @@ -33,6 +33,7 @@ abstract class Customer with _$Customer { required String? language, required String? username, required String? currency, + required String? role, required String? timezone, @JsonKey(name: 'created_at') required int? createdAt, @JsonKey(name: 'updated_at') required int? updatedAt, diff --git a/lib/data/services/model/customer/customer.freezed.dart b/lib/data/services/model/customer/customer.freezed.dart index 5aecef4..8cdd18e 100644 --- a/lib/data/services/model/customer/customer.freezed.dart +++ b/lib/data/services/model/customer/customer.freezed.dart @@ -15,7 +15,7 @@ T _$identity(T value) => value; /// @nodoc mixin _$Customer { - String? get id; String? get type; String? get status;@JsonKey(name: 'first_name') String? get firstName;@JsonKey(name: 'last_name') String? get lastName;@JsonKey(name: 'full_name') String? get fullName; String? get email; String? get phone; String? get mobile;@JsonKey(name: 'registration_number') String? get registrationNumber;@JsonKey(name: 'tax_id') String? get taxId; String? get industry;@JsonKey(name: 'business_type') String? get businessType;@JsonKey(name: 'employee_count') int? get employeeCount;@JsonKey(name: 'annual_revenue') int? get annualRevenue;@JsonKey(name: 'founded_year') int? get foundedYear;@JsonKey(name: 'is_verified') bool? get isVerified;@JsonKey(name: 'is_compliant') bool? get isCompliant;@JsonKey(name: 'compliance_notes') String? get complianceNotes; String? get language; String? get username; String? get currency; String? get timezone;@JsonKey(name: 'created_at') int? get createdAt;@JsonKey(name: 'updated_at') int? get updatedAt;@JsonKey(name: 'created_by') String? get createdBy;@JsonKey(name: 'updated_by') String? get updatedBy; Address? get address; ContactPerson? get contactPersons; + String? get id; String? get type; String? get status;@JsonKey(name: 'first_name') String? get firstName;@JsonKey(name: 'last_name') String? get lastName;@JsonKey(name: 'full_name') String? get fullName; String? get email; String? get phone; String? get mobile;@JsonKey(name: 'registration_number') String? get registrationNumber;@JsonKey(name: 'tax_id') String? get taxId; String? get industry;@JsonKey(name: 'business_type') String? get businessType;@JsonKey(name: 'employee_count') int? get employeeCount;@JsonKey(name: 'annual_revenue') int? get annualRevenue;@JsonKey(name: 'founded_year') int? get foundedYear;@JsonKey(name: 'is_verified') bool? get isVerified;@JsonKey(name: 'is_compliant') bool? get isCompliant;@JsonKey(name: 'compliance_notes') String? get complianceNotes; String? get language; String? get username; String? get currency; String? get role; String? get timezone;@JsonKey(name: 'created_at') int? get createdAt;@JsonKey(name: 'updated_at') int? get updatedAt;@JsonKey(name: 'created_by') String? get createdBy;@JsonKey(name: 'updated_by') String? get updatedBy; Address? get address; ContactPerson? get contactPersons; /// Create a copy of Customer /// with the given fields replaced by the non-null parameter values. @JsonKey(includeFromJson: false, includeToJson: false) @@ -28,16 +28,16 @@ $CustomerCopyWith get copyWith => _$CustomerCopyWithImpl(thi @override bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is Customer&&(identical(other.id, id) || other.id == id)&&(identical(other.type, type) || other.type == type)&&(identical(other.status, status) || other.status == status)&&(identical(other.firstName, firstName) || other.firstName == firstName)&&(identical(other.lastName, lastName) || other.lastName == lastName)&&(identical(other.fullName, fullName) || other.fullName == fullName)&&(identical(other.email, email) || other.email == email)&&(identical(other.phone, phone) || other.phone == phone)&&(identical(other.mobile, mobile) || other.mobile == mobile)&&(identical(other.registrationNumber, registrationNumber) || other.registrationNumber == registrationNumber)&&(identical(other.taxId, taxId) || other.taxId == taxId)&&(identical(other.industry, industry) || other.industry == industry)&&(identical(other.businessType, businessType) || other.businessType == businessType)&&(identical(other.employeeCount, employeeCount) || other.employeeCount == employeeCount)&&(identical(other.annualRevenue, annualRevenue) || other.annualRevenue == annualRevenue)&&(identical(other.foundedYear, foundedYear) || other.foundedYear == foundedYear)&&(identical(other.isVerified, isVerified) || other.isVerified == isVerified)&&(identical(other.isCompliant, isCompliant) || other.isCompliant == isCompliant)&&(identical(other.complianceNotes, complianceNotes) || other.complianceNotes == complianceNotes)&&(identical(other.language, language) || other.language == language)&&(identical(other.username, username) || other.username == username)&&(identical(other.currency, currency) || other.currency == currency)&&(identical(other.timezone, timezone) || other.timezone == timezone)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)&&(identical(other.createdBy, createdBy) || other.createdBy == createdBy)&&(identical(other.updatedBy, updatedBy) || other.updatedBy == updatedBy)&&(identical(other.address, address) || other.address == address)&&(identical(other.contactPersons, contactPersons) || other.contactPersons == contactPersons)); + return identical(this, other) || (other.runtimeType == runtimeType&&other is Customer&&(identical(other.id, id) || other.id == id)&&(identical(other.type, type) || other.type == type)&&(identical(other.status, status) || other.status == status)&&(identical(other.firstName, firstName) || other.firstName == firstName)&&(identical(other.lastName, lastName) || other.lastName == lastName)&&(identical(other.fullName, fullName) || other.fullName == fullName)&&(identical(other.email, email) || other.email == email)&&(identical(other.phone, phone) || other.phone == phone)&&(identical(other.mobile, mobile) || other.mobile == mobile)&&(identical(other.registrationNumber, registrationNumber) || other.registrationNumber == registrationNumber)&&(identical(other.taxId, taxId) || other.taxId == taxId)&&(identical(other.industry, industry) || other.industry == industry)&&(identical(other.businessType, businessType) || other.businessType == businessType)&&(identical(other.employeeCount, employeeCount) || other.employeeCount == employeeCount)&&(identical(other.annualRevenue, annualRevenue) || other.annualRevenue == annualRevenue)&&(identical(other.foundedYear, foundedYear) || other.foundedYear == foundedYear)&&(identical(other.isVerified, isVerified) || other.isVerified == isVerified)&&(identical(other.isCompliant, isCompliant) || other.isCompliant == isCompliant)&&(identical(other.complianceNotes, complianceNotes) || other.complianceNotes == complianceNotes)&&(identical(other.language, language) || other.language == language)&&(identical(other.username, username) || other.username == username)&&(identical(other.currency, currency) || other.currency == currency)&&(identical(other.role, role) || other.role == role)&&(identical(other.timezone, timezone) || other.timezone == timezone)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)&&(identical(other.createdBy, createdBy) || other.createdBy == createdBy)&&(identical(other.updatedBy, updatedBy) || other.updatedBy == updatedBy)&&(identical(other.address, address) || other.address == address)&&(identical(other.contactPersons, contactPersons) || other.contactPersons == contactPersons)); } @JsonKey(includeFromJson: false, includeToJson: false) @override -int get hashCode => Object.hashAll([runtimeType,id,type,status,firstName,lastName,fullName,email,phone,mobile,registrationNumber,taxId,industry,businessType,employeeCount,annualRevenue,foundedYear,isVerified,isCompliant,complianceNotes,language,username,currency,timezone,createdAt,updatedAt,createdBy,updatedBy,address,contactPersons]); +int get hashCode => Object.hashAll([runtimeType,id,type,status,firstName,lastName,fullName,email,phone,mobile,registrationNumber,taxId,industry,businessType,employeeCount,annualRevenue,foundedYear,isVerified,isCompliant,complianceNotes,language,username,currency,role,timezone,createdAt,updatedAt,createdBy,updatedBy,address,contactPersons]); @override String toString() { - return 'Customer(id: $id, type: $type, status: $status, firstName: $firstName, lastName: $lastName, fullName: $fullName, email: $email, phone: $phone, mobile: $mobile, registrationNumber: $registrationNumber, taxId: $taxId, industry: $industry, businessType: $businessType, employeeCount: $employeeCount, annualRevenue: $annualRevenue, foundedYear: $foundedYear, isVerified: $isVerified, isCompliant: $isCompliant, complianceNotes: $complianceNotes, language: $language, username: $username, currency: $currency, timezone: $timezone, createdAt: $createdAt, updatedAt: $updatedAt, createdBy: $createdBy, updatedBy: $updatedBy, address: $address, contactPersons: $contactPersons)'; + return 'Customer(id: $id, type: $type, status: $status, firstName: $firstName, lastName: $lastName, fullName: $fullName, email: $email, phone: $phone, mobile: $mobile, registrationNumber: $registrationNumber, taxId: $taxId, industry: $industry, businessType: $businessType, employeeCount: $employeeCount, annualRevenue: $annualRevenue, foundedYear: $foundedYear, isVerified: $isVerified, isCompliant: $isCompliant, complianceNotes: $complianceNotes, language: $language, username: $username, currency: $currency, role: $role, timezone: $timezone, createdAt: $createdAt, updatedAt: $updatedAt, createdBy: $createdBy, updatedBy: $updatedBy, address: $address, contactPersons: $contactPersons)'; } @@ -48,7 +48,7 @@ abstract mixin class $CustomerCopyWith<$Res> { factory $CustomerCopyWith(Customer value, $Res Function(Customer) _then) = _$CustomerCopyWithImpl; @useResult $Res call({ - String? id, String? type, String? status,@JsonKey(name: 'first_name') String? firstName,@JsonKey(name: 'last_name') String? lastName,@JsonKey(name: 'full_name') String? fullName, String? email, String? phone, String? mobile,@JsonKey(name: 'registration_number') String? registrationNumber,@JsonKey(name: 'tax_id') String? taxId, String? industry,@JsonKey(name: 'business_type') String? businessType,@JsonKey(name: 'employee_count') int? employeeCount,@JsonKey(name: 'annual_revenue') int? annualRevenue,@JsonKey(name: 'founded_year') int? foundedYear,@JsonKey(name: 'is_verified') bool? isVerified,@JsonKey(name: 'is_compliant') bool? isCompliant,@JsonKey(name: 'compliance_notes') String? complianceNotes, String? language, String? username, String? currency, String? timezone,@JsonKey(name: 'created_at') int? createdAt,@JsonKey(name: 'updated_at') int? updatedAt,@JsonKey(name: 'created_by') String? createdBy,@JsonKey(name: 'updated_by') String? updatedBy, Address? address, ContactPerson? contactPersons + String? id, String? type, String? status,@JsonKey(name: 'first_name') String? firstName,@JsonKey(name: 'last_name') String? lastName,@JsonKey(name: 'full_name') String? fullName, String? email, String? phone, String? mobile,@JsonKey(name: 'registration_number') String? registrationNumber,@JsonKey(name: 'tax_id') String? taxId, String? industry,@JsonKey(name: 'business_type') String? businessType,@JsonKey(name: 'employee_count') int? employeeCount,@JsonKey(name: 'annual_revenue') int? annualRevenue,@JsonKey(name: 'founded_year') int? foundedYear,@JsonKey(name: 'is_verified') bool? isVerified,@JsonKey(name: 'is_compliant') bool? isCompliant,@JsonKey(name: 'compliance_notes') String? complianceNotes, String? language, String? username, String? currency, String? role, String? timezone,@JsonKey(name: 'created_at') int? createdAt,@JsonKey(name: 'updated_at') int? updatedAt,@JsonKey(name: 'created_by') String? createdBy,@JsonKey(name: 'updated_by') String? updatedBy, Address? address, ContactPerson? contactPersons }); @@ -65,7 +65,7 @@ class _$CustomerCopyWithImpl<$Res> /// Create a copy of Customer /// with the given fields replaced by the non-null parameter values. -@pragma('vm:prefer-inline') @override $Res call({Object? id = freezed,Object? type = freezed,Object? status = freezed,Object? firstName = freezed,Object? lastName = freezed,Object? fullName = freezed,Object? email = freezed,Object? phone = freezed,Object? mobile = freezed,Object? registrationNumber = freezed,Object? taxId = freezed,Object? industry = freezed,Object? businessType = freezed,Object? employeeCount = freezed,Object? annualRevenue = freezed,Object? foundedYear = freezed,Object? isVerified = freezed,Object? isCompliant = freezed,Object? complianceNotes = freezed,Object? language = freezed,Object? username = freezed,Object? currency = freezed,Object? timezone = freezed,Object? createdAt = freezed,Object? updatedAt = freezed,Object? createdBy = freezed,Object? updatedBy = freezed,Object? address = freezed,Object? contactPersons = freezed,}) { +@pragma('vm:prefer-inline') @override $Res call({Object? id = freezed,Object? type = freezed,Object? status = freezed,Object? firstName = freezed,Object? lastName = freezed,Object? fullName = freezed,Object? email = freezed,Object? phone = freezed,Object? mobile = freezed,Object? registrationNumber = freezed,Object? taxId = freezed,Object? industry = freezed,Object? businessType = freezed,Object? employeeCount = freezed,Object? annualRevenue = freezed,Object? foundedYear = freezed,Object? isVerified = freezed,Object? isCompliant = freezed,Object? complianceNotes = freezed,Object? language = freezed,Object? username = freezed,Object? currency = freezed,Object? role = freezed,Object? timezone = freezed,Object? createdAt = freezed,Object? updatedAt = freezed,Object? createdBy = freezed,Object? updatedBy = freezed,Object? address = freezed,Object? contactPersons = freezed,}) { return _then(_self.copyWith( id: freezed == id ? _self.id : id // ignore: cast_nullable_to_non_nullable as String?,type: freezed == type ? _self.type : type // ignore: cast_nullable_to_non_nullable @@ -89,6 +89,7 @@ as bool?,complianceNotes: freezed == complianceNotes ? _self.complianceNotes : c as String?,language: freezed == language ? _self.language : language // ignore: cast_nullable_to_non_nullable as String?,username: freezed == username ? _self.username : username // ignore: cast_nullable_to_non_nullable as String?,currency: freezed == currency ? _self.currency : currency // ignore: cast_nullable_to_non_nullable +as String?,role: freezed == role ? _self.role : role // ignore: cast_nullable_to_non_nullable as String?,timezone: freezed == timezone ? _self.timezone : timezone // ignore: cast_nullable_to_non_nullable as String?,createdAt: freezed == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable as int?,updatedAt: freezed == updatedAt ? _self.updatedAt : updatedAt // ignore: cast_nullable_to_non_nullable @@ -205,10 +206,10 @@ return $default(_that);case _: /// } /// ``` -@optionalTypeArgs TResult maybeWhen(TResult Function( String? id, String? type, String? status, @JsonKey(name: 'first_name') String? firstName, @JsonKey(name: 'last_name') String? lastName, @JsonKey(name: 'full_name') String? fullName, String? email, String? phone, String? mobile, @JsonKey(name: 'registration_number') String? registrationNumber, @JsonKey(name: 'tax_id') String? taxId, String? industry, @JsonKey(name: 'business_type') String? businessType, @JsonKey(name: 'employee_count') int? employeeCount, @JsonKey(name: 'annual_revenue') int? annualRevenue, @JsonKey(name: 'founded_year') int? foundedYear, @JsonKey(name: 'is_verified') bool? isVerified, @JsonKey(name: 'is_compliant') bool? isCompliant, @JsonKey(name: 'compliance_notes') String? complianceNotes, String? language, String? username, String? currency, String? timezone, @JsonKey(name: 'created_at') int? createdAt, @JsonKey(name: 'updated_at') int? updatedAt, @JsonKey(name: 'created_by') String? createdBy, @JsonKey(name: 'updated_by') String? updatedBy, Address? address, ContactPerson? contactPersons)? $default,{required TResult orElse(),}) {final _that = this; +@optionalTypeArgs TResult maybeWhen(TResult Function( String? id, String? type, String? status, @JsonKey(name: 'first_name') String? firstName, @JsonKey(name: 'last_name') String? lastName, @JsonKey(name: 'full_name') String? fullName, String? email, String? phone, String? mobile, @JsonKey(name: 'registration_number') String? registrationNumber, @JsonKey(name: 'tax_id') String? taxId, String? industry, @JsonKey(name: 'business_type') String? businessType, @JsonKey(name: 'employee_count') int? employeeCount, @JsonKey(name: 'annual_revenue') int? annualRevenue, @JsonKey(name: 'founded_year') int? foundedYear, @JsonKey(name: 'is_verified') bool? isVerified, @JsonKey(name: 'is_compliant') bool? isCompliant, @JsonKey(name: 'compliance_notes') String? complianceNotes, String? language, String? username, String? currency, String? role, String? timezone, @JsonKey(name: 'created_at') int? createdAt, @JsonKey(name: 'updated_at') int? updatedAt, @JsonKey(name: 'created_by') String? createdBy, @JsonKey(name: 'updated_by') String? updatedBy, Address? address, ContactPerson? contactPersons)? $default,{required TResult orElse(),}) {final _that = this; switch (_that) { case _Customer() when $default != null: -return $default(_that.id,_that.type,_that.status,_that.firstName,_that.lastName,_that.fullName,_that.email,_that.phone,_that.mobile,_that.registrationNumber,_that.taxId,_that.industry,_that.businessType,_that.employeeCount,_that.annualRevenue,_that.foundedYear,_that.isVerified,_that.isCompliant,_that.complianceNotes,_that.language,_that.username,_that.currency,_that.timezone,_that.createdAt,_that.updatedAt,_that.createdBy,_that.updatedBy,_that.address,_that.contactPersons);case _: +return $default(_that.id,_that.type,_that.status,_that.firstName,_that.lastName,_that.fullName,_that.email,_that.phone,_that.mobile,_that.registrationNumber,_that.taxId,_that.industry,_that.businessType,_that.employeeCount,_that.annualRevenue,_that.foundedYear,_that.isVerified,_that.isCompliant,_that.complianceNotes,_that.language,_that.username,_that.currency,_that.role,_that.timezone,_that.createdAt,_that.updatedAt,_that.createdBy,_that.updatedBy,_that.address,_that.contactPersons);case _: return orElse(); } @@ -226,10 +227,10 @@ return $default(_that.id,_that.type,_that.status,_that.firstName,_that.lastName, /// } /// ``` -@optionalTypeArgs TResult when(TResult Function( String? id, String? type, String? status, @JsonKey(name: 'first_name') String? firstName, @JsonKey(name: 'last_name') String? lastName, @JsonKey(name: 'full_name') String? fullName, String? email, String? phone, String? mobile, @JsonKey(name: 'registration_number') String? registrationNumber, @JsonKey(name: 'tax_id') String? taxId, String? industry, @JsonKey(name: 'business_type') String? businessType, @JsonKey(name: 'employee_count') int? employeeCount, @JsonKey(name: 'annual_revenue') int? annualRevenue, @JsonKey(name: 'founded_year') int? foundedYear, @JsonKey(name: 'is_verified') bool? isVerified, @JsonKey(name: 'is_compliant') bool? isCompliant, @JsonKey(name: 'compliance_notes') String? complianceNotes, String? language, String? username, String? currency, String? timezone, @JsonKey(name: 'created_at') int? createdAt, @JsonKey(name: 'updated_at') int? updatedAt, @JsonKey(name: 'created_by') String? createdBy, @JsonKey(name: 'updated_by') String? updatedBy, Address? address, ContactPerson? contactPersons) $default,) {final _that = this; +@optionalTypeArgs TResult when(TResult Function( String? id, String? type, String? status, @JsonKey(name: 'first_name') String? firstName, @JsonKey(name: 'last_name') String? lastName, @JsonKey(name: 'full_name') String? fullName, String? email, String? phone, String? mobile, @JsonKey(name: 'registration_number') String? registrationNumber, @JsonKey(name: 'tax_id') String? taxId, String? industry, @JsonKey(name: 'business_type') String? businessType, @JsonKey(name: 'employee_count') int? employeeCount, @JsonKey(name: 'annual_revenue') int? annualRevenue, @JsonKey(name: 'founded_year') int? foundedYear, @JsonKey(name: 'is_verified') bool? isVerified, @JsonKey(name: 'is_compliant') bool? isCompliant, @JsonKey(name: 'compliance_notes') String? complianceNotes, String? language, String? username, String? currency, String? role, String? timezone, @JsonKey(name: 'created_at') int? createdAt, @JsonKey(name: 'updated_at') int? updatedAt, @JsonKey(name: 'created_by') String? createdBy, @JsonKey(name: 'updated_by') String? updatedBy, Address? address, ContactPerson? contactPersons) $default,) {final _that = this; switch (_that) { case _Customer(): -return $default(_that.id,_that.type,_that.status,_that.firstName,_that.lastName,_that.fullName,_that.email,_that.phone,_that.mobile,_that.registrationNumber,_that.taxId,_that.industry,_that.businessType,_that.employeeCount,_that.annualRevenue,_that.foundedYear,_that.isVerified,_that.isCompliant,_that.complianceNotes,_that.language,_that.username,_that.currency,_that.timezone,_that.createdAt,_that.updatedAt,_that.createdBy,_that.updatedBy,_that.address,_that.contactPersons);case _: +return $default(_that.id,_that.type,_that.status,_that.firstName,_that.lastName,_that.fullName,_that.email,_that.phone,_that.mobile,_that.registrationNumber,_that.taxId,_that.industry,_that.businessType,_that.employeeCount,_that.annualRevenue,_that.foundedYear,_that.isVerified,_that.isCompliant,_that.complianceNotes,_that.language,_that.username,_that.currency,_that.role,_that.timezone,_that.createdAt,_that.updatedAt,_that.createdBy,_that.updatedBy,_that.address,_that.contactPersons);case _: throw StateError('Unexpected subclass'); } @@ -246,10 +247,10 @@ return $default(_that.id,_that.type,_that.status,_that.firstName,_that.lastName, /// } /// ``` -@optionalTypeArgs TResult? whenOrNull(TResult? Function( String? id, String? type, String? status, @JsonKey(name: 'first_name') String? firstName, @JsonKey(name: 'last_name') String? lastName, @JsonKey(name: 'full_name') String? fullName, String? email, String? phone, String? mobile, @JsonKey(name: 'registration_number') String? registrationNumber, @JsonKey(name: 'tax_id') String? taxId, String? industry, @JsonKey(name: 'business_type') String? businessType, @JsonKey(name: 'employee_count') int? employeeCount, @JsonKey(name: 'annual_revenue') int? annualRevenue, @JsonKey(name: 'founded_year') int? foundedYear, @JsonKey(name: 'is_verified') bool? isVerified, @JsonKey(name: 'is_compliant') bool? isCompliant, @JsonKey(name: 'compliance_notes') String? complianceNotes, String? language, String? username, String? currency, String? timezone, @JsonKey(name: 'created_at') int? createdAt, @JsonKey(name: 'updated_at') int? updatedAt, @JsonKey(name: 'created_by') String? createdBy, @JsonKey(name: 'updated_by') String? updatedBy, Address? address, ContactPerson? contactPersons)? $default,) {final _that = this; +@optionalTypeArgs TResult? whenOrNull(TResult? Function( String? id, String? type, String? status, @JsonKey(name: 'first_name') String? firstName, @JsonKey(name: 'last_name') String? lastName, @JsonKey(name: 'full_name') String? fullName, String? email, String? phone, String? mobile, @JsonKey(name: 'registration_number') String? registrationNumber, @JsonKey(name: 'tax_id') String? taxId, String? industry, @JsonKey(name: 'business_type') String? businessType, @JsonKey(name: 'employee_count') int? employeeCount, @JsonKey(name: 'annual_revenue') int? annualRevenue, @JsonKey(name: 'founded_year') int? foundedYear, @JsonKey(name: 'is_verified') bool? isVerified, @JsonKey(name: 'is_compliant') bool? isCompliant, @JsonKey(name: 'compliance_notes') String? complianceNotes, String? language, String? username, String? currency, String? role, String? timezone, @JsonKey(name: 'created_at') int? createdAt, @JsonKey(name: 'updated_at') int? updatedAt, @JsonKey(name: 'created_by') String? createdBy, @JsonKey(name: 'updated_by') String? updatedBy, Address? address, ContactPerson? contactPersons)? $default,) {final _that = this; switch (_that) { case _Customer() when $default != null: -return $default(_that.id,_that.type,_that.status,_that.firstName,_that.lastName,_that.fullName,_that.email,_that.phone,_that.mobile,_that.registrationNumber,_that.taxId,_that.industry,_that.businessType,_that.employeeCount,_that.annualRevenue,_that.foundedYear,_that.isVerified,_that.isCompliant,_that.complianceNotes,_that.language,_that.username,_that.currency,_that.timezone,_that.createdAt,_that.updatedAt,_that.createdBy,_that.updatedBy,_that.address,_that.contactPersons);case _: +return $default(_that.id,_that.type,_that.status,_that.firstName,_that.lastName,_that.fullName,_that.email,_that.phone,_that.mobile,_that.registrationNumber,_that.taxId,_that.industry,_that.businessType,_that.employeeCount,_that.annualRevenue,_that.foundedYear,_that.isVerified,_that.isCompliant,_that.complianceNotes,_that.language,_that.username,_that.currency,_that.role,_that.timezone,_that.createdAt,_that.updatedAt,_that.createdBy,_that.updatedBy,_that.address,_that.contactPersons);case _: return null; } @@ -261,7 +262,7 @@ return $default(_that.id,_that.type,_that.status,_that.firstName,_that.lastName, @JsonSerializable() class _Customer implements Customer { - const _Customer({required this.id, required this.type, required this.status, @JsonKey(name: 'first_name') required this.firstName, @JsonKey(name: 'last_name') required this.lastName, @JsonKey(name: 'full_name') required this.fullName, required this.email, required this.phone, required this.mobile, @JsonKey(name: 'registration_number') required this.registrationNumber, @JsonKey(name: 'tax_id') required this.taxId, required this.industry, @JsonKey(name: 'business_type') required this.businessType, @JsonKey(name: 'employee_count') required this.employeeCount, @JsonKey(name: 'annual_revenue') required this.annualRevenue, @JsonKey(name: 'founded_year') required this.foundedYear, @JsonKey(name: 'is_verified') required this.isVerified, @JsonKey(name: 'is_compliant') required this.isCompliant, @JsonKey(name: 'compliance_notes') required this.complianceNotes, required this.language, required this.username, required this.currency, required this.timezone, @JsonKey(name: 'created_at') required this.createdAt, @JsonKey(name: 'updated_at') required this.updatedAt, @JsonKey(name: 'created_by') required this.createdBy, @JsonKey(name: 'updated_by') required this.updatedBy, required this.address, required this.contactPersons}); + const _Customer({required this.id, required this.type, required this.status, @JsonKey(name: 'first_name') required this.firstName, @JsonKey(name: 'last_name') required this.lastName, @JsonKey(name: 'full_name') required this.fullName, required this.email, required this.phone, required this.mobile, @JsonKey(name: 'registration_number') required this.registrationNumber, @JsonKey(name: 'tax_id') required this.taxId, required this.industry, @JsonKey(name: 'business_type') required this.businessType, @JsonKey(name: 'employee_count') required this.employeeCount, @JsonKey(name: 'annual_revenue') required this.annualRevenue, @JsonKey(name: 'founded_year') required this.foundedYear, @JsonKey(name: 'is_verified') required this.isVerified, @JsonKey(name: 'is_compliant') required this.isCompliant, @JsonKey(name: 'compliance_notes') required this.complianceNotes, required this.language, required this.username, required this.currency, required this.role, required this.timezone, @JsonKey(name: 'created_at') required this.createdAt, @JsonKey(name: 'updated_at') required this.updatedAt, @JsonKey(name: 'created_by') required this.createdBy, @JsonKey(name: 'updated_by') required this.updatedBy, required this.address, required this.contactPersons}); factory _Customer.fromJson(Map json) => _$CustomerFromJson(json); @override final String? id; @@ -286,6 +287,7 @@ class _Customer implements Customer { @override final String? language; @override final String? username; @override final String? currency; +@override final String? role; @override final String? timezone; @override@JsonKey(name: 'created_at') final int? createdAt; @override@JsonKey(name: 'updated_at') final int? updatedAt; @@ -307,16 +309,16 @@ Map toJson() { @override bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is _Customer&&(identical(other.id, id) || other.id == id)&&(identical(other.type, type) || other.type == type)&&(identical(other.status, status) || other.status == status)&&(identical(other.firstName, firstName) || other.firstName == firstName)&&(identical(other.lastName, lastName) || other.lastName == lastName)&&(identical(other.fullName, fullName) || other.fullName == fullName)&&(identical(other.email, email) || other.email == email)&&(identical(other.phone, phone) || other.phone == phone)&&(identical(other.mobile, mobile) || other.mobile == mobile)&&(identical(other.registrationNumber, registrationNumber) || other.registrationNumber == registrationNumber)&&(identical(other.taxId, taxId) || other.taxId == taxId)&&(identical(other.industry, industry) || other.industry == industry)&&(identical(other.businessType, businessType) || other.businessType == businessType)&&(identical(other.employeeCount, employeeCount) || other.employeeCount == employeeCount)&&(identical(other.annualRevenue, annualRevenue) || other.annualRevenue == annualRevenue)&&(identical(other.foundedYear, foundedYear) || other.foundedYear == foundedYear)&&(identical(other.isVerified, isVerified) || other.isVerified == isVerified)&&(identical(other.isCompliant, isCompliant) || other.isCompliant == isCompliant)&&(identical(other.complianceNotes, complianceNotes) || other.complianceNotes == complianceNotes)&&(identical(other.language, language) || other.language == language)&&(identical(other.username, username) || other.username == username)&&(identical(other.currency, currency) || other.currency == currency)&&(identical(other.timezone, timezone) || other.timezone == timezone)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)&&(identical(other.createdBy, createdBy) || other.createdBy == createdBy)&&(identical(other.updatedBy, updatedBy) || other.updatedBy == updatedBy)&&(identical(other.address, address) || other.address == address)&&(identical(other.contactPersons, contactPersons) || other.contactPersons == contactPersons)); + return identical(this, other) || (other.runtimeType == runtimeType&&other is _Customer&&(identical(other.id, id) || other.id == id)&&(identical(other.type, type) || other.type == type)&&(identical(other.status, status) || other.status == status)&&(identical(other.firstName, firstName) || other.firstName == firstName)&&(identical(other.lastName, lastName) || other.lastName == lastName)&&(identical(other.fullName, fullName) || other.fullName == fullName)&&(identical(other.email, email) || other.email == email)&&(identical(other.phone, phone) || other.phone == phone)&&(identical(other.mobile, mobile) || other.mobile == mobile)&&(identical(other.registrationNumber, registrationNumber) || other.registrationNumber == registrationNumber)&&(identical(other.taxId, taxId) || other.taxId == taxId)&&(identical(other.industry, industry) || other.industry == industry)&&(identical(other.businessType, businessType) || other.businessType == businessType)&&(identical(other.employeeCount, employeeCount) || other.employeeCount == employeeCount)&&(identical(other.annualRevenue, annualRevenue) || other.annualRevenue == annualRevenue)&&(identical(other.foundedYear, foundedYear) || other.foundedYear == foundedYear)&&(identical(other.isVerified, isVerified) || other.isVerified == isVerified)&&(identical(other.isCompliant, isCompliant) || other.isCompliant == isCompliant)&&(identical(other.complianceNotes, complianceNotes) || other.complianceNotes == complianceNotes)&&(identical(other.language, language) || other.language == language)&&(identical(other.username, username) || other.username == username)&&(identical(other.currency, currency) || other.currency == currency)&&(identical(other.role, role) || other.role == role)&&(identical(other.timezone, timezone) || other.timezone == timezone)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)&&(identical(other.createdBy, createdBy) || other.createdBy == createdBy)&&(identical(other.updatedBy, updatedBy) || other.updatedBy == updatedBy)&&(identical(other.address, address) || other.address == address)&&(identical(other.contactPersons, contactPersons) || other.contactPersons == contactPersons)); } @JsonKey(includeFromJson: false, includeToJson: false) @override -int get hashCode => Object.hashAll([runtimeType,id,type,status,firstName,lastName,fullName,email,phone,mobile,registrationNumber,taxId,industry,businessType,employeeCount,annualRevenue,foundedYear,isVerified,isCompliant,complianceNotes,language,username,currency,timezone,createdAt,updatedAt,createdBy,updatedBy,address,contactPersons]); +int get hashCode => Object.hashAll([runtimeType,id,type,status,firstName,lastName,fullName,email,phone,mobile,registrationNumber,taxId,industry,businessType,employeeCount,annualRevenue,foundedYear,isVerified,isCompliant,complianceNotes,language,username,currency,role,timezone,createdAt,updatedAt,createdBy,updatedBy,address,contactPersons]); @override String toString() { - return 'Customer(id: $id, type: $type, status: $status, firstName: $firstName, lastName: $lastName, fullName: $fullName, email: $email, phone: $phone, mobile: $mobile, registrationNumber: $registrationNumber, taxId: $taxId, industry: $industry, businessType: $businessType, employeeCount: $employeeCount, annualRevenue: $annualRevenue, foundedYear: $foundedYear, isVerified: $isVerified, isCompliant: $isCompliant, complianceNotes: $complianceNotes, language: $language, username: $username, currency: $currency, timezone: $timezone, createdAt: $createdAt, updatedAt: $updatedAt, createdBy: $createdBy, updatedBy: $updatedBy, address: $address, contactPersons: $contactPersons)'; + return 'Customer(id: $id, type: $type, status: $status, firstName: $firstName, lastName: $lastName, fullName: $fullName, email: $email, phone: $phone, mobile: $mobile, registrationNumber: $registrationNumber, taxId: $taxId, industry: $industry, businessType: $businessType, employeeCount: $employeeCount, annualRevenue: $annualRevenue, foundedYear: $foundedYear, isVerified: $isVerified, isCompliant: $isCompliant, complianceNotes: $complianceNotes, language: $language, username: $username, currency: $currency, role: $role, timezone: $timezone, createdAt: $createdAt, updatedAt: $updatedAt, createdBy: $createdBy, updatedBy: $updatedBy, address: $address, contactPersons: $contactPersons)'; } @@ -327,7 +329,7 @@ abstract mixin class _$CustomerCopyWith<$Res> implements $CustomerCopyWith<$Res> factory _$CustomerCopyWith(_Customer value, $Res Function(_Customer) _then) = __$CustomerCopyWithImpl; @override @useResult $Res call({ - String? id, String? type, String? status,@JsonKey(name: 'first_name') String? firstName,@JsonKey(name: 'last_name') String? lastName,@JsonKey(name: 'full_name') String? fullName, String? email, String? phone, String? mobile,@JsonKey(name: 'registration_number') String? registrationNumber,@JsonKey(name: 'tax_id') String? taxId, String? industry,@JsonKey(name: 'business_type') String? businessType,@JsonKey(name: 'employee_count') int? employeeCount,@JsonKey(name: 'annual_revenue') int? annualRevenue,@JsonKey(name: 'founded_year') int? foundedYear,@JsonKey(name: 'is_verified') bool? isVerified,@JsonKey(name: 'is_compliant') bool? isCompliant,@JsonKey(name: 'compliance_notes') String? complianceNotes, String? language, String? username, String? currency, String? timezone,@JsonKey(name: 'created_at') int? createdAt,@JsonKey(name: 'updated_at') int? updatedAt,@JsonKey(name: 'created_by') String? createdBy,@JsonKey(name: 'updated_by') String? updatedBy, Address? address, ContactPerson? contactPersons + String? id, String? type, String? status,@JsonKey(name: 'first_name') String? firstName,@JsonKey(name: 'last_name') String? lastName,@JsonKey(name: 'full_name') String? fullName, String? email, String? phone, String? mobile,@JsonKey(name: 'registration_number') String? registrationNumber,@JsonKey(name: 'tax_id') String? taxId, String? industry,@JsonKey(name: 'business_type') String? businessType,@JsonKey(name: 'employee_count') int? employeeCount,@JsonKey(name: 'annual_revenue') int? annualRevenue,@JsonKey(name: 'founded_year') int? foundedYear,@JsonKey(name: 'is_verified') bool? isVerified,@JsonKey(name: 'is_compliant') bool? isCompliant,@JsonKey(name: 'compliance_notes') String? complianceNotes, String? language, String? username, String? currency, String? role, String? timezone,@JsonKey(name: 'created_at') int? createdAt,@JsonKey(name: 'updated_at') int? updatedAt,@JsonKey(name: 'created_by') String? createdBy,@JsonKey(name: 'updated_by') String? updatedBy, Address? address, ContactPerson? contactPersons }); @@ -344,7 +346,7 @@ class __$CustomerCopyWithImpl<$Res> /// Create a copy of Customer /// with the given fields replaced by the non-null parameter values. -@override @pragma('vm:prefer-inline') $Res call({Object? id = freezed,Object? type = freezed,Object? status = freezed,Object? firstName = freezed,Object? lastName = freezed,Object? fullName = freezed,Object? email = freezed,Object? phone = freezed,Object? mobile = freezed,Object? registrationNumber = freezed,Object? taxId = freezed,Object? industry = freezed,Object? businessType = freezed,Object? employeeCount = freezed,Object? annualRevenue = freezed,Object? foundedYear = freezed,Object? isVerified = freezed,Object? isCompliant = freezed,Object? complianceNotes = freezed,Object? language = freezed,Object? username = freezed,Object? currency = freezed,Object? timezone = freezed,Object? createdAt = freezed,Object? updatedAt = freezed,Object? createdBy = freezed,Object? updatedBy = freezed,Object? address = freezed,Object? contactPersons = freezed,}) { +@override @pragma('vm:prefer-inline') $Res call({Object? id = freezed,Object? type = freezed,Object? status = freezed,Object? firstName = freezed,Object? lastName = freezed,Object? fullName = freezed,Object? email = freezed,Object? phone = freezed,Object? mobile = freezed,Object? registrationNumber = freezed,Object? taxId = freezed,Object? industry = freezed,Object? businessType = freezed,Object? employeeCount = freezed,Object? annualRevenue = freezed,Object? foundedYear = freezed,Object? isVerified = freezed,Object? isCompliant = freezed,Object? complianceNotes = freezed,Object? language = freezed,Object? username = freezed,Object? currency = freezed,Object? role = freezed,Object? timezone = freezed,Object? createdAt = freezed,Object? updatedAt = freezed,Object? createdBy = freezed,Object? updatedBy = freezed,Object? address = freezed,Object? contactPersons = freezed,}) { return _then(_Customer( id: freezed == id ? _self.id : id // ignore: cast_nullable_to_non_nullable as String?,type: freezed == type ? _self.type : type // ignore: cast_nullable_to_non_nullable @@ -368,6 +370,7 @@ as bool?,complianceNotes: freezed == complianceNotes ? _self.complianceNotes : c as String?,language: freezed == language ? _self.language : language // ignore: cast_nullable_to_non_nullable as String?,username: freezed == username ? _self.username : username // ignore: cast_nullable_to_non_nullable as String?,currency: freezed == currency ? _self.currency : currency // ignore: cast_nullable_to_non_nullable +as String?,role: freezed == role ? _self.role : role // ignore: cast_nullable_to_non_nullable as String?,timezone: freezed == timezone ? _self.timezone : timezone // ignore: cast_nullable_to_non_nullable as String?,createdAt: freezed == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable as int?,updatedAt: freezed == updatedAt ? _self.updatedAt : updatedAt // ignore: cast_nullable_to_non_nullable diff --git a/lib/data/services/model/customer/customer.g.dart b/lib/data/services/model/customer/customer.g.dart index 5cd2348..497c714 100644 --- a/lib/data/services/model/customer/customer.g.dart +++ b/lib/data/services/model/customer/customer.g.dart @@ -29,6 +29,7 @@ _Customer _$CustomerFromJson(Map json) => _Customer( language: json['language'] as String?, username: json['username'] as String?, currency: json['currency'] as String?, + role: json['role'] as String?, timezone: json['timezone'] as String?, createdAt: (json['created_at'] as num?)?.toInt(), updatedAt: (json['updated_at'] as num?)?.toInt(), @@ -69,6 +70,7 @@ Map _$CustomerToJson(_Customer instance) => { 'language': instance.language, 'username': instance.username, 'currency': instance.currency, + 'role': instance.role, 'timezone': instance.timezone, 'created_at': instance.createdAt, 'updated_at': instance.updatedAt, diff --git a/lib/view_models/auth_view_model.dart b/lib/view_models/auth_view_model.dart index 55f063b..37d3beb 100644 --- a/lib/view_models/auth_view_model.dart +++ b/lib/view_models/auth_view_model.dart @@ -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(): _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 } diff --git a/lib/views/detail/widgets/tender_detail_action.dart b/lib/views/detail/widgets/tender_detail_action.dart index b89acc1..37d38df 100644 --- a/lib/views/detail/widgets/tender_detail_action.dart +++ b/lib/views/detail/widgets/tender_detail_action.dart @@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:tm_app/core/theme/colors.dart'; import 'package:tm_app/core/utils/size_config.dart'; +import 'package:tm_app/view_models/auth_view_model.dart'; import 'package:tm_app/view_models/tender_detail_view_model.dart'; import 'package:tm_app/views/detail/widgets/meeting_time_bottom_sheet.dart'; import 'package:tm_app/views/detail/widgets/meeting_time_dialog.dart'; @@ -34,8 +35,9 @@ class TenderDetailActions extends StatefulWidget { class _TenderDetailActionsState extends State { @override Widget build(BuildContext context) { + final userRole = context.read().userRole; return widget.isScreenBig - ? _webActions() + ? _webActions(userRole!) : Column( children: [ Consumer( @@ -141,7 +143,7 @@ class _TenderDetailActionsState extends State { ); } - Row _webActions() { + Row _webActions(Role userRole) { return Row( children: [ const Spacer(), @@ -207,8 +209,13 @@ class _TenderDetailActionsState extends State { if (value == TenderSubmissionMode.selfApply.value) { if (context.mounted) { - const FinalCompletionOfDocumentsRouteData() - .push(context); + if (userRole == Role.analyst) { + const FinalCompletionOfDocumentsRouteData() + .push(context); + } else { + const CompletionOfDocumentsRouteData() + .push(context); + } } } else if (value == TenderSubmissionMode.partnership.value) { diff --git a/lib/views/shared/page_selection_dialog.dart b/lib/views/shared/page_selection_dialog.dart index 54006d1..678e65b 100644 --- a/lib/views/shared/page_selection_dialog.dart +++ b/lib/views/shared/page_selection_dialog.dart @@ -52,6 +52,7 @@ class _PageSelectionDialogState extends State { final pageNumber = index + 1; return ListTile( + contentPadding: EdgeInsets.zero, leading: Radio( value: pageNumber, groupValue: selectedPage, diff --git a/lib/views/shared/select_submission_dialog.dart b/lib/views/shared/select_submission_dialog.dart index 51ae507..08593ba 100644 --- a/lib/views/shared/select_submission_dialog.dart +++ b/lib/views/shared/select_submission_dialog.dart @@ -1,7 +1,6 @@ import 'package:flutter/material.dart'; import 'package:go_router/go_router.dart'; import 'package:tm_app/core/utils/size_config.dart'; -import 'package:tm_app/views/shared/base_button.dart'; import '../../core/constants/common_strings.dart'; import '../../core/constants/tender_submision_mode.dart'; @@ -91,18 +90,35 @@ class _SelectSubmissionDialogState extends State { // ), // ), // ), - BaseButton( - isEnabled: true, - onPressed: () { + InkWell( + highlightColor: Colors.transparent, + splashColor: Colors.transparent, + onTap: () { context.pop(); }, - width: 150, - height: 56.0, - text: CommonStrings.cancel, - backgroundColor: Colors.transparent, - textColor: AppColors.errorColor, - borderColor: AppColors.errorColor, + child: Container( + width: 150, + height: 56.0, + decoration: BoxDecoration( + color: Colors.transparent, + borderRadius: BorderRadius.circular(100), + border: Border.all( + color: AppColors.errorColor, + width: 2.0, + ), + ), + alignment: Alignment.center, + child: Text( + CommonStrings.cancel, + style: TextStyle( + fontSize: 14.0.sp(), + fontWeight: FontWeight.w500, + color: AppColors.errorColor, + ), + ), + ), ), + SizedBox(width: 10.0.w()), InkWell( diff --git a/lib/views/tenders/pages/d_tenders_page.dart b/lib/views/tenders/pages/d_tenders_page.dart index 6ab986e..da0ea0d 100644 --- a/lib/views/tenders/pages/d_tenders_page.dart +++ b/lib/views/tenders/pages/d_tenders_page.dart @@ -17,6 +17,7 @@ import 'package:tm_app/views/tenders/widgets/tenders_sort_dialog.dart'; import '../../../core/constants/common_strings.dart'; import '../../../core/utils/app_toast.dart'; +import '../../../view_models/auth_view_model.dart'; class DesktopTendersPage extends StatefulWidget { const DesktopTendersPage({super.key}); @@ -49,6 +50,7 @@ class _DesktopTendersPageState extends State { @override Widget build(BuildContext context) { + final userRole = context.read().userRole; return Scaffold( backgroundColor: AppColors.backgroundColor, body: SafeArea( @@ -56,8 +58,8 @@ class _DesktopTendersPageState extends State { children: [ const DesktopNavigationWidget(currentIndex: 1), SizedBox(height: 48.0.h()), - const _SearchBox(), - const _ActionButtons(), + if (userRole == Role.analyst) const _SearchBox(), + if (userRole == Role.analyst) const _ActionButtons(), Expanded( child: Consumer( builder: (context, vm, child) { diff --git a/lib/views/your_tenders/pages/your_tenders_desktop_page.dart b/lib/views/your_tenders/pages/your_tenders_desktop_page.dart index dd1fba0..bdf8d07 100644 --- a/lib/views/your_tenders/pages/your_tenders_desktop_page.dart +++ b/lib/views/your_tenders/pages/your_tenders_desktop_page.dart @@ -13,6 +13,7 @@ import 'package:tm_app/views/your_tenders/widgets/liked_disliked_tenders_list.da import 'package:tm_app/views/your_tenders/widgets/tenders_submitted.dart'; import '../../shared/desktop_navigation_widget.dart'; +import '../../shared/page_selection_dialog.dart'; class YourTendersDesktopPage extends StatefulWidget { const YourTendersDesktopPage({super.key}); @@ -149,28 +150,37 @@ class _YourTendersDesktopPageState extends State SizedBox(width: 10.0.w()), InkWell( onTap: () async { + // final selectedPage = await showDialog( + // context: context, + // builder: (context) { + // return AlertDialog( + // backgroundColor: AppColors.backgroundColor, + // title: const Text(YourTendersStrings.selectPage), + // content: SizedBox( + // width: 200.0.w(), + // height: 300.0.h(), + // child: ListView.builder( + // itemCount: viewModel.totalPages, + // itemBuilder: (context, index) { + // final pageNumber = index + 1; + // return ListTile( + // title: Text('${YourTendersStrings.page} $pageNumber'), + // onTap: () => Navigator.pop(context, pageNumber), + // ); + // }, + // ), + // ), + // ); + // }, + // ); + final selectedPage = await showDialog( context: context, - builder: (context) { - return AlertDialog( - backgroundColor: AppColors.backgroundColor, - title: const Text(YourTendersStrings.selectPage), - content: SizedBox( - width: 200.0.w(), - height: 300.0.h(), - child: ListView.builder( - itemCount: viewModel.totalPages, - itemBuilder: (context, index) { - final pageNumber = index + 1; - return ListTile( - title: Text('${YourTendersStrings.page} $pageNumber'), - onTap: () => Navigator.pop(context, pageNumber), - ); - }, - ), + builder: + (context) => PageSelectionDialog( + totalPages: viewModel.totalPages, + currentPage: viewModel.currentPage, ), - ); - }, ); if (selectedPage != null) { diff --git a/test/model/customer_test.dart b/test/model/customer_test.dart index cc350a1..34e32ac 100644 --- a/test/model/customer_test.dart +++ b/test/model/customer_test.dart @@ -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();