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
@@ -33,6 +33,7 @@ abstract class Customer with _$Customer {
required String? language, required String? language,
required String? username, required String? username,
required String? currency, required String? currency,
required String? role,
required String? timezone, required String? timezone,
@JsonKey(name: 'created_at') required int? createdAt, @JsonKey(name: 'created_at') required int? createdAt,
@JsonKey(name: 'updated_at') required int? updatedAt, @JsonKey(name: 'updated_at') required int? updatedAt,
@@ -15,7 +15,7 @@ T _$identity<T>(T value) => value;
/// @nodoc /// @nodoc
mixin _$Customer { 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 /// Create a copy of Customer
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false) @JsonKey(includeFromJson: false, includeToJson: false)
@@ -28,16 +28,16 @@ $CustomerCopyWith<Customer> get copyWith => _$CustomerCopyWithImpl<Customer>(thi
@override @override
bool operator ==(Object other) { 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) @JsonKey(includeFromJson: false, includeToJson: false)
@override @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 @override
String toString() { 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; factory $CustomerCopyWith(Customer value, $Res Function(Customer) _then) = _$CustomerCopyWithImpl;
@useResult @useResult
$Res call({ $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 /// Create a copy of Customer
/// with the given fields replaced by the non-null parameter values. /// 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( return _then(_self.copyWith(
id: freezed == id ? _self.id : id // ignore: cast_nullable_to_non_nullable 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 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?,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?,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?,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?,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 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 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 extends Object?>(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 extends Object?>(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) { switch (_that) {
case _Customer() when $default != null: 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(); return orElse();
} }
@@ -226,10 +227,10 @@ return $default(_that.id,_that.type,_that.status,_that.firstName,_that.lastName,
/// } /// }
/// ``` /// ```
@optionalTypeArgs TResult when<TResult extends Object?>(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 extends Object?>(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) { switch (_that) {
case _Customer(): 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'); throw StateError('Unexpected subclass');
} }
@@ -246,10 +247,10 @@ return $default(_that.id,_that.type,_that.status,_that.firstName,_that.lastName,
/// } /// }
/// ``` /// ```
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(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 extends Object?>(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) { switch (_that) {
case _Customer() when $default != null: 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; return null;
} }
@@ -261,7 +262,7 @@ return $default(_that.id,_that.type,_that.status,_that.firstName,_that.lastName,
@JsonSerializable() @JsonSerializable()
class _Customer implements Customer { 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<String, dynamic> json) => _$CustomerFromJson(json); factory _Customer.fromJson(Map<String, dynamic> json) => _$CustomerFromJson(json);
@override final String? id; @override final String? id;
@@ -286,6 +287,7 @@ class _Customer implements Customer {
@override final String? language; @override final String? language;
@override final String? username; @override final String? username;
@override final String? currency; @override final String? currency;
@override final String? role;
@override final String? timezone; @override final String? timezone;
@override@JsonKey(name: 'created_at') final int? createdAt; @override@JsonKey(name: 'created_at') final int? createdAt;
@override@JsonKey(name: 'updated_at') final int? updatedAt; @override@JsonKey(name: 'updated_at') final int? updatedAt;
@@ -307,16 +309,16 @@ Map<String, dynamic> toJson() {
@override @override
bool operator ==(Object other) { 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) @JsonKey(includeFromJson: false, includeToJson: false)
@override @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 @override
String toString() { 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; factory _$CustomerCopyWith(_Customer value, $Res Function(_Customer) _then) = __$CustomerCopyWithImpl;
@override @useResult @override @useResult
$Res call({ $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 /// Create a copy of Customer
/// with the given fields replaced by the non-null parameter values. /// 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( return _then(_Customer(
id: freezed == id ? _self.id : id // ignore: cast_nullable_to_non_nullable 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 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?,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?,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?,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?,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 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 as int?,updatedAt: freezed == updatedAt ? _self.updatedAt : updatedAt // ignore: cast_nullable_to_non_nullable
@@ -29,6 +29,7 @@ _Customer _$CustomerFromJson(Map<String, dynamic> json) => _Customer(
language: json['language'] as String?, language: json['language'] as String?,
username: json['username'] as String?, username: json['username'] as String?,
currency: json['currency'] as String?, currency: json['currency'] as String?,
role: json['role'] as String?,
timezone: json['timezone'] as String?, timezone: json['timezone'] as String?,
createdAt: (json['created_at'] as num?)?.toInt(), createdAt: (json['created_at'] as num?)?.toInt(),
updatedAt: (json['updated_at'] as num?)?.toInt(), updatedAt: (json['updated_at'] as num?)?.toInt(),
@@ -69,6 +70,7 @@ Map<String, dynamic> _$CustomerToJson(_Customer instance) => <String, dynamic>{
'language': instance.language, 'language': instance.language,
'username': instance.username, 'username': instance.username,
'currency': instance.currency, 'currency': instance.currency,
'role': instance.role,
'timezone': instance.timezone, 'timezone': instance.timezone,
'created_at': instance.createdAt, 'created_at': instance.createdAt,
'updated_at': instance.updatedAt, 'updated_at': instance.updatedAt,
+5
View File
@@ -33,11 +33,13 @@ class AuthViewModel with ChangeNotifier {
String? _errorMessage; String? _errorMessage;
Customer? _loggedInUser; Customer? _loggedInUser;
String? successMessage; String? successMessage;
Role? _userRole;
bool get isLoading => _isLoading; bool get isLoading => _isLoading;
bool get isLoggedIn => _isLoggedIn; bool get isLoggedIn => _isLoggedIn;
String? get errorMessage => _errorMessage; String? get errorMessage => _errorMessage;
Customer? get loggedInUser => _loggedInUser; Customer? get loggedInUser => _loggedInUser;
Role? get userRole => _userRole;
void togglePasswordVisibility() { void togglePasswordVisibility() {
_obscurePassword = !_obscurePassword; _obscurePassword = !_obscurePassword;
@@ -63,6 +65,7 @@ class AuthViewModel with ChangeNotifier {
switch (result) { switch (result) {
case Ok<LoginResponseModel>(): case Ok<LoginResponseModel>():
_loggedInUser = result.value.data.customer; _loggedInUser = result.value.data.customer;
_userRole = _loggedInUser?.role == 'admin' ? Role.admin : Role.analyst;
usernameController.clear(); usernameController.clear();
passwordController.clear(); passwordController.clear();
break; break;
@@ -123,3 +126,5 @@ class AuthViewModel with ChangeNotifier {
super.dispose(); super.dispose();
} }
} }
enum Role { admin, analyst }
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'package:tm_app/core/theme/colors.dart'; import 'package:tm_app/core/theme/colors.dart';
import 'package:tm_app/core/utils/size_config.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/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_bottom_sheet.dart';
import 'package:tm_app/views/detail/widgets/meeting_time_dialog.dart'; import 'package:tm_app/views/detail/widgets/meeting_time_dialog.dart';
@@ -34,8 +35,9 @@ class TenderDetailActions extends StatefulWidget {
class _TenderDetailActionsState extends State<TenderDetailActions> { class _TenderDetailActionsState extends State<TenderDetailActions> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final userRole = context.read<AuthViewModel>().userRole;
return widget.isScreenBig return widget.isScreenBig
? _webActions() ? _webActions(userRole!)
: Column( : Column(
children: [ children: [
Consumer<TenderDetailViewModel>( Consumer<TenderDetailViewModel>(
@@ -141,7 +143,7 @@ class _TenderDetailActionsState extends State<TenderDetailActions> {
); );
} }
Row _webActions() { Row _webActions(Role userRole) {
return Row( return Row(
children: [ children: [
const Spacer(), const Spacer(),
@@ -207,8 +209,13 @@ class _TenderDetailActionsState extends State<TenderDetailActions> {
if (value == if (value ==
TenderSubmissionMode.selfApply.value) { TenderSubmissionMode.selfApply.value) {
if (context.mounted) { if (context.mounted) {
if (userRole == Role.analyst) {
const FinalCompletionOfDocumentsRouteData() const FinalCompletionOfDocumentsRouteData()
.push(context); .push(context);
} else {
const CompletionOfDocumentsRouteData()
.push(context);
}
} }
} else if (value == } else if (value ==
TenderSubmissionMode.partnership.value) { TenderSubmissionMode.partnership.value) {
@@ -52,6 +52,7 @@ class _PageSelectionDialogState extends State<PageSelectionDialog> {
final pageNumber = index + 1; final pageNumber = index + 1;
return ListTile( return ListTile(
contentPadding: EdgeInsets.zero,
leading: Radio<int>( leading: Radio<int>(
value: pageNumber, value: pageNumber,
groupValue: selectedPage, groupValue: selectedPage,
+24 -8
View File
@@ -1,7 +1,6 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart'; import 'package:go_router/go_router.dart';
import 'package:tm_app/core/utils/size_config.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/common_strings.dart';
import '../../core/constants/tender_submision_mode.dart'; import '../../core/constants/tender_submision_mode.dart';
@@ -91,18 +90,35 @@ class _SelectSubmissionDialogState extends State<SelectSubmissionDialog> {
// ), // ),
// ), // ),
// ), // ),
BaseButton( InkWell(
isEnabled: true, highlightColor: Colors.transparent,
onPressed: () { splashColor: Colors.transparent,
onTap: () {
context.pop(); context.pop();
}, },
child: Container(
width: 150, width: 150,
height: 56.0, height: 56.0,
text: CommonStrings.cancel, decoration: BoxDecoration(
backgroundColor: Colors.transparent, color: Colors.transparent,
textColor: AppColors.errorColor, borderRadius: BorderRadius.circular(100),
borderColor: AppColors.errorColor, 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()), SizedBox(width: 10.0.w()),
InkWell( InkWell(
+4 -2
View File
@@ -17,6 +17,7 @@ import 'package:tm_app/views/tenders/widgets/tenders_sort_dialog.dart';
import '../../../core/constants/common_strings.dart'; import '../../../core/constants/common_strings.dart';
import '../../../core/utils/app_toast.dart'; import '../../../core/utils/app_toast.dart';
import '../../../view_models/auth_view_model.dart';
class DesktopTendersPage extends StatefulWidget { class DesktopTendersPage extends StatefulWidget {
const DesktopTendersPage({super.key}); const DesktopTendersPage({super.key});
@@ -49,6 +50,7 @@ class _DesktopTendersPageState extends State<DesktopTendersPage> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final userRole = context.read<AuthViewModel>().userRole;
return Scaffold( return Scaffold(
backgroundColor: AppColors.backgroundColor, backgroundColor: AppColors.backgroundColor,
body: SafeArea( body: SafeArea(
@@ -56,8 +58,8 @@ class _DesktopTendersPageState extends State<DesktopTendersPage> {
children: [ children: [
const DesktopNavigationWidget(currentIndex: 1), const DesktopNavigationWidget(currentIndex: 1),
SizedBox(height: 48.0.h()), SizedBox(height: 48.0.h()),
const _SearchBox(), if (userRole == Role.analyst) const _SearchBox(),
const _ActionButtons(), if (userRole == Role.analyst) const _ActionButtons(),
Expanded( Expanded(
child: Consumer<TendersViewModel>( child: Consumer<TendersViewModel>(
builder: (context, vm, child) { builder: (context, vm, child) {
@@ -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 'package:tm_app/views/your_tenders/widgets/tenders_submitted.dart';
import '../../shared/desktop_navigation_widget.dart'; import '../../shared/desktop_navigation_widget.dart';
import '../../shared/page_selection_dialog.dart';
class YourTendersDesktopPage extends StatefulWidget { class YourTendersDesktopPage extends StatefulWidget {
const YourTendersDesktopPage({super.key}); const YourTendersDesktopPage({super.key});
@@ -149,28 +150,37 @@ class _YourTendersDesktopPageState extends State<YourTendersDesktopPage>
SizedBox(width: 10.0.w()), SizedBox(width: 10.0.w()),
InkWell( InkWell(
onTap: () async { onTap: () async {
// final selectedPage = await showDialog<int>(
// 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<int>( final selectedPage = await showDialog<int>(
context: context, context: context,
builder: (context) { builder:
return AlertDialog( (context) => PageSelectionDialog(
backgroundColor: AppColors.backgroundColor, totalPages: viewModel.totalPages,
title: const Text(YourTendersStrings.selectPage), currentPage: viewModel.currentPage,
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),
);
},
), ),
),
);
},
); );
if (selectedPage != null) { if (selectedPage != null) {
+9
View File
@@ -23,6 +23,7 @@ void main() {
'employee_count': 50, 'employee_count': 50,
'annual_revenue': 1000000, 'annual_revenue': 1000000,
'founded_year': 2015, 'founded_year': 2015,
'role': 'admin',
'is_verified': true, 'is_verified': true,
'is_compliant': false, 'is_compliant': false,
'compliance_notes': 'Pending documents', 'compliance_notes': 'Pending documents',
@@ -60,6 +61,7 @@ void main() {
expect(customer.id, '123'); expect(customer.id, '123');
expect(customer.firstName, 'John'); expect(customer.firstName, 'John');
expect(customer.lastName, 'Doe'); expect(customer.lastName, 'Doe');
expect(customer.role, 'admin');
expect(customer.isVerified, true); expect(customer.isVerified, true);
expect(customer.isCompliant, false); expect(customer.isCompliant, false);
expect(customer.address?.city, 'Tehran'); expect(customer.address?.city, 'Tehran');
@@ -106,6 +108,7 @@ void main() {
employeeCount: 200, employeeCount: 200,
annualRevenue: 5000000, annualRevenue: 5000000,
foundedYear: 2010, foundedYear: 2010,
role: 'admin',
isVerified: false, isVerified: false,
isCompliant: true, isCompliant: true,
complianceNotes: 'Verified', complianceNotes: 'Verified',
@@ -150,6 +153,7 @@ void main() {
employeeCount: 50, employeeCount: 50,
annualRevenue: 1000000, annualRevenue: 1000000,
foundedYear: 2015, foundedYear: 2015,
role: 'admin',
isVerified: true, isVerified: true,
isCompliant: true, isCompliant: true,
complianceNotes: 'OK', complianceNotes: 'OK',
@@ -184,10 +188,12 @@ void main() {
final updated = customer.copyWith( final updated = customer.copyWith(
firstName: 'NewName', firstName: 'NewName',
role: 'analyst',
isVerified: false, isVerified: false,
); );
expect(updated.firstName, 'NewName'); expect(updated.firstName, 'NewName');
expect(updated.role, 'analyst');
expect(updated.isVerified, false); expect(updated.isVerified, false);
expect(updated.id, '123'); expect(updated.id, '123');
}); });
@@ -199,6 +205,7 @@ void main() {
expect(customer.id, isNull); expect(customer.id, isNull);
expect(customer.firstName, isNull); expect(customer.firstName, isNull);
expect(customer.role, isNull);
expect(customer.isVerified, isNull); expect(customer.isVerified, isNull);
}); });
@@ -207,6 +214,7 @@ void main() {
'id': 'A1', 'id': 'A1',
'first_name': 'Ali', 'first_name': 'Ali',
'last_name': 'Rezaei', 'last_name': 'Rezaei',
'role': 'admin',
'is_verified': true, 'is_verified': true,
'address': {'city': 'Tehran'}, 'address': {'city': 'Tehran'},
'contactPersons': {'first_name': 'Sara', 'is_primary': true}, 'contactPersons': {'first_name': 'Sara', 'is_primary': true},
@@ -217,6 +225,7 @@ void main() {
expect(output['id'], 'A1'); expect(output['id'], 'A1');
expect(output['first_name'], 'Ali'); expect(output['first_name'], 'Ali');
expect(output['role'], 'admin');
expect(output['is_verified'], true); expect(output['is_verified'], true);
final addressJson = (output['address'] as Address).toJson(); final addressJson = (output['address'] as Address).toJson();
final contactJson = (output['contactPersons'] as ContactPerson).toJson(); final contactJson = (output['contactPersons'] as ContactPerson).toJson();