Add Docker support and enhance data models for tender details

- Introduced a .dockerignore file to optimize Docker builds by excluding unnecessary files.
- Updated the Dockerfile to use a Flutter base image, enabling web builds for the application.
- Added new data models for `Lot` and `OrganizationAddress` to represent tender details more accurately.
- Enhanced the `Organization` model to include `companyId` and a nested `address` field.
- Updated the `TenderData` model to include new fields such as `noticeTypeCode`, `formType`, and `lots`, reflecting the API response structure.
- Regenerated necessary code for data models to ensure compatibility with the updated structures.
This commit is contained in:
AmirReza Jamali
2026-06-03 13:32:42 +03:30
parent 83b77c05ef
commit dde66521f6
35 changed files with 1362 additions and 659 deletions
@@ -1,15 +1,22 @@
// ignore_for_file: invalid_annotation_target
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:tm_app/data/services/model/organization/organization_address.dart';
part 'organization.freezed.dart';
part 'organization.g.dart';
// AI-NOTE (for PR reviewer): Added company_id and a nested address
// (OrganizationAddress) to surface buyer details on the tender-details page.
// A dedicated OrganizationAddress type is used instead of the existing
// `Address` model because the buyer address shape differs (city_name +
// country_code only) and is unrelated to the user-profile Address.
@freezed
abstract class Organization with _$Organization {
const factory Organization({
required String? name,
@JsonKey(name: 'company_id') required String? companyId,
required OrganizationAddress? address,
}) = _Organization;
factory Organization.fromJson(Map<String, Object?> json) =>
@@ -15,7 +15,7 @@ T _$identity<T>(T value) => value;
/// @nodoc
mixin _$Organization {
String? get name;
String? get name;@JsonKey(name: 'company_id') String? get companyId; OrganizationAddress? get address;
/// Create a copy of Organization
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@@ -28,16 +28,16 @@ $OrganizationCopyWith<Organization> get copyWith => _$OrganizationCopyWithImpl<O
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is Organization&&(identical(other.name, name) || other.name == name));
return identical(this, other) || (other.runtimeType == runtimeType&&other is Organization&&(identical(other.name, name) || other.name == name)&&(identical(other.companyId, companyId) || other.companyId == companyId)&&(identical(other.address, address) || other.address == address));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType,name);
int get hashCode => Object.hash(runtimeType,name,companyId,address);
@override
String toString() {
return 'Organization(name: $name)';
return 'Organization(name: $name, companyId: $companyId, address: $address)';
}
@@ -48,11 +48,11 @@ abstract mixin class $OrganizationCopyWith<$Res> {
factory $OrganizationCopyWith(Organization value, $Res Function(Organization) _then) = _$OrganizationCopyWithImpl;
@useResult
$Res call({
String? name
String? name,@JsonKey(name: 'company_id') String? companyId, OrganizationAddress? address
});
$OrganizationAddressCopyWith<$Res>? get address;
}
/// @nodoc
@@ -65,13 +65,27 @@ class _$OrganizationCopyWithImpl<$Res>
/// Create a copy of Organization
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @override $Res call({Object? name = freezed,}) {
@pragma('vm:prefer-inline') @override $Res call({Object? name = freezed,Object? companyId = freezed,Object? address = freezed,}) {
return _then(_self.copyWith(
name: freezed == name ? _self.name : name // ignore: cast_nullable_to_non_nullable
as String?,
as String?,companyId: freezed == companyId ? _self.companyId : companyId // ignore: cast_nullable_to_non_nullable
as String?,address: freezed == address ? _self.address : address // ignore: cast_nullable_to_non_nullable
as OrganizationAddress?,
));
}
/// Create a copy of Organization
/// with the given fields replaced by the non-null parameter values.
@override
@pragma('vm:prefer-inline')
$OrganizationAddressCopyWith<$Res>? get address {
if (_self.address == null) {
return null;
}
return $OrganizationAddressCopyWith<$Res>(_self.address!, (value) {
return _then(_self.copyWith(address: value));
});
}
}
@@ -153,10 +167,10 @@ return $default(_that);case _:
/// }
/// ```
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String? name)? $default,{required TResult orElse(),}) {final _that = this;
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String? name, @JsonKey(name: 'company_id') String? companyId, OrganizationAddress? address)? $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _Organization() when $default != null:
return $default(_that.name);case _:
return $default(_that.name,_that.companyId,_that.address);case _:
return orElse();
}
@@ -174,10 +188,10 @@ return $default(_that.name);case _:
/// }
/// ```
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String? name) $default,) {final _that = this;
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String? name, @JsonKey(name: 'company_id') String? companyId, OrganizationAddress? address) $default,) {final _that = this;
switch (_that) {
case _Organization():
return $default(_that.name);case _:
return $default(_that.name,_that.companyId,_that.address);case _:
throw StateError('Unexpected subclass');
}
@@ -194,10 +208,10 @@ return $default(_that.name);case _:
/// }
/// ```
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String? name)? $default,) {final _that = this;
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String? name, @JsonKey(name: 'company_id') String? companyId, OrganizationAddress? address)? $default,) {final _that = this;
switch (_that) {
case _Organization() when $default != null:
return $default(_that.name);case _:
return $default(_that.name,_that.companyId,_that.address);case _:
return null;
}
@@ -209,10 +223,12 @@ return $default(_that.name);case _:
@JsonSerializable()
class _Organization implements Organization {
const _Organization({required this.name});
const _Organization({required this.name, @JsonKey(name: 'company_id') required this.companyId, required this.address});
factory _Organization.fromJson(Map<String, dynamic> json) => _$OrganizationFromJson(json);
@override final String? name;
@override@JsonKey(name: 'company_id') final String? companyId;
@override final OrganizationAddress? address;
/// Create a copy of Organization
/// with the given fields replaced by the non-null parameter values.
@@ -227,16 +243,16 @@ Map<String, dynamic> toJson() {
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _Organization&&(identical(other.name, name) || other.name == name));
return identical(this, other) || (other.runtimeType == runtimeType&&other is _Organization&&(identical(other.name, name) || other.name == name)&&(identical(other.companyId, companyId) || other.companyId == companyId)&&(identical(other.address, address) || other.address == address));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType,name);
int get hashCode => Object.hash(runtimeType,name,companyId,address);
@override
String toString() {
return 'Organization(name: $name)';
return 'Organization(name: $name, companyId: $companyId, address: $address)';
}
@@ -247,11 +263,11 @@ abstract mixin class _$OrganizationCopyWith<$Res> implements $OrganizationCopyWi
factory _$OrganizationCopyWith(_Organization value, $Res Function(_Organization) _then) = __$OrganizationCopyWithImpl;
@override @useResult
$Res call({
String? name
String? name,@JsonKey(name: 'company_id') String? companyId, OrganizationAddress? address
});
@override $OrganizationAddressCopyWith<$Res>? get address;
}
/// @nodoc
@@ -264,14 +280,28 @@ class __$OrganizationCopyWithImpl<$Res>
/// Create a copy of Organization
/// with the given fields replaced by the non-null parameter values.
@override @pragma('vm:prefer-inline') $Res call({Object? name = freezed,}) {
@override @pragma('vm:prefer-inline') $Res call({Object? name = freezed,Object? companyId = freezed,Object? address = freezed,}) {
return _then(_Organization(
name: freezed == name ? _self.name : name // ignore: cast_nullable_to_non_nullable
as String?,
as String?,companyId: freezed == companyId ? _self.companyId : companyId // ignore: cast_nullable_to_non_nullable
as String?,address: freezed == address ? _self.address : address // ignore: cast_nullable_to_non_nullable
as OrganizationAddress?,
));
}
/// Create a copy of Organization
/// with the given fields replaced by the non-null parameter values.
@override
@pragma('vm:prefer-inline')
$OrganizationAddressCopyWith<$Res>? get address {
if (_self.address == null) {
return null;
}
return $OrganizationAddressCopyWith<$Res>(_self.address!, (value) {
return _then(_self.copyWith(address: value));
});
}
}
// dart format on
@@ -7,7 +7,20 @@ part of 'organization.dart';
// **************************************************************************
_Organization _$OrganizationFromJson(Map<String, dynamic> json) =>
_Organization(name: json['name'] as String?);
_Organization(
name: json['name'] as String?,
companyId: json['company_id'] as String?,
address:
json['address'] == null
? null
: OrganizationAddress.fromJson(
json['address'] as Map<String, dynamic>,
),
);
Map<String, dynamic> _$OrganizationToJson(_Organization instance) =>
<String, dynamic>{'name': instance.name};
<String, dynamic>{
'name': instance.name,
'company_id': instance.companyId,
'address': instance.address,
};
@@ -0,0 +1,21 @@
// ignore_for_file: invalid_annotation_target
import 'package:freezed_annotation/freezed_annotation.dart';
part 'organization_address.freezed.dart';
part 'organization_address.g.dart';
// AI-NOTE (for PR reviewer): New model for the buyer_organization.address
// object from the tender-details API. Kept separate from the existing profile
// `Address` model because the shapes differ (this one only needs city_name and
// country_code). Only the fields the UI shows are mapped.
@freezed
abstract class OrganizationAddress with _$OrganizationAddress {
const factory OrganizationAddress({
@JsonKey(name: 'city_name') required String? cityName,
@JsonKey(name: 'country_code') required String? countryCode,
}) = _OrganizationAddress;
factory OrganizationAddress.fromJson(Map<String, Object?> json) =>
_$OrganizationAddressFromJson(json);
}
@@ -0,0 +1,280 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
// coverage:ignore-file
// ignore_for_file: type=lint
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
part of 'organization_address.dart';
// **************************************************************************
// FreezedGenerator
// **************************************************************************
// dart format off
T _$identity<T>(T value) => value;
/// @nodoc
mixin _$OrganizationAddress {
@JsonKey(name: 'city_name') String? get cityName;@JsonKey(name: 'country_code') String? get countryCode;
/// Create a copy of OrganizationAddress
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
$OrganizationAddressCopyWith<OrganizationAddress> get copyWith => _$OrganizationAddressCopyWithImpl<OrganizationAddress>(this as OrganizationAddress, _$identity);
/// Serializes this OrganizationAddress to a JSON map.
Map<String, dynamic> toJson();
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is OrganizationAddress&&(identical(other.cityName, cityName) || other.cityName == cityName)&&(identical(other.countryCode, countryCode) || other.countryCode == countryCode));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType,cityName,countryCode);
@override
String toString() {
return 'OrganizationAddress(cityName: $cityName, countryCode: $countryCode)';
}
}
/// @nodoc
abstract mixin class $OrganizationAddressCopyWith<$Res> {
factory $OrganizationAddressCopyWith(OrganizationAddress value, $Res Function(OrganizationAddress) _then) = _$OrganizationAddressCopyWithImpl;
@useResult
$Res call({
@JsonKey(name: 'city_name') String? cityName,@JsonKey(name: 'country_code') String? countryCode
});
}
/// @nodoc
class _$OrganizationAddressCopyWithImpl<$Res>
implements $OrganizationAddressCopyWith<$Res> {
_$OrganizationAddressCopyWithImpl(this._self, this._then);
final OrganizationAddress _self;
final $Res Function(OrganizationAddress) _then;
/// Create a copy of OrganizationAddress
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @override $Res call({Object? cityName = freezed,Object? countryCode = freezed,}) {
return _then(_self.copyWith(
cityName: freezed == cityName ? _self.cityName : cityName // ignore: cast_nullable_to_non_nullable
as String?,countryCode: freezed == countryCode ? _self.countryCode : countryCode // ignore: cast_nullable_to_non_nullable
as String?,
));
}
}
/// Adds pattern-matching-related methods to [OrganizationAddress].
extension OrganizationAddressPatterns on OrganizationAddress {
/// A variant of `map` that fallback to returning `orElse`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeMap<TResult extends Object?>(TResult Function( _OrganizationAddress value)? $default,{required TResult orElse(),}){
final _that = this;
switch (_that) {
case _OrganizationAddress() when $default != null:
return $default(_that);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// Callbacks receives the raw object, upcasted.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case final Subclass2 value:
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult map<TResult extends Object?>(TResult Function( _OrganizationAddress value) $default,){
final _that = this;
switch (_that) {
case _OrganizationAddress():
return $default(_that);case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `map` that fallback to returning `null`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>(TResult? Function( _OrganizationAddress value)? $default,){
final _that = this;
switch (_that) {
case _OrganizationAddress() when $default != null:
return $default(_that);case _:
return null;
}
}
/// A variant of `when` that fallback to an `orElse` callback.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function(@JsonKey(name: 'city_name') String? cityName, @JsonKey(name: 'country_code') String? countryCode)? $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _OrganizationAddress() when $default != null:
return $default(_that.cityName,_that.countryCode);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// As opposed to `map`, this offers destructuring.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case Subclass2(:final field2):
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function(@JsonKey(name: 'city_name') String? cityName, @JsonKey(name: 'country_code') String? countryCode) $default,) {final _that = this;
switch (_that) {
case _OrganizationAddress():
return $default(_that.cityName,_that.countryCode);case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `when` that fallback to returning `null`
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function(@JsonKey(name: 'city_name') String? cityName, @JsonKey(name: 'country_code') String? countryCode)? $default,) {final _that = this;
switch (_that) {
case _OrganizationAddress() when $default != null:
return $default(_that.cityName,_that.countryCode);case _:
return null;
}
}
}
/// @nodoc
@JsonSerializable()
class _OrganizationAddress implements OrganizationAddress {
const _OrganizationAddress({@JsonKey(name: 'city_name') required this.cityName, @JsonKey(name: 'country_code') required this.countryCode});
factory _OrganizationAddress.fromJson(Map<String, dynamic> json) => _$OrganizationAddressFromJson(json);
@override@JsonKey(name: 'city_name') final String? cityName;
@override@JsonKey(name: 'country_code') final String? countryCode;
/// Create a copy of OrganizationAddress
/// with the given fields replaced by the non-null parameter values.
@override @JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
_$OrganizationAddressCopyWith<_OrganizationAddress> get copyWith => __$OrganizationAddressCopyWithImpl<_OrganizationAddress>(this, _$identity);
@override
Map<String, dynamic> toJson() {
return _$OrganizationAddressToJson(this, );
}
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _OrganizationAddress&&(identical(other.cityName, cityName) || other.cityName == cityName)&&(identical(other.countryCode, countryCode) || other.countryCode == countryCode));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType,cityName,countryCode);
@override
String toString() {
return 'OrganizationAddress(cityName: $cityName, countryCode: $countryCode)';
}
}
/// @nodoc
abstract mixin class _$OrganizationAddressCopyWith<$Res> implements $OrganizationAddressCopyWith<$Res> {
factory _$OrganizationAddressCopyWith(_OrganizationAddress value, $Res Function(_OrganizationAddress) _then) = __$OrganizationAddressCopyWithImpl;
@override @useResult
$Res call({
@JsonKey(name: 'city_name') String? cityName,@JsonKey(name: 'country_code') String? countryCode
});
}
/// @nodoc
class __$OrganizationAddressCopyWithImpl<$Res>
implements _$OrganizationAddressCopyWith<$Res> {
__$OrganizationAddressCopyWithImpl(this._self, this._then);
final _OrganizationAddress _self;
final $Res Function(_OrganizationAddress) _then;
/// Create a copy of OrganizationAddress
/// with the given fields replaced by the non-null parameter values.
@override @pragma('vm:prefer-inline') $Res call({Object? cityName = freezed,Object? countryCode = freezed,}) {
return _then(_OrganizationAddress(
cityName: freezed == cityName ? _self.cityName : cityName // ignore: cast_nullable_to_non_nullable
as String?,countryCode: freezed == countryCode ? _self.countryCode : countryCode // ignore: cast_nullable_to_non_nullable
as String?,
));
}
}
// dart format on
@@ -0,0 +1,20 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'organization_address.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
_OrganizationAddress _$OrganizationAddressFromJson(Map<String, dynamic> json) =>
_OrganizationAddress(
cityName: json['city_name'] as String?,
countryCode: json['country_code'] as String?,
);
Map<String, dynamic> _$OrganizationAddressToJson(
_OrganizationAddress instance,
) => <String, dynamic>{
'city_name': instance.cityName,
'country_code': instance.countryCode,
};