diff --git a/lib/core/routes/app_routes.dart b/lib/core/routes/app_routes.dart index a0d6c2f..ad01d6c 100644 --- a/lib/core/routes/app_routes.dart +++ b/lib/core/routes/app_routes.dart @@ -143,16 +143,17 @@ class YourTendersRouteData extends GoRouteData with _$YourTendersRouteData { @override Widget build(BuildContext context, GoRouterState state) { - return const YourTendersScreen(); + return YourTendersScreen(); } } @TypedGoRoute(path: '/tender-detail') class TenderDetailRouteData extends GoRouteData with _$TenderDetailRouteData { - const TenderDetailRouteData(); + final String tenderId; + const TenderDetailRouteData({required this.tenderId}); @override Widget build(BuildContext context, GoRouterState state) { - return const TenderDetailScreen(); + return TenderDetailScreen(tenderId: tenderId); } } diff --git a/lib/core/routes/app_routes.g.dart b/lib/core/routes/app_routes.g.dart index 0257261..708bf42 100644 --- a/lib/core/routes/app_routes.g.dart +++ b/lib/core/routes/app_routes.g.dart @@ -175,10 +175,15 @@ RouteBase get $tenderDetailRouteData => GoRouteData.$route( mixin _$TenderDetailRouteData on GoRouteData { static TenderDetailRouteData _fromState(GoRouterState state) => - const TenderDetailRouteData(); + TenderDetailRouteData(tenderId: state.uri.queryParameters['tender-id']!); + + TenderDetailRouteData get _self => this as TenderDetailRouteData; @override - String get location => GoRouteData.$location('/tender-detail'); + String get location => GoRouteData.$location( + '/tender-detail', + queryParams: {'tender-id': _self.tenderId}, + ); @override void go(BuildContext context) => context.go(location); diff --git a/lib/core/utils/date_utils.dart b/lib/core/utils/date_utils.dart new file mode 100644 index 0000000..13eb8ab --- /dev/null +++ b/lib/core/utils/date_utils.dart @@ -0,0 +1,96 @@ +import 'package:intl/intl.dart'; + +class DateUtils { + /// Converts Unix timestamp (seconds since epoch) to a formatted date string + static String unixToDate(int? unixTimestamp, {String format = 'yyyy-MM-dd'}) { + if (unixTimestamp == null) return ''; + + // Convert seconds to milliseconds if needed + int timestampInMs = + unixTimestamp > 1000000000000 ? unixTimestamp : unixTimestamp * 1000; + + final DateTime dateTime = DateTime.fromMillisecondsSinceEpoch( + timestampInMs, + ); + return DateFormat(format).format(dateTime); + } + + /// Converts Unix timestamp to a readable date string + static String unixToReadableDate(int? unixTimestamp) { + if (unixTimestamp == null) return ''; + + int timestampInMs = + unixTimestamp > 1000000000000 ? unixTimestamp : unixTimestamp * 1000; + + final DateTime dateTime = DateTime.fromMillisecondsSinceEpoch( + timestampInMs, + ); + final DateTime now = DateTime.now(); + final Duration difference = now.difference(dateTime); + + if (difference.inDays == 0) { + return 'Today'; + } else if (difference.inDays == 1) { + return 'Yesterday'; + } else if (difference.inDays < 7) { + return '${difference.inDays} days ago'; + } else { + return DateFormat('MMM dd, yyyy').format(dateTime); + } + } + + /// Converts Unix timestamp to a short date format + static String unixToShortDate(int? unixTimestamp) { + if (unixTimestamp == null) return ''; + + int timestampInMs = + unixTimestamp > 1000000000000 ? unixTimestamp : unixTimestamp * 1000; + + final DateTime dateTime = DateTime.fromMillisecondsSinceEpoch( + timestampInMs, + ); + return DateFormat('MMM dd').format(dateTime); + } + + /// Converts Unix timestamp to a full date and time format + static String unixToDateTime(int? unixTimestamp) { + if (unixTimestamp == null) return ''; + + int timestampInMs = + unixTimestamp > 1000000000000 ? unixTimestamp : unixTimestamp * 1000; + + final DateTime dateTime = DateTime.fromMillisecondsSinceEpoch( + timestampInMs, + ); + return DateFormat('MMM dd, yyyy HH:mm').format(dateTime); + } + + /// Checks if a Unix timestamp is in the past + static bool isPast(int? unixTimestamp) { + if (unixTimestamp == null) return false; + + int timestampInMs = + unixTimestamp > 1000000000000 ? unixTimestamp : unixTimestamp * 1000; + + final DateTime dateTime = DateTime.fromMillisecondsSinceEpoch( + timestampInMs, + ); + return dateTime.isBefore(DateTime.now()); + } + + /// Gets the number of days remaining until a Unix timestamp + static int daysRemaining(int? unixTimestamp) { + if (unixTimestamp == null) return 0; + + int timestampInMs = + unixTimestamp > 1000000000000 ? unixTimestamp : unixTimestamp * 1000; + + final DateTime dateTime = DateTime.fromMillisecondsSinceEpoch( + timestampInMs, + ); + final DateTime now = DateTime.now(); + final Duration difference = dateTime.difference(now); + + return difference.inDays; + } +} diff --git a/lib/data/repositories/tender_detail_repository.dart b/lib/data/repositories/tender_detail_repository.dart index 3ad1065..41e50ff 100644 --- a/lib/data/repositories/tender_detail_repository.dart +++ b/lib/data/repositories/tender_detail_repository.dart @@ -1,18 +1,17 @@ import 'package:tm_app/core/utils/result.dart'; -import 'package:tm_app/data/services/model/tender_detail_request/tender_detail_request.dart'; -import 'package:tm_app/data/services/model/tender_detail_response/tender_detail_response_model.dart'; import 'package:tm_app/data/services/tender_detail_service.dart'; +import '../services/model/tender_detail_response/tender_detail_response_model.dart'; + class TenderDetailRepository { TenderDetailRepository({required TenderDetailService tenderDetailService}) - : _tenderDetailService = tenderDetailService; + : _tenderDetailService = tenderDetailService; final TenderDetailService _tenderDetailService; -Future> getTenderDetail({ - required TenderDetailRequest request, -}) async { - return await _tenderDetailService.getTenderDetail(request: request); -} - + Future> getTenderDetail({ + required String tenderId, + }) async { + return _tenderDetailService.getTenderDetails(tenderId: tenderId); + } } diff --git a/lib/data/repositories/tenders_repository.dart b/lib/data/repositories/tenders_repository.dart index 4c696f0..31b803b 100644 --- a/lib/data/repositories/tenders_repository.dart +++ b/lib/data/repositories/tenders_repository.dart @@ -3,7 +3,6 @@ import 'package:tm_app/data/services/model/tenders/tender_dislike_response/tende import 'package:tm_app/data/services/model/tenders/tender_like_response/tender_like_response.dart'; import 'package:tm_app/data/services/model/tenders/tender_reject_response/tender_reject_response.dart'; import 'package:tm_app/data/services/model/tenders/tender_submit_response/tender_submit_response.dart'; -import 'package:tm_app/data/services/model/tenders/tenders_request/tenders_request.dart'; import 'package:tm_app/data/services/model/tenders/tenders_response/tenders_response.dart'; import 'package:tm_app/data/services/tenders_service.dart'; @@ -12,10 +11,8 @@ class TendersRepository { : _tendersService = tendersService; final TendersService _tendersService; - Future> getTenders({ - TendersRequest? tendersRequestModel, - }) async { - return _tendersService.getTenders(tendersRequestModel: tendersRequestModel); + Future> getTenders() async { + return _tendersService.getTenders(); } Future> likeTender() async { diff --git a/lib/data/services/auth_service.dart b/lib/data/services/auth_service.dart index d18a1fa..39c4564 100644 --- a/lib/data/services/auth_service.dart +++ b/lib/data/services/auth_service.dart @@ -22,7 +22,7 @@ class AuthService { var data = jsonEncode({"password": password, "username": username}); final result = await _networkManager.makeRequest( - '/admin/v1/profile/login', + '/api/v1/profile/login', method: 'POST', (json) => LoginResponseModel.fromJson(json), data: data, @@ -31,14 +31,14 @@ class AuthService { if (result is Ok) { final prefs = await SharedPreferences.getInstance(); final token = result.value.data.accessToken; - await prefs.setString('bearer', token); + await prefs.setString('bearer', token!); } return result; } Future> logout() async { final result = await _networkManager.makeRequest( - '/admin/v1/profile/logout', + '/api/v1/profile/logout', method: 'DELETE', (json) => LogoutResponse.fromJson(json), ); diff --git a/lib/data/services/model/address/address.dart b/lib/data/services/model/address/address.dart new file mode 100644 index 0000000..ec3dacb --- /dev/null +++ b/lib/data/services/model/address/address.dart @@ -0,0 +1,22 @@ +// ignore_for_file: invalid_annotation_target + +import 'package:freezed_annotation/freezed_annotation.dart'; + +part 'address.freezed.dart'; +part 'address.g.dart'; + +@freezed +abstract class Address with _$Address { + const factory Address({ + required String? street, + required String? city, + required String? state, + @JsonKey(name: 'postal_code') required String? postalCode, + required String? country, + @JsonKey(name: 'address_type') required String? addressType, + @JsonKey(name: 'is_default') required bool? isDefault, + }) = _Address; + + factory Address.fromJson(Map json) => + _$AddressFromJson(json); +} diff --git a/lib/data/services/model/address/address.freezed.dart b/lib/data/services/model/address/address.freezed.dart new file mode 100644 index 0000000..5772bd0 --- /dev/null +++ b/lib/data/services/model/address/address.freezed.dart @@ -0,0 +1,295 @@ +// 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 'address.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +// dart format off +T _$identity(T value) => value; + +/// @nodoc +mixin _$Address { + + String? get street; String? get city; String? get state;@JsonKey(name: 'postal_code') String? get postalCode; String? get country;@JsonKey(name: 'address_type') String? get addressType;@JsonKey(name: 'is_default') bool? get isDefault; +/// Create a copy of Address +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$AddressCopyWith
get copyWith => _$AddressCopyWithImpl
(this as Address, _$identity); + + /// Serializes this Address to a JSON map. + Map toJson(); + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is Address&&(identical(other.street, street) || other.street == street)&&(identical(other.city, city) || other.city == city)&&(identical(other.state, state) || other.state == state)&&(identical(other.postalCode, postalCode) || other.postalCode == postalCode)&&(identical(other.country, country) || other.country == country)&&(identical(other.addressType, addressType) || other.addressType == addressType)&&(identical(other.isDefault, isDefault) || other.isDefault == isDefault)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,street,city,state,postalCode,country,addressType,isDefault); + +@override +String toString() { + return 'Address(street: $street, city: $city, state: $state, postalCode: $postalCode, country: $country, addressType: $addressType, isDefault: $isDefault)'; +} + + +} + +/// @nodoc +abstract mixin class $AddressCopyWith<$Res> { + factory $AddressCopyWith(Address value, $Res Function(Address) _then) = _$AddressCopyWithImpl; +@useResult +$Res call({ + String? street, String? city, String? state,@JsonKey(name: 'postal_code') String? postalCode, String? country,@JsonKey(name: 'address_type') String? addressType,@JsonKey(name: 'is_default') bool? isDefault +}); + + + + +} +/// @nodoc +class _$AddressCopyWithImpl<$Res> + implements $AddressCopyWith<$Res> { + _$AddressCopyWithImpl(this._self, this._then); + + final Address _self; + final $Res Function(Address) _then; + +/// Create a copy of Address +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? street = freezed,Object? city = freezed,Object? state = freezed,Object? postalCode = freezed,Object? country = freezed,Object? addressType = freezed,Object? isDefault = freezed,}) { + return _then(_self.copyWith( +street: freezed == street ? _self.street : street // ignore: cast_nullable_to_non_nullable +as String?,city: freezed == city ? _self.city : city // ignore: cast_nullable_to_non_nullable +as String?,state: freezed == state ? _self.state : state // ignore: cast_nullable_to_non_nullable +as String?,postalCode: freezed == postalCode ? _self.postalCode : postalCode // ignore: cast_nullable_to_non_nullable +as String?,country: freezed == country ? _self.country : country // ignore: cast_nullable_to_non_nullable +as String?,addressType: freezed == addressType ? _self.addressType : addressType // ignore: cast_nullable_to_non_nullable +as String?,isDefault: freezed == isDefault ? _self.isDefault : isDefault // ignore: cast_nullable_to_non_nullable +as bool?, + )); +} + +} + + +/// Adds pattern-matching-related methods to [Address]. +extension AddressPatterns on Address { +/// 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 Function( _Address value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _Address() 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 Function( _Address value) $default,){ +final _that = this; +switch (_that) { +case _Address(): +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? Function( _Address value)? $default,){ +final _that = this; +switch (_that) { +case _Address() 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 Function( String? street, String? city, String? state, @JsonKey(name: 'postal_code') String? postalCode, String? country, @JsonKey(name: 'address_type') String? addressType, @JsonKey(name: 'is_default') bool? isDefault)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _Address() when $default != null: +return $default(_that.street,_that.city,_that.state,_that.postalCode,_that.country,_that.addressType,_that.isDefault);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 Function( String? street, String? city, String? state, @JsonKey(name: 'postal_code') String? postalCode, String? country, @JsonKey(name: 'address_type') String? addressType, @JsonKey(name: 'is_default') bool? isDefault) $default,) {final _that = this; +switch (_that) { +case _Address(): +return $default(_that.street,_that.city,_that.state,_that.postalCode,_that.country,_that.addressType,_that.isDefault);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? Function( String? street, String? city, String? state, @JsonKey(name: 'postal_code') String? postalCode, String? country, @JsonKey(name: 'address_type') String? addressType, @JsonKey(name: 'is_default') bool? isDefault)? $default,) {final _that = this; +switch (_that) { +case _Address() when $default != null: +return $default(_that.street,_that.city,_that.state,_that.postalCode,_that.country,_that.addressType,_that.isDefault);case _: + return null; + +} +} + +} + +/// @nodoc +@JsonSerializable() + +class _Address implements Address { + const _Address({required this.street, required this.city, required this.state, @JsonKey(name: 'postal_code') required this.postalCode, required this.country, @JsonKey(name: 'address_type') required this.addressType, @JsonKey(name: 'is_default') required this.isDefault}); + factory _Address.fromJson(Map json) => _$AddressFromJson(json); + +@override final String? street; +@override final String? city; +@override final String? state; +@override@JsonKey(name: 'postal_code') final String? postalCode; +@override final String? country; +@override@JsonKey(name: 'address_type') final String? addressType; +@override@JsonKey(name: 'is_default') final bool? isDefault; + +/// Create a copy of Address +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$AddressCopyWith<_Address> get copyWith => __$AddressCopyWithImpl<_Address>(this, _$identity); + +@override +Map toJson() { + return _$AddressToJson(this, ); +} + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _Address&&(identical(other.street, street) || other.street == street)&&(identical(other.city, city) || other.city == city)&&(identical(other.state, state) || other.state == state)&&(identical(other.postalCode, postalCode) || other.postalCode == postalCode)&&(identical(other.country, country) || other.country == country)&&(identical(other.addressType, addressType) || other.addressType == addressType)&&(identical(other.isDefault, isDefault) || other.isDefault == isDefault)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,street,city,state,postalCode,country,addressType,isDefault); + +@override +String toString() { + return 'Address(street: $street, city: $city, state: $state, postalCode: $postalCode, country: $country, addressType: $addressType, isDefault: $isDefault)'; +} + + +} + +/// @nodoc +abstract mixin class _$AddressCopyWith<$Res> implements $AddressCopyWith<$Res> { + factory _$AddressCopyWith(_Address value, $Res Function(_Address) _then) = __$AddressCopyWithImpl; +@override @useResult +$Res call({ + String? street, String? city, String? state,@JsonKey(name: 'postal_code') String? postalCode, String? country,@JsonKey(name: 'address_type') String? addressType,@JsonKey(name: 'is_default') bool? isDefault +}); + + + + +} +/// @nodoc +class __$AddressCopyWithImpl<$Res> + implements _$AddressCopyWith<$Res> { + __$AddressCopyWithImpl(this._self, this._then); + + final _Address _self; + final $Res Function(_Address) _then; + +/// Create a copy of Address +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? street = freezed,Object? city = freezed,Object? state = freezed,Object? postalCode = freezed,Object? country = freezed,Object? addressType = freezed,Object? isDefault = freezed,}) { + return _then(_Address( +street: freezed == street ? _self.street : street // ignore: cast_nullable_to_non_nullable +as String?,city: freezed == city ? _self.city : city // ignore: cast_nullable_to_non_nullable +as String?,state: freezed == state ? _self.state : state // ignore: cast_nullable_to_non_nullable +as String?,postalCode: freezed == postalCode ? _self.postalCode : postalCode // ignore: cast_nullable_to_non_nullable +as String?,country: freezed == country ? _self.country : country // ignore: cast_nullable_to_non_nullable +as String?,addressType: freezed == addressType ? _self.addressType : addressType // ignore: cast_nullable_to_non_nullable +as String?,isDefault: freezed == isDefault ? _self.isDefault : isDefault // ignore: cast_nullable_to_non_nullable +as bool?, + )); +} + + +} + +// dart format on diff --git a/lib/data/services/model/address/address.g.dart b/lib/data/services/model/address/address.g.dart new file mode 100644 index 0000000..87302d5 --- /dev/null +++ b/lib/data/services/model/address/address.g.dart @@ -0,0 +1,27 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'address.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_Address _$AddressFromJson(Map json) => _Address( + street: json['street'] as String?, + city: json['city'] as String?, + state: json['state'] as String?, + postalCode: json['postal_code'] as String?, + country: json['country'] as String?, + addressType: json['address_type'] as String?, + isDefault: json['is_default'] as bool?, +); + +Map _$AddressToJson(_Address instance) => { + 'street': instance.street, + 'city': instance.city, + 'state': instance.state, + 'postal_code': instance.postalCode, + 'country': instance.country, + 'address_type': instance.addressType, + 'is_default': instance.isDefault, +}; diff --git a/lib/data/services/model/contact_person/contact_person.dart b/lib/data/services/model/contact_person/contact_person.dart new file mode 100644 index 0000000..954e4cd --- /dev/null +++ b/lib/data/services/model/contact_person/contact_person.dart @@ -0,0 +1,23 @@ +// ignore_for_file: invalid_annotation_target + +import 'package:freezed_annotation/freezed_annotation.dart'; + +part 'contact_person.freezed.dart'; +part 'contact_person.g.dart'; + +@freezed +abstract class ContactPerson with _$ContactPerson { + const factory ContactPerson({ + @JsonKey(name: 'first_name') required String? firstName, + @JsonKey(name: 'last_name') required String? lastName, + @JsonKey(name: 'full_name') required String? fullName, + required String? position, + required String? email, + required String? phone, + required String? mobile, + @JsonKey(name: 'is_primary') required bool? isPrimary, + }) = _ContactPerson; + + factory ContactPerson.fromJson(Map json) => + _$ContactPersonFromJson(json); +} diff --git a/lib/data/services/model/contact_person/contact_person.freezed.dart b/lib/data/services/model/contact_person/contact_person.freezed.dart new file mode 100644 index 0000000..5b7dd2f --- /dev/null +++ b/lib/data/services/model/contact_person/contact_person.freezed.dart @@ -0,0 +1,298 @@ +// 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 'contact_person.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +// dart format off +T _$identity(T value) => value; + +/// @nodoc +mixin _$ContactPerson { + +@JsonKey(name: 'first_name') String? get firstName;@JsonKey(name: 'last_name') String? get lastName;@JsonKey(name: 'full_name') String? get fullName; String? get position; String? get email; String? get phone; String? get mobile;@JsonKey(name: 'is_primary') bool? get isPrimary; +/// Create a copy of ContactPerson +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$ContactPersonCopyWith get copyWith => _$ContactPersonCopyWithImpl(this as ContactPerson, _$identity); + + /// Serializes this ContactPerson to a JSON map. + Map toJson(); + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is ContactPerson&&(identical(other.firstName, firstName) || other.firstName == firstName)&&(identical(other.lastName, lastName) || other.lastName == lastName)&&(identical(other.fullName, fullName) || other.fullName == fullName)&&(identical(other.position, position) || other.position == position)&&(identical(other.email, email) || other.email == email)&&(identical(other.phone, phone) || other.phone == phone)&&(identical(other.mobile, mobile) || other.mobile == mobile)&&(identical(other.isPrimary, isPrimary) || other.isPrimary == isPrimary)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,firstName,lastName,fullName,position,email,phone,mobile,isPrimary); + +@override +String toString() { + return 'ContactPerson(firstName: $firstName, lastName: $lastName, fullName: $fullName, position: $position, email: $email, phone: $phone, mobile: $mobile, isPrimary: $isPrimary)'; +} + + +} + +/// @nodoc +abstract mixin class $ContactPersonCopyWith<$Res> { + factory $ContactPersonCopyWith(ContactPerson value, $Res Function(ContactPerson) _then) = _$ContactPersonCopyWithImpl; +@useResult +$Res call({ +@JsonKey(name: 'first_name') String? firstName,@JsonKey(name: 'last_name') String? lastName,@JsonKey(name: 'full_name') String? fullName, String? position, String? email, String? phone, String? mobile,@JsonKey(name: 'is_primary') bool? isPrimary +}); + + + + +} +/// @nodoc +class _$ContactPersonCopyWithImpl<$Res> + implements $ContactPersonCopyWith<$Res> { + _$ContactPersonCopyWithImpl(this._self, this._then); + + final ContactPerson _self; + final $Res Function(ContactPerson) _then; + +/// Create a copy of ContactPerson +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? firstName = freezed,Object? lastName = freezed,Object? fullName = freezed,Object? position = freezed,Object? email = freezed,Object? phone = freezed,Object? mobile = freezed,Object? isPrimary = freezed,}) { + return _then(_self.copyWith( +firstName: freezed == firstName ? _self.firstName : firstName // ignore: cast_nullable_to_non_nullable +as String?,lastName: freezed == lastName ? _self.lastName : lastName // ignore: cast_nullable_to_non_nullable +as String?,fullName: freezed == fullName ? _self.fullName : fullName // ignore: cast_nullable_to_non_nullable +as String?,position: freezed == position ? _self.position : position // ignore: cast_nullable_to_non_nullable +as String?,email: freezed == email ? _self.email : email // ignore: cast_nullable_to_non_nullable +as String?,phone: freezed == phone ? _self.phone : phone // ignore: cast_nullable_to_non_nullable +as String?,mobile: freezed == mobile ? _self.mobile : mobile // ignore: cast_nullable_to_non_nullable +as String?,isPrimary: freezed == isPrimary ? _self.isPrimary : isPrimary // ignore: cast_nullable_to_non_nullable +as bool?, + )); +} + +} + + +/// Adds pattern-matching-related methods to [ContactPerson]. +extension ContactPersonPatterns on ContactPerson { +/// 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 Function( _ContactPerson value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _ContactPerson() 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 Function( _ContactPerson value) $default,){ +final _that = this; +switch (_that) { +case _ContactPerson(): +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? Function( _ContactPerson value)? $default,){ +final _that = this; +switch (_that) { +case _ContactPerson() 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 Function(@JsonKey(name: 'first_name') String? firstName, @JsonKey(name: 'last_name') String? lastName, @JsonKey(name: 'full_name') String? fullName, String? position, String? email, String? phone, String? mobile, @JsonKey(name: 'is_primary') bool? isPrimary)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _ContactPerson() when $default != null: +return $default(_that.firstName,_that.lastName,_that.fullName,_that.position,_that.email,_that.phone,_that.mobile,_that.isPrimary);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 Function(@JsonKey(name: 'first_name') String? firstName, @JsonKey(name: 'last_name') String? lastName, @JsonKey(name: 'full_name') String? fullName, String? position, String? email, String? phone, String? mobile, @JsonKey(name: 'is_primary') bool? isPrimary) $default,) {final _that = this; +switch (_that) { +case _ContactPerson(): +return $default(_that.firstName,_that.lastName,_that.fullName,_that.position,_that.email,_that.phone,_that.mobile,_that.isPrimary);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? Function(@JsonKey(name: 'first_name') String? firstName, @JsonKey(name: 'last_name') String? lastName, @JsonKey(name: 'full_name') String? fullName, String? position, String? email, String? phone, String? mobile, @JsonKey(name: 'is_primary') bool? isPrimary)? $default,) {final _that = this; +switch (_that) { +case _ContactPerson() when $default != null: +return $default(_that.firstName,_that.lastName,_that.fullName,_that.position,_that.email,_that.phone,_that.mobile,_that.isPrimary);case _: + return null; + +} +} + +} + +/// @nodoc +@JsonSerializable() + +class _ContactPerson implements ContactPerson { + const _ContactPerson({@JsonKey(name: 'first_name') required this.firstName, @JsonKey(name: 'last_name') required this.lastName, @JsonKey(name: 'full_name') required this.fullName, required this.position, required this.email, required this.phone, required this.mobile, @JsonKey(name: 'is_primary') required this.isPrimary}); + factory _ContactPerson.fromJson(Map json) => _$ContactPersonFromJson(json); + +@override@JsonKey(name: 'first_name') final String? firstName; +@override@JsonKey(name: 'last_name') final String? lastName; +@override@JsonKey(name: 'full_name') final String? fullName; +@override final String? position; +@override final String? email; +@override final String? phone; +@override final String? mobile; +@override@JsonKey(name: 'is_primary') final bool? isPrimary; + +/// Create a copy of ContactPerson +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$ContactPersonCopyWith<_ContactPerson> get copyWith => __$ContactPersonCopyWithImpl<_ContactPerson>(this, _$identity); + +@override +Map toJson() { + return _$ContactPersonToJson(this, ); +} + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _ContactPerson&&(identical(other.firstName, firstName) || other.firstName == firstName)&&(identical(other.lastName, lastName) || other.lastName == lastName)&&(identical(other.fullName, fullName) || other.fullName == fullName)&&(identical(other.position, position) || other.position == position)&&(identical(other.email, email) || other.email == email)&&(identical(other.phone, phone) || other.phone == phone)&&(identical(other.mobile, mobile) || other.mobile == mobile)&&(identical(other.isPrimary, isPrimary) || other.isPrimary == isPrimary)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,firstName,lastName,fullName,position,email,phone,mobile,isPrimary); + +@override +String toString() { + return 'ContactPerson(firstName: $firstName, lastName: $lastName, fullName: $fullName, position: $position, email: $email, phone: $phone, mobile: $mobile, isPrimary: $isPrimary)'; +} + + +} + +/// @nodoc +abstract mixin class _$ContactPersonCopyWith<$Res> implements $ContactPersonCopyWith<$Res> { + factory _$ContactPersonCopyWith(_ContactPerson value, $Res Function(_ContactPerson) _then) = __$ContactPersonCopyWithImpl; +@override @useResult +$Res call({ +@JsonKey(name: 'first_name') String? firstName,@JsonKey(name: 'last_name') String? lastName,@JsonKey(name: 'full_name') String? fullName, String? position, String? email, String? phone, String? mobile,@JsonKey(name: 'is_primary') bool? isPrimary +}); + + + + +} +/// @nodoc +class __$ContactPersonCopyWithImpl<$Res> + implements _$ContactPersonCopyWith<$Res> { + __$ContactPersonCopyWithImpl(this._self, this._then); + + final _ContactPerson _self; + final $Res Function(_ContactPerson) _then; + +/// Create a copy of ContactPerson +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? firstName = freezed,Object? lastName = freezed,Object? fullName = freezed,Object? position = freezed,Object? email = freezed,Object? phone = freezed,Object? mobile = freezed,Object? isPrimary = freezed,}) { + return _then(_ContactPerson( +firstName: freezed == firstName ? _self.firstName : firstName // ignore: cast_nullable_to_non_nullable +as String?,lastName: freezed == lastName ? _self.lastName : lastName // ignore: cast_nullable_to_non_nullable +as String?,fullName: freezed == fullName ? _self.fullName : fullName // ignore: cast_nullable_to_non_nullable +as String?,position: freezed == position ? _self.position : position // ignore: cast_nullable_to_non_nullable +as String?,email: freezed == email ? _self.email : email // ignore: cast_nullable_to_non_nullable +as String?,phone: freezed == phone ? _self.phone : phone // ignore: cast_nullable_to_non_nullable +as String?,mobile: freezed == mobile ? _self.mobile : mobile // ignore: cast_nullable_to_non_nullable +as String?,isPrimary: freezed == isPrimary ? _self.isPrimary : isPrimary // ignore: cast_nullable_to_non_nullable +as bool?, + )); +} + + +} + +// dart format on diff --git a/lib/data/services/model/contact_person/contact_person.g.dart b/lib/data/services/model/contact_person/contact_person.g.dart new file mode 100644 index 0000000..2954e96 --- /dev/null +++ b/lib/data/services/model/contact_person/contact_person.g.dart @@ -0,0 +1,31 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'contact_person.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_ContactPerson _$ContactPersonFromJson(Map json) => + _ContactPerson( + firstName: json['first_name'] as String?, + lastName: json['last_name'] as String?, + fullName: json['full_name'] as String?, + position: json['position'] as String?, + email: json['email'] as String?, + phone: json['phone'] as String?, + mobile: json['mobile'] as String?, + isPrimary: json['is_primary'] as bool?, + ); + +Map _$ContactPersonToJson(_ContactPerson instance) => + { + 'first_name': instance.firstName, + 'last_name': instance.lastName, + 'full_name': instance.fullName, + 'position': instance.position, + 'email': instance.email, + 'phone': instance.phone, + 'mobile': instance.mobile, + 'is_primary': instance.isPrimary, + }; diff --git a/lib/data/services/model/customer/customer.dart b/lib/data/services/model/customer/customer.dart new file mode 100644 index 0000000..ca2a7b9 --- /dev/null +++ b/lib/data/services/model/customer/customer.dart @@ -0,0 +1,47 @@ +// ignore_for_file: invalid_annotation_target + +import 'package:freezed_annotation/freezed_annotation.dart'; + +import '../address/address.dart'; +import '../contact_person/contact_person.dart'; + +part 'customer.freezed.dart'; +part 'customer.g.dart'; + +@freezed +abstract class Customer with _$Customer { + const factory Customer({ + required String? id, + required String? type, + required String? status, + @JsonKey(name: 'first_name') required String? firstName, + @JsonKey(name: 'last_name') required String? lastName, + @JsonKey(name: 'full_name') required String? fullName, + required String? email, + required String? phone, + required String? mobile, + @JsonKey(name: 'registration_number') required String? registrationNumber, + @JsonKey(name: 'tax_id') required String? taxId, + required String? industry, + @JsonKey(name: 'business_type') required String? businessType, + @JsonKey(name: 'employee_count') required int? employeeCount, + @JsonKey(name: 'annual_revenue') required int? annualRevenue, + @JsonKey(name: 'founded_year') required int? foundedYear, + @JsonKey(name: 'is_verified') required bool? isVerified, + @JsonKey(name: 'is_compliant') required bool? isCompliant, + @JsonKey(name: 'compliance_notes') required String? complianceNotes, + required String? language, + required String? username, + required String? currency, + required String? timezone, + @JsonKey(name: 'created_at') required int? createdAt, + @JsonKey(name: 'updated_at') required int? updatedAt, + @JsonKey(name: 'created_by') required String? createdBy, + @JsonKey(name: 'updated_by') required String? updatedBy, + required Address? address, + required ContactPerson? contactPersons, + }) = _Customer; + + factory Customer.fromJson(Map json) => + _$CustomerFromJson(json); +} diff --git a/lib/data/services/model/customer/customer.freezed.dart b/lib/data/services/model/customer/customer.freezed.dart new file mode 100644 index 0000000..5aecef4 --- /dev/null +++ b/lib/data/services/model/customer/customer.freezed.dart @@ -0,0 +1,409 @@ +// 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 'customer.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +// dart format off +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; +/// Create a copy of Customer +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$CustomerCopyWith get copyWith => _$CustomerCopyWithImpl(this as Customer, _$identity); + + /// Serializes this Customer to a JSON map. + 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)); +} + +@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]); + +@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)'; +} + + +} + +/// @nodoc +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 +}); + + +$AddressCopyWith<$Res>? get address;$ContactPersonCopyWith<$Res>? get contactPersons; + +} +/// @nodoc +class _$CustomerCopyWithImpl<$Res> + implements $CustomerCopyWith<$Res> { + _$CustomerCopyWithImpl(this._self, this._then); + + final Customer _self; + final $Res Function(Customer) _then; + +/// 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,}) { + 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 +as String?,status: freezed == status ? _self.status : status // ignore: cast_nullable_to_non_nullable +as String?,firstName: freezed == firstName ? _self.firstName : firstName // ignore: cast_nullable_to_non_nullable +as String?,lastName: freezed == lastName ? _self.lastName : lastName // ignore: cast_nullable_to_non_nullable +as String?,fullName: freezed == fullName ? _self.fullName : fullName // ignore: cast_nullable_to_non_nullable +as String?,email: freezed == email ? _self.email : email // ignore: cast_nullable_to_non_nullable +as String?,phone: freezed == phone ? _self.phone : phone // ignore: cast_nullable_to_non_nullable +as String?,mobile: freezed == mobile ? _self.mobile : mobile // ignore: cast_nullable_to_non_nullable +as String?,registrationNumber: freezed == registrationNumber ? _self.registrationNumber : registrationNumber // ignore: cast_nullable_to_non_nullable +as String?,taxId: freezed == taxId ? _self.taxId : taxId // ignore: cast_nullable_to_non_nullable +as String?,industry: freezed == industry ? _self.industry : industry // ignore: cast_nullable_to_non_nullable +as String?,businessType: freezed == businessType ? _self.businessType : businessType // ignore: cast_nullable_to_non_nullable +as String?,employeeCount: freezed == employeeCount ? _self.employeeCount : employeeCount // ignore: cast_nullable_to_non_nullable +as int?,annualRevenue: freezed == annualRevenue ? _self.annualRevenue : annualRevenue // ignore: cast_nullable_to_non_nullable +as int?,foundedYear: freezed == foundedYear ? _self.foundedYear : foundedYear // ignore: cast_nullable_to_non_nullable +as int?,isVerified: freezed == isVerified ? _self.isVerified : isVerified // ignore: cast_nullable_to_non_nullable +as bool?,isCompliant: freezed == isCompliant ? _self.isCompliant : isCompliant // ignore: cast_nullable_to_non_nullable +as bool?,complianceNotes: freezed == complianceNotes ? _self.complianceNotes : complianceNotes // 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?,currency: freezed == currency ? _self.currency : currency // 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 +as int?,createdBy: freezed == createdBy ? _self.createdBy : createdBy // ignore: cast_nullable_to_non_nullable +as String?,updatedBy: freezed == updatedBy ? _self.updatedBy : updatedBy // ignore: cast_nullable_to_non_nullable +as String?,address: freezed == address ? _self.address : address // ignore: cast_nullable_to_non_nullable +as Address?,contactPersons: freezed == contactPersons ? _self.contactPersons : contactPersons // ignore: cast_nullable_to_non_nullable +as ContactPerson?, + )); +} +/// Create a copy of Customer +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$AddressCopyWith<$Res>? get address { + if (_self.address == null) { + return null; + } + + return $AddressCopyWith<$Res>(_self.address!, (value) { + return _then(_self.copyWith(address: value)); + }); +}/// Create a copy of Customer +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$ContactPersonCopyWith<$Res>? get contactPersons { + if (_self.contactPersons == null) { + return null; + } + + return $ContactPersonCopyWith<$Res>(_self.contactPersons!, (value) { + return _then(_self.copyWith(contactPersons: value)); + }); +} +} + + +/// Adds pattern-matching-related methods to [Customer]. +extension CustomerPatterns on Customer { +/// 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 Function( _Customer value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _Customer() 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 Function( _Customer value) $default,){ +final _that = this; +switch (_that) { +case _Customer(): +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? Function( _Customer value)? $default,){ +final _that = this; +switch (_that) { +case _Customer() 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 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; +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 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 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; +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 _: + 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? 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; +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 null; + +} +} + +} + +/// @nodoc +@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}); + factory _Customer.fromJson(Map json) => _$CustomerFromJson(json); + +@override final String? id; +@override final String? type; +@override final String? status; +@override@JsonKey(name: 'first_name') final String? firstName; +@override@JsonKey(name: 'last_name') final String? lastName; +@override@JsonKey(name: 'full_name') final String? fullName; +@override final String? email; +@override final String? phone; +@override final String? mobile; +@override@JsonKey(name: 'registration_number') final String? registrationNumber; +@override@JsonKey(name: 'tax_id') final String? taxId; +@override final String? industry; +@override@JsonKey(name: 'business_type') final String? businessType; +@override@JsonKey(name: 'employee_count') final int? employeeCount; +@override@JsonKey(name: 'annual_revenue') final int? annualRevenue; +@override@JsonKey(name: 'founded_year') final int? foundedYear; +@override@JsonKey(name: 'is_verified') final bool? isVerified; +@override@JsonKey(name: 'is_compliant') final bool? isCompliant; +@override@JsonKey(name: 'compliance_notes') final String? complianceNotes; +@override final String? language; +@override final String? username; +@override final String? currency; +@override final String? timezone; +@override@JsonKey(name: 'created_at') final int? createdAt; +@override@JsonKey(name: 'updated_at') final int? updatedAt; +@override@JsonKey(name: 'created_by') final String? createdBy; +@override@JsonKey(name: 'updated_by') final String? updatedBy; +@override final Address? address; +@override final ContactPerson? contactPersons; + +/// Create a copy of Customer +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$CustomerCopyWith<_Customer> get copyWith => __$CustomerCopyWithImpl<_Customer>(this, _$identity); + +@override +Map toJson() { + return _$CustomerToJson(this, ); +} + +@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)); +} + +@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]); + +@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)'; +} + + +} + +/// @nodoc +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 +}); + + +@override $AddressCopyWith<$Res>? get address;@override $ContactPersonCopyWith<$Res>? get contactPersons; + +} +/// @nodoc +class __$CustomerCopyWithImpl<$Res> + implements _$CustomerCopyWith<$Res> { + __$CustomerCopyWithImpl(this._self, this._then); + + final _Customer _self; + final $Res Function(_Customer) _then; + +/// 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,}) { + 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 +as String?,status: freezed == status ? _self.status : status // ignore: cast_nullable_to_non_nullable +as String?,firstName: freezed == firstName ? _self.firstName : firstName // ignore: cast_nullable_to_non_nullable +as String?,lastName: freezed == lastName ? _self.lastName : lastName // ignore: cast_nullable_to_non_nullable +as String?,fullName: freezed == fullName ? _self.fullName : fullName // ignore: cast_nullable_to_non_nullable +as String?,email: freezed == email ? _self.email : email // ignore: cast_nullable_to_non_nullable +as String?,phone: freezed == phone ? _self.phone : phone // ignore: cast_nullable_to_non_nullable +as String?,mobile: freezed == mobile ? _self.mobile : mobile // ignore: cast_nullable_to_non_nullable +as String?,registrationNumber: freezed == registrationNumber ? _self.registrationNumber : registrationNumber // ignore: cast_nullable_to_non_nullable +as String?,taxId: freezed == taxId ? _self.taxId : taxId // ignore: cast_nullable_to_non_nullable +as String?,industry: freezed == industry ? _self.industry : industry // ignore: cast_nullable_to_non_nullable +as String?,businessType: freezed == businessType ? _self.businessType : businessType // ignore: cast_nullable_to_non_nullable +as String?,employeeCount: freezed == employeeCount ? _self.employeeCount : employeeCount // ignore: cast_nullable_to_non_nullable +as int?,annualRevenue: freezed == annualRevenue ? _self.annualRevenue : annualRevenue // ignore: cast_nullable_to_non_nullable +as int?,foundedYear: freezed == foundedYear ? _self.foundedYear : foundedYear // ignore: cast_nullable_to_non_nullable +as int?,isVerified: freezed == isVerified ? _self.isVerified : isVerified // ignore: cast_nullable_to_non_nullable +as bool?,isCompliant: freezed == isCompliant ? _self.isCompliant : isCompliant // ignore: cast_nullable_to_non_nullable +as bool?,complianceNotes: freezed == complianceNotes ? _self.complianceNotes : complianceNotes // 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?,currency: freezed == currency ? _self.currency : currency // 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 +as int?,createdBy: freezed == createdBy ? _self.createdBy : createdBy // ignore: cast_nullable_to_non_nullable +as String?,updatedBy: freezed == updatedBy ? _self.updatedBy : updatedBy // ignore: cast_nullable_to_non_nullable +as String?,address: freezed == address ? _self.address : address // ignore: cast_nullable_to_non_nullable +as Address?,contactPersons: freezed == contactPersons ? _self.contactPersons : contactPersons // ignore: cast_nullable_to_non_nullable +as ContactPerson?, + )); +} + +/// Create a copy of Customer +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$AddressCopyWith<$Res>? get address { + if (_self.address == null) { + return null; + } + + return $AddressCopyWith<$Res>(_self.address!, (value) { + return _then(_self.copyWith(address: value)); + }); +}/// Create a copy of Customer +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$ContactPersonCopyWith<$Res>? get contactPersons { + if (_self.contactPersons == null) { + return null; + } + + return $ContactPersonCopyWith<$Res>(_self.contactPersons!, (value) { + return _then(_self.copyWith(contactPersons: value)); + }); +} +} + +// dart format on diff --git a/lib/data/services/model/customer/customer.g.dart b/lib/data/services/model/customer/customer.g.dart new file mode 100644 index 0000000..5cd2348 --- /dev/null +++ b/lib/data/services/model/customer/customer.g.dart @@ -0,0 +1,79 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'customer.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_Customer _$CustomerFromJson(Map json) => _Customer( + id: json['id'] as String?, + type: json['type'] as String?, + status: json['status'] as String?, + firstName: json['first_name'] as String?, + lastName: json['last_name'] as String?, + fullName: json['full_name'] as String?, + email: json['email'] as String?, + phone: json['phone'] as String?, + mobile: json['mobile'] as String?, + registrationNumber: json['registration_number'] as String?, + taxId: json['tax_id'] as String?, + industry: json['industry'] as String?, + businessType: json['business_type'] as String?, + employeeCount: (json['employee_count'] as num?)?.toInt(), + annualRevenue: (json['annual_revenue'] as num?)?.toInt(), + foundedYear: (json['founded_year'] as num?)?.toInt(), + isVerified: json['is_verified'] as bool?, + isCompliant: json['is_compliant'] as bool?, + complianceNotes: json['compliance_notes'] as String?, + language: json['language'] as String?, + username: json['username'] as String?, + currency: json['currency'] as String?, + timezone: json['timezone'] as String?, + createdAt: (json['created_at'] as num?)?.toInt(), + updatedAt: (json['updated_at'] as num?)?.toInt(), + createdBy: json['created_by'] as String?, + updatedBy: json['updated_by'] as String?, + address: + json['address'] == null + ? null + : Address.fromJson(json['address'] as Map), + contactPersons: + json['contactPersons'] == null + ? null + : ContactPerson.fromJson( + json['contactPersons'] as Map, + ), +); + +Map _$CustomerToJson(_Customer instance) => { + 'id': instance.id, + 'type': instance.type, + 'status': instance.status, + 'first_name': instance.firstName, + 'last_name': instance.lastName, + 'full_name': instance.fullName, + 'email': instance.email, + 'phone': instance.phone, + 'mobile': instance.mobile, + 'registration_number': instance.registrationNumber, + 'tax_id': instance.taxId, + 'industry': instance.industry, + 'business_type': instance.businessType, + 'employee_count': instance.employeeCount, + 'annual_revenue': instance.annualRevenue, + 'founded_year': instance.foundedYear, + 'is_verified': instance.isVerified, + 'is_compliant': instance.isCompliant, + 'compliance_notes': instance.complianceNotes, + 'language': instance.language, + 'username': instance.username, + 'currency': instance.currency, + 'timezone': instance.timezone, + 'created_at': instance.createdAt, + 'updated_at': instance.updatedAt, + 'created_by': instance.createdBy, + 'updated_by': instance.updatedBy, + 'address': instance.address, + 'contactPersons': instance.contactPersons, +}; diff --git a/lib/data/services/model/login_data/login_data.dart b/lib/data/services/model/login_data/login_data.dart index 9e02f96..4599a54 100644 --- a/lib/data/services/model/login_data/login_data.dart +++ b/lib/data/services/model/login_data/login_data.dart @@ -1,7 +1,9 @@ // ignore_for_file: invalid_annotation_target import 'package:freezed_annotation/freezed_annotation.dart'; -import 'package:tm_app/data/services/model/user/user.dart'; +import 'package:tm_app/data/services/model/customer/customer.dart'; + +import '../error/error_model.dart'; part 'login_data.freezed.dart'; part 'login_data.g.dart'; @@ -9,10 +11,11 @@ part 'login_data.g.dart'; @freezed abstract class LoginData with _$LoginData { const factory LoginData({ - required User user, - @JsonKey(name: 'access_token') required String accessToken, - @JsonKey(name: 'refresh_token') required String refreshToken, - @JsonKey(name: 'expires_at') required int expiresAt, + required Customer? customer, + required ErrorModel? error, + @JsonKey(name: 'access_token') required String? accessToken, + @JsonKey(name: 'refresh_token') required String? refreshToken, + @JsonKey(name: 'expires_at') required int? expiresAt, }) = _LoginData; factory LoginData.fromJson(Map json) => diff --git a/lib/data/services/model/login_data/login_data.freezed.dart b/lib/data/services/model/login_data/login_data.freezed.dart index f5e6234..5ed643e 100644 --- a/lib/data/services/model/login_data/login_data.freezed.dart +++ b/lib/data/services/model/login_data/login_data.freezed.dart @@ -15,7 +15,7 @@ T _$identity(T value) => value; /// @nodoc mixin _$LoginData { - User get user;@JsonKey(name: 'access_token') String get accessToken;@JsonKey(name: 'refresh_token') String get refreshToken;@JsonKey(name: 'expires_at') int get expiresAt; + Customer? get customer; ErrorModel? get error;@JsonKey(name: 'access_token') String? get accessToken;@JsonKey(name: 'refresh_token') String? get refreshToken;@JsonKey(name: 'expires_at') int? get expiresAt; /// Create a copy of LoginData /// with the given fields replaced by the non-null parameter values. @JsonKey(includeFromJson: false, includeToJson: false) @@ -28,16 +28,16 @@ $LoginDataCopyWith get copyWith => _$LoginDataCopyWithImpl @override bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is LoginData&&(identical(other.user, user) || other.user == user)&&(identical(other.accessToken, accessToken) || other.accessToken == accessToken)&&(identical(other.refreshToken, refreshToken) || other.refreshToken == refreshToken)&&(identical(other.expiresAt, expiresAt) || other.expiresAt == expiresAt)); + return identical(this, other) || (other.runtimeType == runtimeType&&other is LoginData&&(identical(other.customer, customer) || other.customer == customer)&&(identical(other.error, error) || other.error == error)&&(identical(other.accessToken, accessToken) || other.accessToken == accessToken)&&(identical(other.refreshToken, refreshToken) || other.refreshToken == refreshToken)&&(identical(other.expiresAt, expiresAt) || other.expiresAt == expiresAt)); } @JsonKey(includeFromJson: false, includeToJson: false) @override -int get hashCode => Object.hash(runtimeType,user,accessToken,refreshToken,expiresAt); +int get hashCode => Object.hash(runtimeType,customer,error,accessToken,refreshToken,expiresAt); @override String toString() { - return 'LoginData(user: $user, accessToken: $accessToken, refreshToken: $refreshToken, expiresAt: $expiresAt)'; + return 'LoginData(customer: $customer, error: $error, accessToken: $accessToken, refreshToken: $refreshToken, expiresAt: $expiresAt)'; } @@ -48,11 +48,11 @@ abstract mixin class $LoginDataCopyWith<$Res> { factory $LoginDataCopyWith(LoginData value, $Res Function(LoginData) _then) = _$LoginDataCopyWithImpl; @useResult $Res call({ - User user,@JsonKey(name: 'access_token') String accessToken,@JsonKey(name: 'refresh_token') String refreshToken,@JsonKey(name: 'expires_at') int expiresAt + Customer? customer, ErrorModel? error,@JsonKey(name: 'access_token') String? accessToken,@JsonKey(name: 'refresh_token') String? refreshToken,@JsonKey(name: 'expires_at') int? expiresAt }); -$UserCopyWith<$Res> get user; +$CustomerCopyWith<$Res>? get customer;$ErrorModelCopyWith<$Res>? get error; } /// @nodoc @@ -65,23 +65,39 @@ class _$LoginDataCopyWithImpl<$Res> /// Create a copy of LoginData /// with the given fields replaced by the non-null parameter values. -@pragma('vm:prefer-inline') @override $Res call({Object? user = null,Object? accessToken = null,Object? refreshToken = null,Object? expiresAt = null,}) { +@pragma('vm:prefer-inline') @override $Res call({Object? customer = freezed,Object? error = freezed,Object? accessToken = freezed,Object? refreshToken = freezed,Object? expiresAt = freezed,}) { return _then(_self.copyWith( -user: null == user ? _self.user : user // ignore: cast_nullable_to_non_nullable -as User,accessToken: null == accessToken ? _self.accessToken : accessToken // ignore: cast_nullable_to_non_nullable -as String,refreshToken: null == refreshToken ? _self.refreshToken : refreshToken // ignore: cast_nullable_to_non_nullable -as String,expiresAt: null == expiresAt ? _self.expiresAt : expiresAt // ignore: cast_nullable_to_non_nullable -as int, +customer: freezed == customer ? _self.customer : customer // ignore: cast_nullable_to_non_nullable +as Customer?,error: freezed == error ? _self.error : error // ignore: cast_nullable_to_non_nullable +as ErrorModel?,accessToken: freezed == accessToken ? _self.accessToken : accessToken // ignore: cast_nullable_to_non_nullable +as String?,refreshToken: freezed == refreshToken ? _self.refreshToken : refreshToken // ignore: cast_nullable_to_non_nullable +as String?,expiresAt: freezed == expiresAt ? _self.expiresAt : expiresAt // ignore: cast_nullable_to_non_nullable +as int?, )); } /// Create a copy of LoginData /// with the given fields replaced by the non-null parameter values. @override @pragma('vm:prefer-inline') -$UserCopyWith<$Res> get user { - - return $UserCopyWith<$Res>(_self.user, (value) { - return _then(_self.copyWith(user: value)); +$CustomerCopyWith<$Res>? get customer { + if (_self.customer == null) { + return null; + } + + return $CustomerCopyWith<$Res>(_self.customer!, (value) { + return _then(_self.copyWith(customer: value)); + }); +}/// Create a copy of LoginData +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$ErrorModelCopyWith<$Res>? get error { + if (_self.error == null) { + return null; + } + + return $ErrorModelCopyWith<$Res>(_self.error!, (value) { + return _then(_self.copyWith(error: value)); }); } } @@ -165,10 +181,10 @@ return $default(_that);case _: /// } /// ``` -@optionalTypeArgs TResult maybeWhen(TResult Function( User user, @JsonKey(name: 'access_token') String accessToken, @JsonKey(name: 'refresh_token') String refreshToken, @JsonKey(name: 'expires_at') int expiresAt)? $default,{required TResult orElse(),}) {final _that = this; +@optionalTypeArgs TResult maybeWhen(TResult Function( Customer? customer, ErrorModel? error, @JsonKey(name: 'access_token') String? accessToken, @JsonKey(name: 'refresh_token') String? refreshToken, @JsonKey(name: 'expires_at') int? expiresAt)? $default,{required TResult orElse(),}) {final _that = this; switch (_that) { case _LoginData() when $default != null: -return $default(_that.user,_that.accessToken,_that.refreshToken,_that.expiresAt);case _: +return $default(_that.customer,_that.error,_that.accessToken,_that.refreshToken,_that.expiresAt);case _: return orElse(); } @@ -186,10 +202,10 @@ return $default(_that.user,_that.accessToken,_that.refreshToken,_that.expiresAt) /// } /// ``` -@optionalTypeArgs TResult when(TResult Function( User user, @JsonKey(name: 'access_token') String accessToken, @JsonKey(name: 'refresh_token') String refreshToken, @JsonKey(name: 'expires_at') int expiresAt) $default,) {final _that = this; +@optionalTypeArgs TResult when(TResult Function( Customer? customer, ErrorModel? error, @JsonKey(name: 'access_token') String? accessToken, @JsonKey(name: 'refresh_token') String? refreshToken, @JsonKey(name: 'expires_at') int? expiresAt) $default,) {final _that = this; switch (_that) { case _LoginData(): -return $default(_that.user,_that.accessToken,_that.refreshToken,_that.expiresAt);case _: +return $default(_that.customer,_that.error,_that.accessToken,_that.refreshToken,_that.expiresAt);case _: throw StateError('Unexpected subclass'); } @@ -206,10 +222,10 @@ return $default(_that.user,_that.accessToken,_that.refreshToken,_that.expiresAt) /// } /// ``` -@optionalTypeArgs TResult? whenOrNull(TResult? Function( User user, @JsonKey(name: 'access_token') String accessToken, @JsonKey(name: 'refresh_token') String refreshToken, @JsonKey(name: 'expires_at') int expiresAt)? $default,) {final _that = this; +@optionalTypeArgs TResult? whenOrNull(TResult? Function( Customer? customer, ErrorModel? error, @JsonKey(name: 'access_token') String? accessToken, @JsonKey(name: 'refresh_token') String? refreshToken, @JsonKey(name: 'expires_at') int? expiresAt)? $default,) {final _that = this; switch (_that) { case _LoginData() when $default != null: -return $default(_that.user,_that.accessToken,_that.refreshToken,_that.expiresAt);case _: +return $default(_that.customer,_that.error,_that.accessToken,_that.refreshToken,_that.expiresAt);case _: return null; } @@ -221,13 +237,14 @@ return $default(_that.user,_that.accessToken,_that.refreshToken,_that.expiresAt) @JsonSerializable() class _LoginData implements LoginData { - const _LoginData({required this.user, @JsonKey(name: 'access_token') required this.accessToken, @JsonKey(name: 'refresh_token') required this.refreshToken, @JsonKey(name: 'expires_at') required this.expiresAt}); + const _LoginData({required this.customer, required this.error, @JsonKey(name: 'access_token') required this.accessToken, @JsonKey(name: 'refresh_token') required this.refreshToken, @JsonKey(name: 'expires_at') required this.expiresAt}); factory _LoginData.fromJson(Map json) => _$LoginDataFromJson(json); -@override final User user; -@override@JsonKey(name: 'access_token') final String accessToken; -@override@JsonKey(name: 'refresh_token') final String refreshToken; -@override@JsonKey(name: 'expires_at') final int expiresAt; +@override final Customer? customer; +@override final ErrorModel? error; +@override@JsonKey(name: 'access_token') final String? accessToken; +@override@JsonKey(name: 'refresh_token') final String? refreshToken; +@override@JsonKey(name: 'expires_at') final int? expiresAt; /// Create a copy of LoginData /// with the given fields replaced by the non-null parameter values. @@ -242,16 +259,16 @@ Map toJson() { @override bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is _LoginData&&(identical(other.user, user) || other.user == user)&&(identical(other.accessToken, accessToken) || other.accessToken == accessToken)&&(identical(other.refreshToken, refreshToken) || other.refreshToken == refreshToken)&&(identical(other.expiresAt, expiresAt) || other.expiresAt == expiresAt)); + return identical(this, other) || (other.runtimeType == runtimeType&&other is _LoginData&&(identical(other.customer, customer) || other.customer == customer)&&(identical(other.error, error) || other.error == error)&&(identical(other.accessToken, accessToken) || other.accessToken == accessToken)&&(identical(other.refreshToken, refreshToken) || other.refreshToken == refreshToken)&&(identical(other.expiresAt, expiresAt) || other.expiresAt == expiresAt)); } @JsonKey(includeFromJson: false, includeToJson: false) @override -int get hashCode => Object.hash(runtimeType,user,accessToken,refreshToken,expiresAt); +int get hashCode => Object.hash(runtimeType,customer,error,accessToken,refreshToken,expiresAt); @override String toString() { - return 'LoginData(user: $user, accessToken: $accessToken, refreshToken: $refreshToken, expiresAt: $expiresAt)'; + return 'LoginData(customer: $customer, error: $error, accessToken: $accessToken, refreshToken: $refreshToken, expiresAt: $expiresAt)'; } @@ -262,11 +279,11 @@ abstract mixin class _$LoginDataCopyWith<$Res> implements $LoginDataCopyWith<$Re factory _$LoginDataCopyWith(_LoginData value, $Res Function(_LoginData) _then) = __$LoginDataCopyWithImpl; @override @useResult $Res call({ - User user,@JsonKey(name: 'access_token') String accessToken,@JsonKey(name: 'refresh_token') String refreshToken,@JsonKey(name: 'expires_at') int expiresAt + Customer? customer, ErrorModel? error,@JsonKey(name: 'access_token') String? accessToken,@JsonKey(name: 'refresh_token') String? refreshToken,@JsonKey(name: 'expires_at') int? expiresAt }); -@override $UserCopyWith<$Res> get user; +@override $CustomerCopyWith<$Res>? get customer;@override $ErrorModelCopyWith<$Res>? get error; } /// @nodoc @@ -279,13 +296,14 @@ class __$LoginDataCopyWithImpl<$Res> /// Create a copy of LoginData /// with the given fields replaced by the non-null parameter values. -@override @pragma('vm:prefer-inline') $Res call({Object? user = null,Object? accessToken = null,Object? refreshToken = null,Object? expiresAt = null,}) { +@override @pragma('vm:prefer-inline') $Res call({Object? customer = freezed,Object? error = freezed,Object? accessToken = freezed,Object? refreshToken = freezed,Object? expiresAt = freezed,}) { return _then(_LoginData( -user: null == user ? _self.user : user // ignore: cast_nullable_to_non_nullable -as User,accessToken: null == accessToken ? _self.accessToken : accessToken // ignore: cast_nullable_to_non_nullable -as String,refreshToken: null == refreshToken ? _self.refreshToken : refreshToken // ignore: cast_nullable_to_non_nullable -as String,expiresAt: null == expiresAt ? _self.expiresAt : expiresAt // ignore: cast_nullable_to_non_nullable -as int, +customer: freezed == customer ? _self.customer : customer // ignore: cast_nullable_to_non_nullable +as Customer?,error: freezed == error ? _self.error : error // ignore: cast_nullable_to_non_nullable +as ErrorModel?,accessToken: freezed == accessToken ? _self.accessToken : accessToken // ignore: cast_nullable_to_non_nullable +as String?,refreshToken: freezed == refreshToken ? _self.refreshToken : refreshToken // ignore: cast_nullable_to_non_nullable +as String?,expiresAt: freezed == expiresAt ? _self.expiresAt : expiresAt // ignore: cast_nullable_to_non_nullable +as int?, )); } @@ -293,10 +311,25 @@ as int, /// with the given fields replaced by the non-null parameter values. @override @pragma('vm:prefer-inline') -$UserCopyWith<$Res> get user { - - return $UserCopyWith<$Res>(_self.user, (value) { - return _then(_self.copyWith(user: value)); +$CustomerCopyWith<$Res>? get customer { + if (_self.customer == null) { + return null; + } + + return $CustomerCopyWith<$Res>(_self.customer!, (value) { + return _then(_self.copyWith(customer: value)); + }); +}/// Create a copy of LoginData +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$ErrorModelCopyWith<$Res>? get error { + if (_self.error == null) { + return null; + } + + return $ErrorModelCopyWith<$Res>(_self.error!, (value) { + return _then(_self.copyWith(error: value)); }); } } diff --git a/lib/data/services/model/login_data/login_data.g.dart b/lib/data/services/model/login_data/login_data.g.dart index 7fea684..6cd1699 100644 --- a/lib/data/services/model/login_data/login_data.g.dart +++ b/lib/data/services/model/login_data/login_data.g.dart @@ -7,15 +7,23 @@ part of 'login_data.dart'; // ************************************************************************** _LoginData _$LoginDataFromJson(Map json) => _LoginData( - user: User.fromJson(json['user'] as Map), - accessToken: json['access_token'] as String, - refreshToken: json['refresh_token'] as String, - expiresAt: (json['expires_at'] as num).toInt(), + customer: + json['customer'] == null + ? null + : Customer.fromJson(json['customer'] as Map), + error: + json['error'] == null + ? null + : ErrorModel.fromJson(json['error'] as Map), + accessToken: json['access_token'] as String?, + refreshToken: json['refresh_token'] as String?, + expiresAt: (json['expires_at'] as num?)?.toInt(), ); Map _$LoginDataToJson(_LoginData instance) => { - 'user': instance.user, + 'customer': instance.customer, + 'error': instance.error, 'access_token': instance.accessToken, 'refresh_token': instance.refreshToken, 'expires_at': instance.expiresAt, diff --git a/lib/data/services/model/tender_detail_response/tender_detail_response_model.dart b/lib/data/services/model/tender_detail_response/tender_detail_response_model.dart index 6ddf525..c8b91fb 100644 --- a/lib/data/services/model/tender_detail_response/tender_detail_response_model.dart +++ b/lib/data/services/model/tender_detail_response/tender_detail_response_model.dart @@ -1,6 +1,8 @@ // ignore_for_file: invalid_annotation_target import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:tm_app/data/services/model/error/error_model.dart'; +import 'package:tm_app/data/services/model/tender_data/tender_data.dart'; part 'tender_detail_response_model.freezed.dart'; part 'tender_detail_response_model.g.dart'; @@ -9,24 +11,10 @@ part 'tender_detail_response_model.g.dart'; abstract class TenderDetailResponseModel with _$TenderDetailResponseModel { @JsonSerializable(explicitToJson: true) const factory TenderDetailResponseModel({ - required String? date, - required String? status, - required String? title, - required String? id, - required String? approvalDate, - required String? submissionDate, - required String? client, - required String? deliveryLocation, - required String? referenceNumber, - required String? country, - required String? flagAsset, - required String? locationTitle, - required String? locationDescription, - required String? documentName, - required String? documentUrl, - required double? profileMatch, - required bool? incompleteResume, - required String? incompleteResumeReason, + required TenderData? data, + required ErrorModel? error, + required bool? success, + required String? message, }) = _TenderDetailResponseModel; factory TenderDetailResponseModel.fromJson(Map json) => diff --git a/lib/data/services/model/tender_detail_response/tender_detail_response_model.freezed.dart b/lib/data/services/model/tender_detail_response/tender_detail_response_model.freezed.dart index 419a6c6..28dab2b 100644 --- a/lib/data/services/model/tender_detail_response/tender_detail_response_model.freezed.dart +++ b/lib/data/services/model/tender_detail_response/tender_detail_response_model.freezed.dart @@ -15,7 +15,7 @@ T _$identity(T value) => value; /// @nodoc mixin _$TenderDetailResponseModel { - String? get date; String? get status; String? get title; String? get id; String? get approvalDate; String? get submissionDate; String? get client; String? get deliveryLocation; String? get referenceNumber; String? get country; String? get flagAsset; String? get locationTitle; String? get locationDescription; String? get documentName; String? get documentUrl; double? get profileMatch; bool? get incompleteResume; String? get incompleteResumeReason; + TenderData? get data; ErrorModel? get error; bool? get success; String? get message; /// Create a copy of TenderDetailResponseModel /// with the given fields replaced by the non-null parameter values. @JsonKey(includeFromJson: false, includeToJson: false) @@ -28,16 +28,16 @@ $TenderDetailResponseModelCopyWith get copyWith => _$ @override bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is TenderDetailResponseModel&&(identical(other.date, date) || other.date == date)&&(identical(other.status, status) || other.status == status)&&(identical(other.title, title) || other.title == title)&&(identical(other.id, id) || other.id == id)&&(identical(other.approvalDate, approvalDate) || other.approvalDate == approvalDate)&&(identical(other.submissionDate, submissionDate) || other.submissionDate == submissionDate)&&(identical(other.client, client) || other.client == client)&&(identical(other.deliveryLocation, deliveryLocation) || other.deliveryLocation == deliveryLocation)&&(identical(other.referenceNumber, referenceNumber) || other.referenceNumber == referenceNumber)&&(identical(other.country, country) || other.country == country)&&(identical(other.flagAsset, flagAsset) || other.flagAsset == flagAsset)&&(identical(other.locationTitle, locationTitle) || other.locationTitle == locationTitle)&&(identical(other.locationDescription, locationDescription) || other.locationDescription == locationDescription)&&(identical(other.documentName, documentName) || other.documentName == documentName)&&(identical(other.documentUrl, documentUrl) || other.documentUrl == documentUrl)&&(identical(other.profileMatch, profileMatch) || other.profileMatch == profileMatch)&&(identical(other.incompleteResume, incompleteResume) || other.incompleteResume == incompleteResume)&&(identical(other.incompleteResumeReason, incompleteResumeReason) || other.incompleteResumeReason == incompleteResumeReason)); + return identical(this, other) || (other.runtimeType == runtimeType&&other is TenderDetailResponseModel&&(identical(other.data, data) || other.data == data)&&(identical(other.error, error) || other.error == error)&&(identical(other.success, success) || other.success == success)&&(identical(other.message, message) || other.message == message)); } @JsonKey(includeFromJson: false, includeToJson: false) @override -int get hashCode => Object.hash(runtimeType,date,status,title,id,approvalDate,submissionDate,client,deliveryLocation,referenceNumber,country,flagAsset,locationTitle,locationDescription,documentName,documentUrl,profileMatch,incompleteResume,incompleteResumeReason); +int get hashCode => Object.hash(runtimeType,data,error,success,message); @override String toString() { - return 'TenderDetailResponseModel(date: $date, status: $status, title: $title, id: $id, approvalDate: $approvalDate, submissionDate: $submissionDate, client: $client, deliveryLocation: $deliveryLocation, referenceNumber: $referenceNumber, country: $country, flagAsset: $flagAsset, locationTitle: $locationTitle, locationDescription: $locationDescription, documentName: $documentName, documentUrl: $documentUrl, profileMatch: $profileMatch, incompleteResume: $incompleteResume, incompleteResumeReason: $incompleteResumeReason)'; + return 'TenderDetailResponseModel(data: $data, error: $error, success: $success, message: $message)'; } @@ -48,11 +48,11 @@ abstract mixin class $TenderDetailResponseModelCopyWith<$Res> { factory $TenderDetailResponseModelCopyWith(TenderDetailResponseModel value, $Res Function(TenderDetailResponseModel) _then) = _$TenderDetailResponseModelCopyWithImpl; @useResult $Res call({ - String? date, String? status, String? title, String? id, String? approvalDate, String? submissionDate, String? client, String? deliveryLocation, String? referenceNumber, String? country, String? flagAsset, String? locationTitle, String? locationDescription, String? documentName, String? documentUrl, double? profileMatch, bool? incompleteResume, String? incompleteResumeReason + TenderData? data, ErrorModel? error, bool? success, String? message }); - +$TenderDataCopyWith<$Res>? get data;$ErrorModelCopyWith<$Res>? get error; } /// @nodoc @@ -65,30 +65,40 @@ class _$TenderDetailResponseModelCopyWithImpl<$Res> /// Create a copy of TenderDetailResponseModel /// with the given fields replaced by the non-null parameter values. -@pragma('vm:prefer-inline') @override $Res call({Object? date = freezed,Object? status = freezed,Object? title = freezed,Object? id = freezed,Object? approvalDate = freezed,Object? submissionDate = freezed,Object? client = freezed,Object? deliveryLocation = freezed,Object? referenceNumber = freezed,Object? country = freezed,Object? flagAsset = freezed,Object? locationTitle = freezed,Object? locationDescription = freezed,Object? documentName = freezed,Object? documentUrl = freezed,Object? profileMatch = freezed,Object? incompleteResume = freezed,Object? incompleteResumeReason = freezed,}) { +@pragma('vm:prefer-inline') @override $Res call({Object? data = freezed,Object? error = freezed,Object? success = freezed,Object? message = freezed,}) { return _then(_self.copyWith( -date: freezed == date ? _self.date : date // ignore: cast_nullable_to_non_nullable -as String?,status: freezed == status ? _self.status : status // ignore: cast_nullable_to_non_nullable -as String?,title: freezed == title ? _self.title : title // ignore: cast_nullable_to_non_nullable -as String?,id: freezed == id ? _self.id : id // ignore: cast_nullable_to_non_nullable -as String?,approvalDate: freezed == approvalDate ? _self.approvalDate : approvalDate // ignore: cast_nullable_to_non_nullable -as String?,submissionDate: freezed == submissionDate ? _self.submissionDate : submissionDate // ignore: cast_nullable_to_non_nullable -as String?,client: freezed == client ? _self.client : client // ignore: cast_nullable_to_non_nullable -as String?,deliveryLocation: freezed == deliveryLocation ? _self.deliveryLocation : deliveryLocation // ignore: cast_nullable_to_non_nullable -as String?,referenceNumber: freezed == referenceNumber ? _self.referenceNumber : referenceNumber // ignore: cast_nullable_to_non_nullable -as String?,country: freezed == country ? _self.country : country // ignore: cast_nullable_to_non_nullable -as String?,flagAsset: freezed == flagAsset ? _self.flagAsset : flagAsset // ignore: cast_nullable_to_non_nullable -as String?,locationTitle: freezed == locationTitle ? _self.locationTitle : locationTitle // ignore: cast_nullable_to_non_nullable -as String?,locationDescription: freezed == locationDescription ? _self.locationDescription : locationDescription // ignore: cast_nullable_to_non_nullable -as String?,documentName: freezed == documentName ? _self.documentName : documentName // ignore: cast_nullable_to_non_nullable -as String?,documentUrl: freezed == documentUrl ? _self.documentUrl : documentUrl // ignore: cast_nullable_to_non_nullable -as String?,profileMatch: freezed == profileMatch ? _self.profileMatch : profileMatch // ignore: cast_nullable_to_non_nullable -as double?,incompleteResume: freezed == incompleteResume ? _self.incompleteResume : incompleteResume // ignore: cast_nullable_to_non_nullable -as bool?,incompleteResumeReason: freezed == incompleteResumeReason ? _self.incompleteResumeReason : incompleteResumeReason // ignore: cast_nullable_to_non_nullable +data: freezed == data ? _self.data : data // ignore: cast_nullable_to_non_nullable +as TenderData?,error: freezed == error ? _self.error : error // ignore: cast_nullable_to_non_nullable +as ErrorModel?,success: freezed == success ? _self.success : success // ignore: cast_nullable_to_non_nullable +as bool?,message: freezed == message ? _self.message : message // ignore: cast_nullable_to_non_nullable as String?, )); } +/// Create a copy of TenderDetailResponseModel +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$TenderDataCopyWith<$Res>? get data { + if (_self.data == null) { + return null; + } + return $TenderDataCopyWith<$Res>(_self.data!, (value) { + return _then(_self.copyWith(data: value)); + }); +}/// Create a copy of TenderDetailResponseModel +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$ErrorModelCopyWith<$Res>? get error { + if (_self.error == null) { + return null; + } + + return $ErrorModelCopyWith<$Res>(_self.error!, (value) { + return _then(_self.copyWith(error: value)); + }); +} } @@ -170,10 +180,10 @@ return $default(_that);case _: /// } /// ``` -@optionalTypeArgs TResult maybeWhen(TResult Function( String? date, String? status, String? title, String? id, String? approvalDate, String? submissionDate, String? client, String? deliveryLocation, String? referenceNumber, String? country, String? flagAsset, String? locationTitle, String? locationDescription, String? documentName, String? documentUrl, double? profileMatch, bool? incompleteResume, String? incompleteResumeReason)? $default,{required TResult orElse(),}) {final _that = this; +@optionalTypeArgs TResult maybeWhen(TResult Function( TenderData? data, ErrorModel? error, bool? success, String? message)? $default,{required TResult orElse(),}) {final _that = this; switch (_that) { case _TenderDetailResponseModel() when $default != null: -return $default(_that.date,_that.status,_that.title,_that.id,_that.approvalDate,_that.submissionDate,_that.client,_that.deliveryLocation,_that.referenceNumber,_that.country,_that.flagAsset,_that.locationTitle,_that.locationDescription,_that.documentName,_that.documentUrl,_that.profileMatch,_that.incompleteResume,_that.incompleteResumeReason);case _: +return $default(_that.data,_that.error,_that.success,_that.message);case _: return orElse(); } @@ -191,10 +201,10 @@ return $default(_that.date,_that.status,_that.title,_that.id,_that.approvalDate, /// } /// ``` -@optionalTypeArgs TResult when(TResult Function( String? date, String? status, String? title, String? id, String? approvalDate, String? submissionDate, String? client, String? deliveryLocation, String? referenceNumber, String? country, String? flagAsset, String? locationTitle, String? locationDescription, String? documentName, String? documentUrl, double? profileMatch, bool? incompleteResume, String? incompleteResumeReason) $default,) {final _that = this; +@optionalTypeArgs TResult when(TResult Function( TenderData? data, ErrorModel? error, bool? success, String? message) $default,) {final _that = this; switch (_that) { case _TenderDetailResponseModel(): -return $default(_that.date,_that.status,_that.title,_that.id,_that.approvalDate,_that.submissionDate,_that.client,_that.deliveryLocation,_that.referenceNumber,_that.country,_that.flagAsset,_that.locationTitle,_that.locationDescription,_that.documentName,_that.documentUrl,_that.profileMatch,_that.incompleteResume,_that.incompleteResumeReason);case _: +return $default(_that.data,_that.error,_that.success,_that.message);case _: throw StateError('Unexpected subclass'); } @@ -211,10 +221,10 @@ return $default(_that.date,_that.status,_that.title,_that.id,_that.approvalDate, /// } /// ``` -@optionalTypeArgs TResult? whenOrNull(TResult? Function( String? date, String? status, String? title, String? id, String? approvalDate, String? submissionDate, String? client, String? deliveryLocation, String? referenceNumber, String? country, String? flagAsset, String? locationTitle, String? locationDescription, String? documentName, String? documentUrl, double? profileMatch, bool? incompleteResume, String? incompleteResumeReason)? $default,) {final _that = this; +@optionalTypeArgs TResult? whenOrNull(TResult? Function( TenderData? data, ErrorModel? error, bool? success, String? message)? $default,) {final _that = this; switch (_that) { case _TenderDetailResponseModel() when $default != null: -return $default(_that.date,_that.status,_that.title,_that.id,_that.approvalDate,_that.submissionDate,_that.client,_that.deliveryLocation,_that.referenceNumber,_that.country,_that.flagAsset,_that.locationTitle,_that.locationDescription,_that.documentName,_that.documentUrl,_that.profileMatch,_that.incompleteResume,_that.incompleteResumeReason);case _: +return $default(_that.data,_that.error,_that.success,_that.message);case _: return null; } @@ -226,27 +236,13 @@ return $default(_that.date,_that.status,_that.title,_that.id,_that.approvalDate, @JsonSerializable(explicitToJson: true) class _TenderDetailResponseModel implements TenderDetailResponseModel { - const _TenderDetailResponseModel({required this.date, required this.status, required this.title, required this.id, required this.approvalDate, required this.submissionDate, required this.client, required this.deliveryLocation, required this.referenceNumber, required this.country, required this.flagAsset, required this.locationTitle, required this.locationDescription, required this.documentName, required this.documentUrl, required this.profileMatch, required this.incompleteResume, required this.incompleteResumeReason}); + const _TenderDetailResponseModel({required this.data, required this.error, required this.success, required this.message}); factory _TenderDetailResponseModel.fromJson(Map json) => _$TenderDetailResponseModelFromJson(json); -@override final String? date; -@override final String? status; -@override final String? title; -@override final String? id; -@override final String? approvalDate; -@override final String? submissionDate; -@override final String? client; -@override final String? deliveryLocation; -@override final String? referenceNumber; -@override final String? country; -@override final String? flagAsset; -@override final String? locationTitle; -@override final String? locationDescription; -@override final String? documentName; -@override final String? documentUrl; -@override final double? profileMatch; -@override final bool? incompleteResume; -@override final String? incompleteResumeReason; +@override final TenderData? data; +@override final ErrorModel? error; +@override final bool? success; +@override final String? message; /// Create a copy of TenderDetailResponseModel /// with the given fields replaced by the non-null parameter values. @@ -261,16 +257,16 @@ Map toJson() { @override bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is _TenderDetailResponseModel&&(identical(other.date, date) || other.date == date)&&(identical(other.status, status) || other.status == status)&&(identical(other.title, title) || other.title == title)&&(identical(other.id, id) || other.id == id)&&(identical(other.approvalDate, approvalDate) || other.approvalDate == approvalDate)&&(identical(other.submissionDate, submissionDate) || other.submissionDate == submissionDate)&&(identical(other.client, client) || other.client == client)&&(identical(other.deliveryLocation, deliveryLocation) || other.deliveryLocation == deliveryLocation)&&(identical(other.referenceNumber, referenceNumber) || other.referenceNumber == referenceNumber)&&(identical(other.country, country) || other.country == country)&&(identical(other.flagAsset, flagAsset) || other.flagAsset == flagAsset)&&(identical(other.locationTitle, locationTitle) || other.locationTitle == locationTitle)&&(identical(other.locationDescription, locationDescription) || other.locationDescription == locationDescription)&&(identical(other.documentName, documentName) || other.documentName == documentName)&&(identical(other.documentUrl, documentUrl) || other.documentUrl == documentUrl)&&(identical(other.profileMatch, profileMatch) || other.profileMatch == profileMatch)&&(identical(other.incompleteResume, incompleteResume) || other.incompleteResume == incompleteResume)&&(identical(other.incompleteResumeReason, incompleteResumeReason) || other.incompleteResumeReason == incompleteResumeReason)); + return identical(this, other) || (other.runtimeType == runtimeType&&other is _TenderDetailResponseModel&&(identical(other.data, data) || other.data == data)&&(identical(other.error, error) || other.error == error)&&(identical(other.success, success) || other.success == success)&&(identical(other.message, message) || other.message == message)); } @JsonKey(includeFromJson: false, includeToJson: false) @override -int get hashCode => Object.hash(runtimeType,date,status,title,id,approvalDate,submissionDate,client,deliveryLocation,referenceNumber,country,flagAsset,locationTitle,locationDescription,documentName,documentUrl,profileMatch,incompleteResume,incompleteResumeReason); +int get hashCode => Object.hash(runtimeType,data,error,success,message); @override String toString() { - return 'TenderDetailResponseModel(date: $date, status: $status, title: $title, id: $id, approvalDate: $approvalDate, submissionDate: $submissionDate, client: $client, deliveryLocation: $deliveryLocation, referenceNumber: $referenceNumber, country: $country, flagAsset: $flagAsset, locationTitle: $locationTitle, locationDescription: $locationDescription, documentName: $documentName, documentUrl: $documentUrl, profileMatch: $profileMatch, incompleteResume: $incompleteResume, incompleteResumeReason: $incompleteResumeReason)'; + return 'TenderDetailResponseModel(data: $data, error: $error, success: $success, message: $message)'; } @@ -281,11 +277,11 @@ abstract mixin class _$TenderDetailResponseModelCopyWith<$Res> implements $Tende factory _$TenderDetailResponseModelCopyWith(_TenderDetailResponseModel value, $Res Function(_TenderDetailResponseModel) _then) = __$TenderDetailResponseModelCopyWithImpl; @override @useResult $Res call({ - String? date, String? status, String? title, String? id, String? approvalDate, String? submissionDate, String? client, String? deliveryLocation, String? referenceNumber, String? country, String? flagAsset, String? locationTitle, String? locationDescription, String? documentName, String? documentUrl, double? profileMatch, bool? incompleteResume, String? incompleteResumeReason + TenderData? data, ErrorModel? error, bool? success, String? message }); - +@override $TenderDataCopyWith<$Res>? get data;@override $ErrorModelCopyWith<$Res>? get error; } /// @nodoc @@ -298,31 +294,41 @@ class __$TenderDetailResponseModelCopyWithImpl<$Res> /// Create a copy of TenderDetailResponseModel /// with the given fields replaced by the non-null parameter values. -@override @pragma('vm:prefer-inline') $Res call({Object? date = freezed,Object? status = freezed,Object? title = freezed,Object? id = freezed,Object? approvalDate = freezed,Object? submissionDate = freezed,Object? client = freezed,Object? deliveryLocation = freezed,Object? referenceNumber = freezed,Object? country = freezed,Object? flagAsset = freezed,Object? locationTitle = freezed,Object? locationDescription = freezed,Object? documentName = freezed,Object? documentUrl = freezed,Object? profileMatch = freezed,Object? incompleteResume = freezed,Object? incompleteResumeReason = freezed,}) { +@override @pragma('vm:prefer-inline') $Res call({Object? data = freezed,Object? error = freezed,Object? success = freezed,Object? message = freezed,}) { return _then(_TenderDetailResponseModel( -date: freezed == date ? _self.date : date // ignore: cast_nullable_to_non_nullable -as String?,status: freezed == status ? _self.status : status // ignore: cast_nullable_to_non_nullable -as String?,title: freezed == title ? _self.title : title // ignore: cast_nullable_to_non_nullable -as String?,id: freezed == id ? _self.id : id // ignore: cast_nullable_to_non_nullable -as String?,approvalDate: freezed == approvalDate ? _self.approvalDate : approvalDate // ignore: cast_nullable_to_non_nullable -as String?,submissionDate: freezed == submissionDate ? _self.submissionDate : submissionDate // ignore: cast_nullable_to_non_nullable -as String?,client: freezed == client ? _self.client : client // ignore: cast_nullable_to_non_nullable -as String?,deliveryLocation: freezed == deliveryLocation ? _self.deliveryLocation : deliveryLocation // ignore: cast_nullable_to_non_nullable -as String?,referenceNumber: freezed == referenceNumber ? _self.referenceNumber : referenceNumber // ignore: cast_nullable_to_non_nullable -as String?,country: freezed == country ? _self.country : country // ignore: cast_nullable_to_non_nullable -as String?,flagAsset: freezed == flagAsset ? _self.flagAsset : flagAsset // ignore: cast_nullable_to_non_nullable -as String?,locationTitle: freezed == locationTitle ? _self.locationTitle : locationTitle // ignore: cast_nullable_to_non_nullable -as String?,locationDescription: freezed == locationDescription ? _self.locationDescription : locationDescription // ignore: cast_nullable_to_non_nullable -as String?,documentName: freezed == documentName ? _self.documentName : documentName // ignore: cast_nullable_to_non_nullable -as String?,documentUrl: freezed == documentUrl ? _self.documentUrl : documentUrl // ignore: cast_nullable_to_non_nullable -as String?,profileMatch: freezed == profileMatch ? _self.profileMatch : profileMatch // ignore: cast_nullable_to_non_nullable -as double?,incompleteResume: freezed == incompleteResume ? _self.incompleteResume : incompleteResume // ignore: cast_nullable_to_non_nullable -as bool?,incompleteResumeReason: freezed == incompleteResumeReason ? _self.incompleteResumeReason : incompleteResumeReason // ignore: cast_nullable_to_non_nullable +data: freezed == data ? _self.data : data // ignore: cast_nullable_to_non_nullable +as TenderData?,error: freezed == error ? _self.error : error // ignore: cast_nullable_to_non_nullable +as ErrorModel?,success: freezed == success ? _self.success : success // ignore: cast_nullable_to_non_nullable +as bool?,message: freezed == message ? _self.message : message // ignore: cast_nullable_to_non_nullable as String?, )); } +/// Create a copy of TenderDetailResponseModel +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$TenderDataCopyWith<$Res>? get data { + if (_self.data == null) { + return null; + } + return $TenderDataCopyWith<$Res>(_self.data!, (value) { + return _then(_self.copyWith(data: value)); + }); +}/// Create a copy of TenderDetailResponseModel +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$ErrorModelCopyWith<$Res>? get error { + if (_self.error == null) { + return null; + } + + return $ErrorModelCopyWith<$Res>(_self.error!, (value) { + return _then(_self.copyWith(error: value)); + }); +} } // dart format on diff --git a/lib/data/services/model/tender_detail_response/tender_detail_response_model.g.dart b/lib/data/services/model/tender_detail_response/tender_detail_response_model.g.dart index c864a64..6cb8d86 100644 --- a/lib/data/services/model/tender_detail_response/tender_detail_response_model.g.dart +++ b/lib/data/services/model/tender_detail_response/tender_detail_response_model.g.dart @@ -9,45 +9,23 @@ part of 'tender_detail_response_model.dart'; _TenderDetailResponseModel _$TenderDetailResponseModelFromJson( Map json, ) => _TenderDetailResponseModel( - date: json['date'] as String?, - status: json['status'] as String?, - title: json['title'] as String?, - id: json['id'] as String?, - approvalDate: json['approvalDate'] as String?, - submissionDate: json['submissionDate'] as String?, - client: json['client'] as String?, - deliveryLocation: json['deliveryLocation'] as String?, - referenceNumber: json['referenceNumber'] as String?, - country: json['country'] as String?, - flagAsset: json['flagAsset'] as String?, - locationTitle: json['locationTitle'] as String?, - locationDescription: json['locationDescription'] as String?, - documentName: json['documentName'] as String?, - documentUrl: json['documentUrl'] as String?, - profileMatch: (json['profileMatch'] as num?)?.toDouble(), - incompleteResume: json['incompleteResume'] as bool?, - incompleteResumeReason: json['incompleteResumeReason'] as String?, + data: + json['data'] == null + ? null + : TenderData.fromJson(json['data'] as Map), + error: + json['error'] == null + ? null + : ErrorModel.fromJson(json['error'] as Map), + success: json['success'] as bool?, + message: json['message'] as String?, ); Map _$TenderDetailResponseModelToJson( _TenderDetailResponseModel instance, ) => { - 'date': instance.date, - 'status': instance.status, - 'title': instance.title, - 'id': instance.id, - 'approvalDate': instance.approvalDate, - 'submissionDate': instance.submissionDate, - 'client': instance.client, - 'deliveryLocation': instance.deliveryLocation, - 'referenceNumber': instance.referenceNumber, - 'country': instance.country, - 'flagAsset': instance.flagAsset, - 'locationTitle': instance.locationTitle, - 'locationDescription': instance.locationDescription, - 'documentName': instance.documentName, - 'documentUrl': instance.documentUrl, - 'profileMatch': instance.profileMatch, - 'incompleteResume': instance.incompleteResume, - 'incompleteResumeReason': instance.incompleteResumeReason, + 'data': instance.data?.toJson(), + 'error': instance.error?.toJson(), + 'success': instance.success, + 'message': instance.message, }; diff --git a/lib/data/services/model/tenders/tenders_data/tenders_data.dart b/lib/data/services/model/tenders/tenders_data/tenders_data.dart new file mode 100644 index 0000000..9e046ea --- /dev/null +++ b/lib/data/services/model/tenders/tenders_data/tenders_data.dart @@ -0,0 +1,20 @@ +// ignore_for_file: invalid_annotation_target + +import 'package:freezed_annotation/freezed_annotation.dart'; + +import '../../meta/meta.dart'; +import '../../tender_data/tender_data.dart'; + +part 'tenders_data.freezed.dart'; +part 'tenders_data.g.dart'; + +@freezed +abstract class TendersData with _$TendersData { + const factory TendersData({ + required List? tenders, + required Meta? metadata, + }) = _TendersData; + + factory TendersData.fromJson(Map json) => + _$TendersDataFromJson(json); +} diff --git a/lib/data/services/model/tenders/tenders_data/tenders_data.freezed.dart b/lib/data/services/model/tenders/tenders_data/tenders_data.freezed.dart new file mode 100644 index 0000000..77d49f3 --- /dev/null +++ b/lib/data/services/model/tenders/tenders_data/tenders_data.freezed.dart @@ -0,0 +1,312 @@ +// 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 'tenders_data.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +// dart format off +T _$identity(T value) => value; + +/// @nodoc +mixin _$TendersData { + + List? get tenders; Meta? get metadata; +/// Create a copy of TendersData +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$TendersDataCopyWith get copyWith => _$TendersDataCopyWithImpl(this as TendersData, _$identity); + + /// Serializes this TendersData to a JSON map. + Map toJson(); + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is TendersData&&const DeepCollectionEquality().equals(other.tenders, tenders)&&(identical(other.metadata, metadata) || other.metadata == metadata)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,const DeepCollectionEquality().hash(tenders),metadata); + +@override +String toString() { + return 'TendersData(tenders: $tenders, metadata: $metadata)'; +} + + +} + +/// @nodoc +abstract mixin class $TendersDataCopyWith<$Res> { + factory $TendersDataCopyWith(TendersData value, $Res Function(TendersData) _then) = _$TendersDataCopyWithImpl; +@useResult +$Res call({ + List? tenders, Meta? metadata +}); + + +$MetaCopyWith<$Res>? get metadata; + +} +/// @nodoc +class _$TendersDataCopyWithImpl<$Res> + implements $TendersDataCopyWith<$Res> { + _$TendersDataCopyWithImpl(this._self, this._then); + + final TendersData _self; + final $Res Function(TendersData) _then; + +/// Create a copy of TendersData +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? tenders = freezed,Object? metadata = freezed,}) { + return _then(_self.copyWith( +tenders: freezed == tenders ? _self.tenders : tenders // ignore: cast_nullable_to_non_nullable +as List?,metadata: freezed == metadata ? _self.metadata : metadata // ignore: cast_nullable_to_non_nullable +as Meta?, + )); +} +/// Create a copy of TendersData +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$MetaCopyWith<$Res>? get metadata { + if (_self.metadata == null) { + return null; + } + + return $MetaCopyWith<$Res>(_self.metadata!, (value) { + return _then(_self.copyWith(metadata: value)); + }); +} +} + + +/// Adds pattern-matching-related methods to [TendersData]. +extension TendersDataPatterns on TendersData { +/// 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 Function( _TendersData value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _TendersData() 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 Function( _TendersData value) $default,){ +final _that = this; +switch (_that) { +case _TendersData(): +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? Function( _TendersData value)? $default,){ +final _that = this; +switch (_that) { +case _TendersData() 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 Function( List? tenders, Meta? metadata)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _TendersData() when $default != null: +return $default(_that.tenders,_that.metadata);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 Function( List? tenders, Meta? metadata) $default,) {final _that = this; +switch (_that) { +case _TendersData(): +return $default(_that.tenders,_that.metadata);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? Function( List? tenders, Meta? metadata)? $default,) {final _that = this; +switch (_that) { +case _TendersData() when $default != null: +return $default(_that.tenders,_that.metadata);case _: + return null; + +} +} + +} + +/// @nodoc +@JsonSerializable() + +class _TendersData implements TendersData { + const _TendersData({required final List? tenders, required this.metadata}): _tenders = tenders; + factory _TendersData.fromJson(Map json) => _$TendersDataFromJson(json); + + final List? _tenders; +@override List? get tenders { + final value = _tenders; + if (value == null) return null; + if (_tenders is EqualUnmodifiableListView) return _tenders; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(value); +} + +@override final Meta? metadata; + +/// Create a copy of TendersData +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$TendersDataCopyWith<_TendersData> get copyWith => __$TendersDataCopyWithImpl<_TendersData>(this, _$identity); + +@override +Map toJson() { + return _$TendersDataToJson(this, ); +} + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _TendersData&&const DeepCollectionEquality().equals(other._tenders, _tenders)&&(identical(other.metadata, metadata) || other.metadata == metadata)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,const DeepCollectionEquality().hash(_tenders),metadata); + +@override +String toString() { + return 'TendersData(tenders: $tenders, metadata: $metadata)'; +} + + +} + +/// @nodoc +abstract mixin class _$TendersDataCopyWith<$Res> implements $TendersDataCopyWith<$Res> { + factory _$TendersDataCopyWith(_TendersData value, $Res Function(_TendersData) _then) = __$TendersDataCopyWithImpl; +@override @useResult +$Res call({ + List? tenders, Meta? metadata +}); + + +@override $MetaCopyWith<$Res>? get metadata; + +} +/// @nodoc +class __$TendersDataCopyWithImpl<$Res> + implements _$TendersDataCopyWith<$Res> { + __$TendersDataCopyWithImpl(this._self, this._then); + + final _TendersData _self; + final $Res Function(_TendersData) _then; + +/// Create a copy of TendersData +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? tenders = freezed,Object? metadata = freezed,}) { + return _then(_TendersData( +tenders: freezed == tenders ? _self._tenders : tenders // ignore: cast_nullable_to_non_nullable +as List?,metadata: freezed == metadata ? _self.metadata : metadata // ignore: cast_nullable_to_non_nullable +as Meta?, + )); +} + +/// Create a copy of TendersData +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$MetaCopyWith<$Res>? get metadata { + if (_self.metadata == null) { + return null; + } + + return $MetaCopyWith<$Res>(_self.metadata!, (value) { + return _then(_self.copyWith(metadata: value)); + }); +} +} + +// dart format on diff --git a/lib/data/services/model/tenders/tenders_data/tenders_data.g.dart b/lib/data/services/model/tenders/tenders_data/tenders_data.g.dart new file mode 100644 index 0000000..736dd48 --- /dev/null +++ b/lib/data/services/model/tenders/tenders_data/tenders_data.g.dart @@ -0,0 +1,24 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'tenders_data.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_TendersData _$TendersDataFromJson(Map json) => _TendersData( + tenders: + (json['tenders'] as List?) + ?.map((e) => TenderData.fromJson(e as Map)) + .toList(), + metadata: + json['metadata'] == null + ? null + : Meta.fromJson(json['metadata'] as Map), +); + +Map _$TendersDataToJson(_TendersData instance) => + { + 'tenders': instance.tenders, + 'metadata': instance.metadata, + }; diff --git a/lib/data/services/model/tenders/tenders_response/tenders_response.dart b/lib/data/services/model/tenders/tenders_response/tenders_response.dart index 4ecc237..cd8a356 100644 --- a/lib/data/services/model/tenders/tenders_response/tenders_response.dart +++ b/lib/data/services/model/tenders/tenders_response/tenders_response.dart @@ -1,15 +1,21 @@ // ignore_for_file: invalid_annotation_target import 'package:freezed_annotation/freezed_annotation.dart'; -import 'package:tm_app/data/services/model/tender/tender_model.dart'; + +import '../../error/error_model.dart'; +import '../tenders_data/tenders_data.dart'; part 'tenders_response.freezed.dart'; part 'tenders_response.g.dart'; @freezed abstract class TendersResponse with _$TendersResponse { - const factory TendersResponse({required List? tenders}) = - _TendersResponse; + const factory TendersResponse({ + required TendersData? data, + required ErrorModel? error, + required String? message, + required bool? success, + }) = _TendersResponse; factory TendersResponse.fromJson(Map json) => _$TendersResponseFromJson(json); diff --git a/lib/data/services/model/tenders/tenders_response/tenders_response.freezed.dart b/lib/data/services/model/tenders/tenders_response/tenders_response.freezed.dart index 0d5c831..0ad9ac4 100644 --- a/lib/data/services/model/tenders/tenders_response/tenders_response.freezed.dart +++ b/lib/data/services/model/tenders/tenders_response/tenders_response.freezed.dart @@ -15,7 +15,7 @@ T _$identity(T value) => value; /// @nodoc mixin _$TendersResponse { - List? get tenders; + TendersData? get data; ErrorModel? get error; String? get message; bool? get success; /// Create a copy of TendersResponse /// with the given fields replaced by the non-null parameter values. @JsonKey(includeFromJson: false, includeToJson: false) @@ -28,16 +28,16 @@ $TendersResponseCopyWith get copyWith => _$TendersResponseCopyW @override bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is TendersResponse&&const DeepCollectionEquality().equals(other.tenders, tenders)); + return identical(this, other) || (other.runtimeType == runtimeType&&other is TendersResponse&&(identical(other.data, data) || other.data == data)&&(identical(other.error, error) || other.error == error)&&(identical(other.message, message) || other.message == message)&&(identical(other.success, success) || other.success == success)); } @JsonKey(includeFromJson: false, includeToJson: false) @override -int get hashCode => Object.hash(runtimeType,const DeepCollectionEquality().hash(tenders)); +int get hashCode => Object.hash(runtimeType,data,error,message,success); @override String toString() { - return 'TendersResponse(tenders: $tenders)'; + return 'TendersResponse(data: $data, error: $error, message: $message, success: $success)'; } @@ -48,11 +48,11 @@ abstract mixin class $TendersResponseCopyWith<$Res> { factory $TendersResponseCopyWith(TendersResponse value, $Res Function(TendersResponse) _then) = _$TendersResponseCopyWithImpl; @useResult $Res call({ - List? tenders + TendersData? data, ErrorModel? error, String? message, bool? success }); - +$TendersDataCopyWith<$Res>? get data;$ErrorModelCopyWith<$Res>? get error; } /// @nodoc @@ -65,13 +65,40 @@ class _$TendersResponseCopyWithImpl<$Res> /// Create a copy of TendersResponse /// with the given fields replaced by the non-null parameter values. -@pragma('vm:prefer-inline') @override $Res call({Object? tenders = freezed,}) { +@pragma('vm:prefer-inline') @override $Res call({Object? data = freezed,Object? error = freezed,Object? message = freezed,Object? success = freezed,}) { return _then(_self.copyWith( -tenders: freezed == tenders ? _self.tenders : tenders // ignore: cast_nullable_to_non_nullable -as List?, +data: freezed == data ? _self.data : data // ignore: cast_nullable_to_non_nullable +as TendersData?,error: freezed == error ? _self.error : error // ignore: cast_nullable_to_non_nullable +as ErrorModel?,message: freezed == message ? _self.message : message // ignore: cast_nullable_to_non_nullable +as String?,success: freezed == success ? _self.success : success // ignore: cast_nullable_to_non_nullable +as bool?, )); } +/// Create a copy of TendersResponse +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$TendersDataCopyWith<$Res>? get data { + if (_self.data == null) { + return null; + } + return $TendersDataCopyWith<$Res>(_self.data!, (value) { + return _then(_self.copyWith(data: value)); + }); +}/// Create a copy of TendersResponse +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$ErrorModelCopyWith<$Res>? get error { + if (_self.error == null) { + return null; + } + + return $ErrorModelCopyWith<$Res>(_self.error!, (value) { + return _then(_self.copyWith(error: value)); + }); +} } @@ -153,10 +180,10 @@ return $default(_that);case _: /// } /// ``` -@optionalTypeArgs TResult maybeWhen(TResult Function( List? tenders)? $default,{required TResult orElse(),}) {final _that = this; +@optionalTypeArgs TResult maybeWhen(TResult Function( TendersData? data, ErrorModel? error, String? message, bool? success)? $default,{required TResult orElse(),}) {final _that = this; switch (_that) { case _TendersResponse() when $default != null: -return $default(_that.tenders);case _: +return $default(_that.data,_that.error,_that.message,_that.success);case _: return orElse(); } @@ -174,10 +201,10 @@ return $default(_that.tenders);case _: /// } /// ``` -@optionalTypeArgs TResult when(TResult Function( List? tenders) $default,) {final _that = this; +@optionalTypeArgs TResult when(TResult Function( TendersData? data, ErrorModel? error, String? message, bool? success) $default,) {final _that = this; switch (_that) { case _TendersResponse(): -return $default(_that.tenders);case _: +return $default(_that.data,_that.error,_that.message,_that.success);case _: throw StateError('Unexpected subclass'); } @@ -194,10 +221,10 @@ return $default(_that.tenders);case _: /// } /// ``` -@optionalTypeArgs TResult? whenOrNull(TResult? Function( List? tenders)? $default,) {final _that = this; +@optionalTypeArgs TResult? whenOrNull(TResult? Function( TendersData? data, ErrorModel? error, String? message, bool? success)? $default,) {final _that = this; switch (_that) { case _TendersResponse() when $default != null: -return $default(_that.tenders);case _: +return $default(_that.data,_that.error,_that.message,_that.success);case _: return null; } @@ -209,18 +236,13 @@ return $default(_that.tenders);case _: @JsonSerializable() class _TendersResponse implements TendersResponse { - const _TendersResponse({required final List? tenders}): _tenders = tenders; + const _TendersResponse({required this.data, required this.error, required this.message, required this.success}); factory _TendersResponse.fromJson(Map json) => _$TendersResponseFromJson(json); - final List? _tenders; -@override List? get tenders { - final value = _tenders; - if (value == null) return null; - if (_tenders is EqualUnmodifiableListView) return _tenders; - // ignore: implicit_dynamic_type - return EqualUnmodifiableListView(value); -} - +@override final TendersData? data; +@override final ErrorModel? error; +@override final String? message; +@override final bool? success; /// Create a copy of TendersResponse /// with the given fields replaced by the non-null parameter values. @@ -235,16 +257,16 @@ Map toJson() { @override bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is _TendersResponse&&const DeepCollectionEquality().equals(other._tenders, _tenders)); + return identical(this, other) || (other.runtimeType == runtimeType&&other is _TendersResponse&&(identical(other.data, data) || other.data == data)&&(identical(other.error, error) || other.error == error)&&(identical(other.message, message) || other.message == message)&&(identical(other.success, success) || other.success == success)); } @JsonKey(includeFromJson: false, includeToJson: false) @override -int get hashCode => Object.hash(runtimeType,const DeepCollectionEquality().hash(_tenders)); +int get hashCode => Object.hash(runtimeType,data,error,message,success); @override String toString() { - return 'TendersResponse(tenders: $tenders)'; + return 'TendersResponse(data: $data, error: $error, message: $message, success: $success)'; } @@ -255,11 +277,11 @@ abstract mixin class _$TendersResponseCopyWith<$Res> implements $TendersResponse factory _$TendersResponseCopyWith(_TendersResponse value, $Res Function(_TendersResponse) _then) = __$TendersResponseCopyWithImpl; @override @useResult $Res call({ - List? tenders + TendersData? data, ErrorModel? error, String? message, bool? success }); - +@override $TendersDataCopyWith<$Res>? get data;@override $ErrorModelCopyWith<$Res>? get error; } /// @nodoc @@ -272,14 +294,41 @@ class __$TendersResponseCopyWithImpl<$Res> /// Create a copy of TendersResponse /// with the given fields replaced by the non-null parameter values. -@override @pragma('vm:prefer-inline') $Res call({Object? tenders = freezed,}) { +@override @pragma('vm:prefer-inline') $Res call({Object? data = freezed,Object? error = freezed,Object? message = freezed,Object? success = freezed,}) { return _then(_TendersResponse( -tenders: freezed == tenders ? _self._tenders : tenders // ignore: cast_nullable_to_non_nullable -as List?, +data: freezed == data ? _self.data : data // ignore: cast_nullable_to_non_nullable +as TendersData?,error: freezed == error ? _self.error : error // ignore: cast_nullable_to_non_nullable +as ErrorModel?,message: freezed == message ? _self.message : message // ignore: cast_nullable_to_non_nullable +as String?,success: freezed == success ? _self.success : success // ignore: cast_nullable_to_non_nullable +as bool?, )); } +/// Create a copy of TendersResponse +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$TendersDataCopyWith<$Res>? get data { + if (_self.data == null) { + return null; + } + return $TendersDataCopyWith<$Res>(_self.data!, (value) { + return _then(_self.copyWith(data: value)); + }); +}/// Create a copy of TendersResponse +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$ErrorModelCopyWith<$Res>? get error { + if (_self.error == null) { + return null; + } + + return $ErrorModelCopyWith<$Res>(_self.error!, (value) { + return _then(_self.copyWith(error: value)); + }); +} } // dart format on diff --git a/lib/data/services/model/tenders/tenders_response/tenders_response.g.dart b/lib/data/services/model/tenders/tenders_response/tenders_response.g.dart index a5e6d5d..c5d3ccd 100644 --- a/lib/data/services/model/tenders/tenders_response/tenders_response.g.dart +++ b/lib/data/services/model/tenders/tenders_response/tenders_response.g.dart @@ -8,11 +8,22 @@ part of 'tenders_response.dart'; _TendersResponse _$TendersResponseFromJson(Map json) => _TendersResponse( - tenders: - (json['tenders'] as List?) - ?.map((e) => TenderModel.fromJson(e as Map)) - .toList(), + data: + json['data'] == null + ? null + : TendersData.fromJson(json['data'] as Map), + error: + json['error'] == null + ? null + : ErrorModel.fromJson(json['error'] as Map), + message: json['message'] as String?, + success: json['success'] as bool?, ); Map _$TendersResponseToJson(_TendersResponse instance) => - {'tenders': instance.tenders}; + { + 'data': instance.data, + 'error': instance.error, + 'message': instance.message, + 'success': instance.success, + }; diff --git a/lib/data/services/tender_detail_service.dart b/lib/data/services/tender_detail_service.dart index a8794fc..4f51543 100644 --- a/lib/data/services/tender_detail_service.dart +++ b/lib/data/services/tender_detail_service.dart @@ -1,9 +1,4 @@ -import 'dart:convert'; - -import 'package:tm_app/core/utils/logger.dart'; import 'package:tm_app/core/utils/result.dart'; -import 'package:tm_app/data/services/mock_data/tender_detail_mock.dart'; -import 'package:tm_app/data/services/model/tender_detail_request/tender_detail_request.dart'; import 'package:tm_app/data/services/model/tender_detail_response/tender_detail_response_model.dart'; import '../../core/network/network_manager.dart'; @@ -14,21 +9,14 @@ class TenderDetailService { final NetworkManager _networkManager; - Future> getTenderDetail({ - required TenderDetailRequest request, + Future> getTenderDetails({ + required String tenderId, }) async { - try { - await Future.delayed(const Duration(seconds: 2)); - appLogger.info('get tender detail success'); - - return Result.ok( - TenderDetailResponseModel.fromJson( - jsonDecode(tenderDetailMockData)['data'], - ), - ); - } catch (e, stackTrace) { - appLogger.error('get tender detail failed: $e', stackTrace: stackTrace); - return Result.error(Exception(e)); - } + final result = await _networkManager.makeRequest( + '/api/v1/tenders/details/$tenderId', + method: 'GET', + (json) => TenderDetailResponseModel.fromJson(json), + ); + return result; } } diff --git a/lib/data/services/tenders_service.dart b/lib/data/services/tenders_service.dart index 775b342..e465212 100644 --- a/lib/data/services/tenders_service.dart +++ b/lib/data/services/tenders_service.dart @@ -1,14 +1,10 @@ -import 'dart:convert'; - import 'package:dio/dio.dart'; import 'package:tm_app/core/utils/logger.dart'; import 'package:tm_app/core/utils/result.dart'; -import 'package:tm_app/data/services/mock_data/tenders_mock_data.dart'; import 'package:tm_app/data/services/model/tenders/tender_dislike_response/tender_dislike_response.dart'; import 'package:tm_app/data/services/model/tenders/tender_like_response/tender_like_response.dart'; import 'package:tm_app/data/services/model/tenders/tender_reject_response/tender_reject_response.dart'; import 'package:tm_app/data/services/model/tenders/tender_submit_response/tender_submit_response.dart'; -import 'package:tm_app/data/services/model/tenders/tenders_request/tenders_request.dart'; import 'package:tm_app/data/services/model/tenders/tenders_response/tenders_response.dart'; import '../../core/network/network_manager.dart'; @@ -18,26 +14,13 @@ class TendersService { : _networkManager = networkManager; final NetworkManager _networkManager; - Future> getTenders({ - TendersRequest? tendersRequestModel, - }) async { - try { - // final result = await _networkManager.makeRequest( - // '/api/v1/tenders', - // (json) => TendersResponse.fromJson(json), - // method: 'GET', - // ); - await Future.delayed(Duration(seconds: 2)); - appLogger.info('get tenders success'); - // TODO: will change when api is ready - return Result.ok(TendersResponse.fromJson(jsonDecode(tendersMockData))); - } on DioException catch (e) { - appLogger.error('get tenders failed: $e'); - return Result.error(e); - } on Exception catch (e, stackTrace) { - appLogger.error('get tenders failed: $e', stackTrace: stackTrace); - return Result.error(Exception(e)); - } + Future> getTenders() async { + final result = await _networkManager.makeRequest( + '/api/v1/tenders', + method: 'GET', + (json) => TendersResponse.fromJson(json), + ); + return result; } Future> likeTender() async { diff --git a/lib/view_models/auth_view_model.dart b/lib/view_models/auth_view_model.dart index 4390a4e..7bc32ee 100644 --- a/lib/view_models/auth_view_model.dart +++ b/lib/view_models/auth_view_model.dart @@ -1,10 +1,10 @@ import 'package:flutter/material.dart'; +import 'package:tm_app/data/services/model/customer/customer.dart'; import '../core/utils/result.dart'; import '../data/repositories/auth_repository.dart'; import '../data/services/model/login_response/login_response_model.dart'; import '../data/services/model/logout_response/logout_response.dart'; -import '../data/services/model/user/user.dart'; class AuthViewModel with ChangeNotifier { final AuthRepository _authRepository; @@ -30,11 +30,11 @@ class AuthViewModel with ChangeNotifier { // Auth state bool _isLoading = false; String? _errorMessage; - User? _loggedInUser; + Customer? _loggedInUser; bool get isLoading => _isLoading; String? get errorMessage => _errorMessage; - User? get loggedInUser => _loggedInUser; + Customer? get loggedInUser => _loggedInUser; void togglePasswordVisibility() { _obscurePassword = !_obscurePassword; @@ -57,8 +57,7 @@ class AuthViewModel with ChangeNotifier { switch (result) { case Ok(): - _loggedInUser = result.value.data.user; - + _loggedInUser = result.value.data.customer; break; case Error(): _errorMessage = result.error.toString(); diff --git a/lib/view_models/tender_detail_view_model.dart b/lib/view_models/tender_detail_view_model.dart index bac6866..a591c62 100644 --- a/lib/view_models/tender_detail_view_model.dart +++ b/lib/view_models/tender_detail_view_model.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; import 'package:tm_app/core/utils/result.dart'; import 'package:tm_app/data/repositories/tender_detail_repository.dart'; -import 'package:tm_app/data/services/model/tender_detail_request/tender_detail_request.dart'; +import 'package:tm_app/data/services/model/tender_data/tender_data.dart'; import 'package:tm_app/data/services/model/tender_detail_response/tender_detail_response_model.dart'; class TenderDetailViewModel with ChangeNotifier { @@ -9,32 +9,25 @@ class TenderDetailViewModel with ChangeNotifier { TenderDetailViewModel({ required TenderDetailRepository tenderDetailRepository, - }) : _tenderDetailRepository = tenderDetailRepository { - WidgetsBinding.instance.addPostFrameCallback((_) { - getTenderDetail(id: 'JNDFKMDV-100JF'); - }); - } + }) : _tenderDetailRepository = tenderDetailRepository; bool _isLoading = false; String? _errorMessage; - TenderDetailResponseModel? _tenderDetail; + TenderData? _tenderDetail; bool get isLoading => _isLoading; String? get errorMessage => _errorMessage; - TenderDetailResponseModel? get tenderDetail => _tenderDetail; + TenderData? get tenderDetail => _tenderDetail; Future getTenderDetail({required String id}) async { _isLoading = true; _errorMessage = null; notifyListeners(); - final request = TenderDetailRequest(id: id); - final result = await _tenderDetailRepository.getTenderDetail( - request: request, - ); + final result = await _tenderDetailRepository.getTenderDetail(tenderId: id); switch (result) { case Ok(): - _tenderDetail = result.value; + _tenderDetail = result.value.data; break; case Error(): _errorMessage = result.error.toString(); diff --git a/lib/view_models/tenders_view_model.dart b/lib/view_models/tenders_view_model.dart index bb4a9d2..709cd13 100644 --- a/lib/view_models/tenders_view_model.dart +++ b/lib/view_models/tenders_view_model.dart @@ -1,11 +1,6 @@ import 'package:flutter/material.dart'; import 'package:tm_app/data/repositories/tenders_repository.dart'; import 'package:tm_app/data/services/model/tender/tender_model.dart'; -import 'package:tm_app/data/services/model/tenders/tender_dislike_response/tender_dislike_response.dart'; -import 'package:tm_app/data/services/model/tenders/tender_like_response/tender_like_response.dart'; -import 'package:tm_app/data/services/model/tenders/tender_reject_response/tender_reject_response.dart'; -import 'package:tm_app/data/services/model/tenders/tender_submit_response/tender_submit_response.dart'; -import 'package:tm_app/data/services/model/tenders/tenders_request/tenders_request.dart'; import 'package:tm_app/data/services/model/tenders/tenders_response/tenders_response.dart'; import '../core/utils/result.dart'; @@ -35,10 +30,7 @@ class TendersViewModel with ChangeNotifier { _errorMessage = null; notifyListeners(); - final request = TendersRequest(id: 'JNDFKMDV-100JF'); - final result = await _tendersRepository.getTenders( - tendersRequestModel: request, - ); + final result = await _tendersRepository.getTenders(); switch (result) { case Ok(): _tendersResponse = result.value; @@ -61,98 +53,102 @@ class TendersViewModel with ChangeNotifier { bool? rejected, bool? submitted, }) { - if (_tendersResponse?.tenders != null) { - final updatedTenders = - _tendersResponse!.tenders!.map((element) { - if (element.tenderId == tenderId) { - return element.copyWith( - liked: liked, - disliked: disliked, - rejected: rejected, - submitted: submitted, - ); - } - return element; - }).toList(); + // if (_tendersResponse?.tendersData?.tenders != null) { + // final updatedTenders = + // _tendersResponse!.tendersData!.tenders!.map((element) { + // if (element.tenderId == tenderId) { + // return element.copyWith( + // liked: liked, + // disliked: disliked, + // rejected: rejected, + // submitted: submitted, + // ); + // } + // return element; + // }).toList(); - _tendersResponse = _tendersResponse!.copyWith(tenders: updatedTenders); - } + // _tendersResponse = _tendersResponse!.copyWith( + // tendersData: _tendersResponse!.tendersData!.copyWith( + // tenders: updatedTenders, + // ), + // ); + // } } /// Sets a tender as liked Future markLiked(TenderModel tender) async { - _updateTenderState( - tender.tenderId!, - liked: true, - disliked: false, - rejected: false, - submitted: tender.submitted, - ); - notifyListeners(); - final result = await _tendersRepository.likeTender(); - switch (result) { - case Ok(): - break; - case Error(): - break; - } + // _updateTenderState( + // tender.id!, + // liked: true, + // disliked: false, + // rejected: false, + // submitted: tender.submitted, + // ); + // notifyListeners(); + // final result = await _tendersRepository.likeTender(); + // switch (result) { + // case Ok(): + // break; + // case Error(): + // break; + // } } /// Sets a tender as disliked Future markDisliked(TenderModel tender) async { - _updateTenderState( - tender.tenderId!, - disliked: true, - liked: false, - rejected: tender.rejected, - submitted: false, - ); - notifyListeners(); - final result = await _tendersRepository.dislikeTender(); - switch (result) { - case Ok(): - break; - case Error(): - break; - } + // _updateTenderState( + // tender.tenderId!, + // disliked: true, + // liked: false, + // rejected: tender.rejected, + // submitted: false, + // ); + // notifyListeners(); + // final result = await _tendersRepository.dislikeTender(); + // switch (result) { + // case Ok(): + // break; + // case Error(): + // break; + // } } /// Sets a tender as rejected Future markRejected(TenderModel tender) async { - _updateTenderState( - tender.tenderId!, - rejected: true, - liked: false, - disliked: tender.disliked, - submitted: false, - ); - notifyListeners(); - final result = await _tendersRepository.rejectTender(); - switch (result) { - case Ok(): - break; - case Error(): - break; - } + // _updateTenderState( + // tender.tenderId!, + // rejected: true, + // liked: false, + // disliked: tender.disliked, + // submitted: false, + // ); + // notifyListeners(); + // final result = await _tendersRepository.rejectTender(); + // switch (result) { + // case Ok(): + // break; + // case Error(): + // break; + // } } /// Sets a tender as submitted Future markSubmitted(TenderModel tender) async { - _updateTenderState( - tender.tenderId!, - submitted: true, - liked: tender.liked, - disliked: false, - rejected: false, - ); - notifyListeners(); - final result = await _tendersRepository.submitTender(); - switch (result) { - case Ok(): - break; - case Error(): - break; - } + // _updateTenderState( + // tender.tenderId!, + // submitted: true, + // liked: tender.liked, + // disliked: false, + // rejected: false, + // ); + // notifyListeners(); + // final result = await _tendersRepository.submitTender(); + // switch (result) { + // case Ok(): + // break; + // case Error(): + // break; + // } } /// Clears a specific state for a tender @@ -163,52 +159,52 @@ class TendersViewModel with ChangeNotifier { bool? isRejected, bool? isSubmitted, }) { - _updateTenderState( - tenderModel.tenderId!, - liked: isLiked ?? tenderModel.liked, - disliked: isDisliked ?? tenderModel.disliked, - rejected: isRejected ?? tenderModel.rejected, - submitted: isSubmitted ?? tenderModel.submitted, - ); + // _updateTenderState( + // tenderModel.tenderId!, + // liked: isLiked ?? tenderModel.liked, + // disliked: isDisliked ?? tenderModel.disliked, + // rejected: isRejected ?? tenderModel.rejected, + // submitted: isSubmitted ?? tenderModel.submitted, + // ); } /// Toggles like state for a tender void toggleLike(TenderModel tender) { - if (tender.liked == true) { - clearTenderState(tender, isLiked: false); - } else { - markLiked(tender); - } - notifyListeners(); + // if (tender.liked == true) { + // clearTenderState(tender, isLiked: false); + // } else { + // markLiked(tender); + // } + // notifyListeners(); } /// Toggles dislike state for a tender void toggleDislike(TenderModel tender) { - if (tender.disliked == true) { - clearTenderState(tender, isDisliked: false); - } else { - markDisliked(tender); - } - notifyListeners(); + // if (tender.disliked == true) { + // clearTenderState(tender, isDisliked: false); + // } else { + // markDisliked(tender); + // } + // notifyListeners(); } /// Toggles reject state for a tender void toggleReject(TenderModel tender) { - if (tender.rejected == true) { - clearTenderState(tender, isRejected: false); - } else { - markRejected(tender); - } - notifyListeners(); + // if (tender.rejected == true) { + // clearTenderState(tender, isRejected: false); + // } else { + // markRejected(tender); + // } + // notifyListeners(); } /// Toggles submit state for a tender void toggleSubmit(TenderModel tender) { - if (tender.submitted == true) { - clearTenderState(tender, isSubmitted: false); - } else { - markSubmitted(tender); - } - notifyListeners(); + // if (tender.submitted == true) { + // clearTenderState(tender, isSubmitted: false); + // } else { + // markSubmitted(tender); + // } + // notifyListeners(); } } diff --git a/lib/views/detail/pages/detail_screen.dart b/lib/views/detail/pages/detail_screen.dart index 2a5053b..67c3bbf 100644 --- a/lib/views/detail/pages/detail_screen.dart +++ b/lib/views/detail/pages/detail_screen.dart @@ -1,20 +1,39 @@ import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; import 'package:tm_app/core/utils/size_config.dart'; +import 'package:tm_app/view_models/tender_detail_view_model.dart'; import 'package:tm_app/views/detail/pages/detail_desktop_page.dart'; import 'package:tm_app/views/detail/pages/detail_mobile_page.dart'; import 'package:tm_app/views/detail/pages/detail_tablet_page.dart'; import 'package:tm_app/views/shared/responsive_builder.dart'; -class TenderDetailScreen extends StatelessWidget { - const TenderDetailScreen({super.key}); +class TenderDetailScreen extends StatefulWidget { + const TenderDetailScreen({required this.tenderId, super.key}); + + final String tenderId; + + @override + State createState() => _TenderDetailScreenState(); +} + +class _TenderDetailScreenState extends State { + @override + void initState() { + super.initState(); + WidgetsBinding.instance.addPostFrameCallback((_) { + context.read().getTenderDetail( + id: widget.tenderId, + ); + }); + } @override Widget build(BuildContext context) { SizeConfig.init(context); return ResponsiveBuilder( - mobile: TenderDetailMobilePage(tenderId: 'JNDFKMDV-100JF'), - tablet: TenderDetailTabletPage(tenderId: 'JNDFKMDV-100JF'), - desktop: TenderDetailDesktopPage(tenderId: 'JNDFKMDV-100JF'), + mobile: TenderDetailMobilePage(tenderId: widget.tenderId), + tablet: TenderDetailTabletPage(tenderId: widget.tenderId), + desktop: TenderDetailDesktopPage(tenderId: widget.tenderId), ); } } diff --git a/lib/views/detail/widgets/tender_detail_card.dart b/lib/views/detail/widgets/tender_detail_card.dart index d31e48e..e6fe807 100644 --- a/lib/views/detail/widgets/tender_detail_card.dart +++ b/lib/views/detail/widgets/tender_detail_card.dart @@ -2,10 +2,10 @@ import 'package:flutter/material.dart'; import 'package:tm_app/core/constants/strings.dart'; import 'package:tm_app/core/theme/colors.dart'; import 'package:tm_app/core/utils/size_config.dart'; -import 'package:tm_app/data/services/model/tender_detail_response/tender_detail_response_model.dart'; +import 'package:tm_app/data/services/model/tender_data/tender_data.dart'; class TenderDetailCard extends StatelessWidget { - final TenderDetailResponseModel detail; + final TenderData detail; const TenderDetailCard({required this.detail, super.key}); diff --git a/lib/views/detail/widgets/tender_detail_header.dart b/lib/views/detail/widgets/tender_detail_header.dart index 6396622..6f2945a 100644 --- a/lib/views/detail/widgets/tender_detail_header.dart +++ b/lib/views/detail/widgets/tender_detail_header.dart @@ -1,7 +1,8 @@ import 'package:flutter/material.dart'; +import 'package:intl/intl.dart'; import 'package:tm_app/core/theme/colors.dart'; import 'package:tm_app/core/utils/size_config.dart'; -import 'package:tm_app/data/services/model/tender_detail_response/tender_detail_response_model.dart'; +import 'package:tm_app/data/services/model/tender_data/tender_data.dart'; import 'package:tm_app/views/detail/widgets/status_tag.dart'; import 'package:tm_app/views/detail/widgets/tender_detail_info_section.dart'; import 'package:tm_app/views/detail/widgets/tender_document_section.dart'; @@ -9,9 +10,13 @@ import 'package:tm_app/views/detail/widgets/tender_location_section.dart'; class TenderDetailHeader extends StatelessWidget { final bool isScreenBig; - final TenderDetailResponseModel detail; + final TenderData detail; - const TenderDetailHeader({required this.isScreenBig, required this.detail, super.key}); + const TenderDetailHeader({ + required this.isScreenBig, + required this.detail, + super.key, + }); @override Widget build(BuildContext context) { @@ -29,7 +34,7 @@ class TenderDetailHeader extends StatelessWidget { SizedBox(height: 12.0.h()), _buildTitle(), SizedBox(height: 10.0.h()), - Divider(color: AppColors.grey20,), + Divider(color: AppColors.grey20), SizedBox(height: 5.0.h()), TenderDetailInfoSection(isScreenBig: isScreenBig, detail: detail), TenderLocationSection(detail: detail), @@ -44,7 +49,7 @@ class TenderDetailHeader extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text( - detail.date ?? '', + unixToDate(detail.publicationDate), style: TextStyle( color: AppColors.grey60, fontWeight: FontWeight.w400, @@ -68,3 +73,14 @@ class TenderDetailHeader extends StatelessWidget { ), ); } + +String unixToDate(int? unixTimestamp, {String format = 'yyyy-MM-dd'}) { + if (unixTimestamp == null) return ''; + + // Convert seconds to milliseconds if needed + int timestampInMs = + unixTimestamp > 1000000000000 ? unixTimestamp : unixTimestamp * 1000; + + final DateTime dateTime = DateTime.fromMillisecondsSinceEpoch(timestampInMs); + return DateFormat(format).format(dateTime); +} diff --git a/lib/views/detail/widgets/tender_detail_info_section.dart b/lib/views/detail/widgets/tender_detail_info_section.dart index e504b0f..cebcc4a 100644 --- a/lib/views/detail/widgets/tender_detail_info_section.dart +++ b/lib/views/detail/widgets/tender_detail_info_section.dart @@ -1,43 +1,44 @@ import 'package:flutter/material.dart'; import 'package:tm_app/core/constants/strings.dart'; -import 'package:tm_app/data/services/model/tender_detail_response/tender_detail_response_model.dart'; +import 'package:tm_app/data/services/model/tender_data/tender_data.dart'; import 'package:tm_app/views/detail/widgets/deadline_item.dart'; import 'package:tm_app/views/detail/widgets/info_item.dart'; class TenderDetailInfoSection extends StatelessWidget { final bool isScreenBig; - final TenderDetailResponseModel detail; + final TenderData detail; - const TenderDetailInfoSection({required this.isScreenBig, required this.detail, super.key}); + const TenderDetailInfoSection({ + required this.isScreenBig, + required this.detail, + super.key, + }); @override Widget build(BuildContext context) { return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - InfoItem( - title: AppStrings.tenderIdLabel, - value: detail.id ?? '', - ), + InfoItem(title: AppStrings.tenderIdLabel, value: detail.id ?? ''), DeadlineItem( title: AppStrings.tenderDeadlineLabel, approvalText: AppStrings.tenderApprovalText, - approvalDate: detail.approvalDate ?? '', + approvalDate: '', submissionText: AppStrings.tenderSubmissionText, - submissionDate: detail.submissionDate ?? '', + submissionDate: '', isScreenBig: isScreenBig, ), InfoItem( title: AppStrings.tenderClientLabel, - value: detail.client ?? '', + value: detail.buyerOrganization!.name ?? '', ), InfoItem( title: AppStrings.tenderDeliveryLocationsLabel, - value: detail.deliveryLocation ?? '', + value: detail.countryCode ?? '', ), InfoItem( title: AppStrings.tenderReferenceNumberLabel, - value: detail.referenceNumber ?? '', + value: detail.noticePublicationId ?? '', ), ], ); diff --git a/lib/views/detail/widgets/tender_document_section.dart b/lib/views/detail/widgets/tender_document_section.dart index 0a41f85..be9f4d3 100644 --- a/lib/views/detail/widgets/tender_document_section.dart +++ b/lib/views/detail/widgets/tender_document_section.dart @@ -3,27 +3,24 @@ import 'package:flutter_svg/flutter_svg.dart'; import 'package:tm_app/core/constants/assets.dart'; import 'package:tm_app/core/theme/colors.dart'; import 'package:tm_app/core/utils/size_config.dart'; -import 'package:tm_app/data/services/model/tender_detail_response/tender_detail_response_model.dart'; -class TenderDocumentSection extends StatelessWidget { - final TenderDetailResponseModel detail; +import 'package:tm_app/data/services/model/tender_data/tender_data.dart'; - const TenderDocumentSection({super.key, required this.detail}); +class TenderDocumentSection extends StatelessWidget { + final TenderData detail; + + const TenderDocumentSection({required this.detail, super.key}); @override Widget build(BuildContext context) { return InkWell( - onTap: () { - if (detail.documentUrl != null) { - //launchUrl(Uri.parse(detail.documentUrl!)); - } - }, + onTap: () {}, child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ SvgPicture.asset(AssetsManager.export), SizedBox(height: 6.0.h()), Text( - detail.documentName ?? '', + '', style: TextStyle( fontWeight: FontWeight.w400, fontSize: 16.0.sp(), diff --git a/lib/views/detail/widgets/tender_location_section.dart b/lib/views/detail/widgets/tender_location_section.dart index d2ec023..d3cf0a9 100644 --- a/lib/views/detail/widgets/tender_location_section.dart +++ b/lib/views/detail/widgets/tender_location_section.dart @@ -4,10 +4,11 @@ import 'package:tm_app/core/constants/assets.dart'; import 'package:tm_app/core/constants/strings.dart'; import 'package:tm_app/core/theme/colors.dart'; import 'package:tm_app/core/utils/size_config.dart'; -import 'package:tm_app/data/services/model/tender_detail_response/tender_detail_response_model.dart'; + +import '../../../data/services/model/tender_data/tender_data.dart'; class TenderLocationSection extends StatelessWidget { - final TenderDetailResponseModel detail; + final TenderData detail; const TenderLocationSection({required this.detail, super.key}); @@ -21,7 +22,7 @@ class TenderLocationSection extends StatelessWidget { SizedBox( height: 45.0.h(), child: Text( - detail.locationTitle ?? '', + '', style: TextStyle( color: AppColors.grey80, fontWeight: FontWeight.w600, @@ -38,7 +39,7 @@ class TenderLocationSection extends StatelessWidget { ), SizedBox(width: 4.0.w()), Text( - detail.country ?? '', + detail.countryCode ?? '', style: TextStyle( color: AppColors.grey70, fontSize: 14.0.sp(), @@ -47,7 +48,7 @@ class TenderLocationSection extends StatelessWidget { ), SizedBox(width: 4.0.w()), Image.asset( - detail.flagAsset ?? AssetsManager.seFlag, + AssetsManager.seFlag, height: 20.0.h(), width: 20.0.w(), ), @@ -60,7 +61,7 @@ class TenderLocationSection extends StatelessWidget { ), SizedBox(height: 8.0.h()), Text( - detail.locationDescription ?? '', + detail.description ?? '', style: TextStyle(fontWeight: FontWeight.w400, fontSize: 14.0.sp()), ), SizedBox(height: 16.0.h()), diff --git a/lib/views/home/pages/d_home_page.dart b/lib/views/home/pages/d_home_page.dart index 84ae07a..66ca54d 100644 --- a/lib/views/home/pages/d_home_page.dart +++ b/lib/views/home/pages/d_home_page.dart @@ -100,7 +100,7 @@ class DesktopHomePage extends StatelessWidget { width: 178, height: 148, onTap: () { - YourTendersRouteData().push(context); + // YourTendersRouteData().push(context); }, ), SizedBox(width: 10), diff --git a/lib/views/tenders/pages/d_tenders_page.dart b/lib/views/tenders/pages/d_tenders_page.dart index c2a829d..1a11c7f 100644 --- a/lib/views/tenders/pages/d_tenders_page.dart +++ b/lib/views/tenders/pages/d_tenders_page.dart @@ -33,7 +33,7 @@ class DesktopTendersPage extends StatelessWidget { child: Padding( padding: EdgeInsets.symmetric(vertical: 24.0.h()), child: MainTendersSlider( - tenders: viewModel.tendersResponse?.tenders ?? [], + tenders: viewModel.tendersResponse?.data?.tenders ?? [], isDesktop: true, ), ), diff --git a/lib/views/tenders/pages/m_tenders_page.dart b/lib/views/tenders/pages/m_tenders_page.dart index 4f07b79..081a06f 100644 --- a/lib/views/tenders/pages/m_tenders_page.dart +++ b/lib/views/tenders/pages/m_tenders_page.dart @@ -30,7 +30,7 @@ class MobileTendersPage extends StatelessWidget { return Padding( padding: EdgeInsets.symmetric(vertical: 24.0.h()), child: MainTendersSlider( - tenders: viewModel.tendersResponse?.tenders ?? [], + tenders: viewModel.tendersResponse?.data?.tenders ?? [], ), ); }, diff --git a/lib/views/tenders/pages/t_tenders_page.dart b/lib/views/tenders/pages/t_tenders_page.dart index cddcfed..5006c24 100644 --- a/lib/views/tenders/pages/t_tenders_page.dart +++ b/lib/views/tenders/pages/t_tenders_page.dart @@ -28,7 +28,7 @@ class TabletTendersPage extends StatelessWidget { return Padding( padding: EdgeInsets.only(right: 24.0.w(), top: 128.0.h()), child: MainTendersSlider( - tenders: viewModel.tendersResponse?.tenders ?? [], + tenders: viewModel.tendersResponse?.data?.tenders ?? [], ), ); }, diff --git a/lib/views/tenders/widgets/main_tenders_slider.dart b/lib/views/tenders/widgets/main_tenders_slider.dart index b9013ed..f655d88 100644 --- a/lib/views/tenders/widgets/main_tenders_slider.dart +++ b/lib/views/tenders/widgets/main_tenders_slider.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/svg.dart'; import 'package:tm_app/core/theme/colors.dart'; -import 'package:tm_app/data/services/model/tender/tender_model.dart'; +import 'package:tm_app/data/services/model/tender_data/tender_data.dart'; import '../../../core/constants/assets.dart'; import '../../../core/utils/size_config.dart'; @@ -14,7 +14,7 @@ class MainTendersSlider extends StatefulWidget { this.isDesktop = false, }); final bool isDesktop; - final List tenders; + final List tenders; @override State createState() => _MainTendersSliderState(); diff --git a/lib/views/tenders/widgets/tender_action_buttons_row.dart b/lib/views/tenders/widgets/tender_action_buttons_row.dart index f903ada..5d760aa 100644 --- a/lib/views/tenders/widgets/tender_action_buttons_row.dart +++ b/lib/views/tenders/widgets/tender_action_buttons_row.dart @@ -2,7 +2,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/svg.dart'; import 'package:provider/provider.dart'; import 'package:tm_app/core/constants/strings.dart'; -import 'package:tm_app/data/services/model/tender/tender_model.dart'; +import 'package:tm_app/data/services/model/tender_data/tender_data.dart'; import 'package:tm_app/view_models/tenders_view_model.dart'; import '../../../core/constants/assets.dart'; @@ -10,7 +10,7 @@ import '../../../core/theme/colors.dart'; import '../../../core/utils/size_config.dart'; class TenderActionButtonsRow extends StatelessWidget { - final TenderModel tender; + final TenderData tender; final bool isDesktop; const TenderActionButtonsRow({ @@ -48,7 +48,7 @@ class TenderActionButtonsRow extends StatelessWidget { child: InkWell( splashColor: Colors.transparent, onTap: () { - viewModel.toggleReject(tender); + // viewModel.toggleReject(tender); }, child: Column( children: [ @@ -59,9 +59,10 @@ class TenderActionButtonsRow extends StatelessWidget { shape: BoxShape.circle, border: Border.all( color: - tender.rejected ?? false - ? AppColors.errorColor - : AppColors.grey60, + // tender.rejected ?? false + // ? AppColors.errorColor + // : + AppColors.grey60, width: 1.5.w(), ), ), @@ -69,9 +70,10 @@ class TenderActionButtonsRow extends StatelessWidget { child: Icon( Icons.close, color: - tender.rejected ?? false - ? AppColors.errorColor - : AppColors.grey60, + // tender.rejected ?? false + // ? AppColors.errorColor + // : + AppColors.grey60, size: 16, ), ), @@ -83,9 +85,10 @@ class TenderActionButtonsRow extends StatelessWidget { fontSize: 12.0.sp(), fontWeight: FontWeight.w400, color: - tender.rejected ?? false - ? AppColors.errorColor - : AppColors.grey60, + // tender.rejected ?? false + // ? AppColors.errorColor + // : + AppColors.grey60, ), ), ], @@ -100,7 +103,7 @@ class TenderActionButtonsRow extends StatelessWidget { child: InkWell( splashColor: Colors.transparent, onTap: () { - viewModel.toggleSubmit(tender); + // viewModel.toggleSubmit(tender); }, child: Column( children: [ @@ -111,9 +114,10 @@ class TenderActionButtonsRow extends StatelessWidget { shape: BoxShape.circle, border: Border.all( color: - tender.submitted ?? false - ? AppColors.successColor - : AppColors.grey60, + // tender.submitted ?? false + // ? AppColors.successColor + // : + AppColors.grey60, width: 1.5.w(), ), ), @@ -121,9 +125,10 @@ class TenderActionButtonsRow extends StatelessWidget { child: SvgPicture.asset( AssetsManager.tick, colorFilter: ColorFilter.mode( - tender.submitted ?? false - ? AppColors.successColor - : AppColors.grey60, + // tender.submitted ?? false + // ? AppColors.successColor + // : + AppColors.grey60, BlendMode.srcATop, ), ), @@ -136,9 +141,10 @@ class TenderActionButtonsRow extends StatelessWidget { fontSize: 12.0.sp(), fontWeight: FontWeight.w400, color: - tender.submitted ?? false - ? AppColors.successColor - : AppColors.grey60, + // tender.submitted ?? false + // ? AppColors.successColor + // : + AppColors.grey60, ), ), ], @@ -153,7 +159,7 @@ class TenderActionButtonsRow extends StatelessWidget { child: InkWell( splashColor: Colors.transparent, onTap: () { - viewModel.toggleDislike(tender); + // viewModel.toggleDislike(tender); }, child: Column( children: [ @@ -163,9 +169,10 @@ class TenderActionButtonsRow extends StatelessWidget { fit: BoxFit.cover, AssetsManager.dislike, colorFilter: ColorFilter.mode( - tender.disliked ?? false - ? AppColors.errorColor - : AppColors.grey50, + // tender.disliked ?? false + // ? AppColors.errorColor + // : + AppColors.grey50, BlendMode.srcATop, ), ), @@ -177,9 +184,10 @@ class TenderActionButtonsRow extends StatelessWidget { fontSize: 12.0.sp(), fontWeight: FontWeight.w400, color: - tender.disliked ?? false - ? AppColors.errorColor - : AppColors.grey50, + // tender.disliked ?? false + // ? AppColors.errorColor + // : + AppColors.grey50, ), ), ], @@ -194,7 +202,7 @@ class TenderActionButtonsRow extends StatelessWidget { child: InkWell( splashColor: Colors.transparent, onTap: () { - viewModel.toggleLike(tender); + // viewModel.toggleLike(tender); }, child: Column( children: [ @@ -204,9 +212,10 @@ class TenderActionButtonsRow extends StatelessWidget { fit: BoxFit.cover, AssetsManager.like, colorFilter: ColorFilter.mode( - tender.liked ?? false - ? AppColors.successColor - : AppColors.grey50, + // tender.liked ?? false + // ? AppColors.successColor + // : + AppColors.grey50, BlendMode.srcATop, ), ), @@ -218,9 +227,10 @@ class TenderActionButtonsRow extends StatelessWidget { fontSize: 12.0.sp(), fontWeight: FontWeight.w400, color: - tender.liked ?? false - ? AppColors.successColor - : AppColors.grey50, + // tender.liked ?? false + // ? AppColors.successColor + // : + AppColors.grey50, ), ), ], diff --git a/lib/views/tenders/widgets/tender_card.dart b/lib/views/tenders/widgets/tender_card.dart index 9f6c123..4a7dbc0 100644 --- a/lib/views/tenders/widgets/tender_card.dart +++ b/lib/views/tenders/widgets/tender_card.dart @@ -1,16 +1,17 @@ -import 'package:flutter/material.dart'; +import 'package:flutter/material.dart' hide DateUtils; import 'package:flutter_svg/svg.dart'; import 'package:tm_app/core/constants/strings.dart'; import 'package:tm_app/core/routes/app_routes.dart'; -import 'package:tm_app/data/services/model/tender/tender_model.dart'; +import 'package:tm_app/data/services/model/tender_data/tender_data.dart'; import '../../../core/constants/assets.dart'; import '../../../core/theme/colors.dart'; +import '../../../core/utils/date_utils.dart'; import '../../../core/utils/size_config.dart'; import 'tender_action_buttons_row.dart'; class TenderCard extends StatelessWidget { - final TenderModel tender; + final TenderData tender; final bool isDesktop; const TenderCard({required this.tender, super.key, this.isDesktop = false}); @@ -104,7 +105,7 @@ class TenderCard extends StatelessWidget { Widget _dateText() { return Text( - tender.createdTime ?? '', + DateUtils.unixToDate(tender.publicationDate ?? 0), style: TextStyle( color: AppColors.grey60, fontSize: 12.0.sp(), @@ -134,7 +135,7 @@ class TenderCard extends StatelessWidget { ), ), Text( - tender.deadline ?? '', + DateUtils.unixToDate(tender.tenderDeadline ?? 0), style: TextStyle( color: AppColors.grey80, fontSize: 14.0.sp(), @@ -171,7 +172,7 @@ class TenderCard extends StatelessWidget { Widget _idText() { return Text( - tender.tenderId ?? '', + tender.id ?? '', style: TextStyle( color: AppColors.grey, fontSize: 14.0.sp(), @@ -193,7 +194,7 @@ class TenderCard extends StatelessWidget { ), ), Text( - '${tender.profileMatch ?? 0}%', + '${45}%', style: TextStyle( color: AppColors.secondaryTextColor, fontSize: 16.0.sp(), @@ -214,7 +215,7 @@ class TenderCard extends StatelessWidget { ), child: FractionallySizedBox( alignment: Alignment.centerLeft, - widthFactor: (tender.profileMatch ?? 0) / 100, + widthFactor: (45) / 100, child: Container( decoration: BoxDecoration( color: AppColors.secondary50, @@ -232,7 +233,7 @@ class TenderCard extends StatelessWidget { SvgPicture.asset(AssetsManager.location), SizedBox(width: 4.0.w()), Text( - tender.location ?? '', + tender.countryCode ?? '', style: TextStyle( color: AppColors.grey80, fontSize: 14.0.sp(), @@ -250,7 +251,7 @@ class TenderCard extends StatelessWidget { Widget _seeMoreButton(BuildContext context) { return InkWell( onTap: () { - TenderDetailRouteData().push(context); + TenderDetailRouteData(tenderId: tender.id!).push(context); }, child: Container( width: 108.0.w(), diff --git a/lib/views/your_tenders/model/tender_model.dart b/lib/views/your_tenders/model/tender_model.dart deleted file mode 100644 index 45da451..0000000 --- a/lib/views/your_tenders/model/tender_model.dart +++ /dev/null @@ -1,101 +0,0 @@ -import 'package:flutter/material.dart'; - -class TenderModel { - final String date; - final String title; - final String description; - final String location; - final String countryFlag; - final String status; - final String projectStatus; - final Color? backgroundColor; - final Color? borderColor; - final String? statusIcon; - final Color? statusCardColor; - - TenderModel({ - required this.date, - required this.title, - required this.description, - required this.location, - required this.countryFlag, - required this.status, - required this.projectStatus, - this.backgroundColor, - this.borderColor, - this.statusIcon, - this.statusCardColor, - }); -} - -List approvedTenders = [ - TenderModel( - date: '2025-01-01', - title: - 'Lorem ipsum dolor sit amet consectetur. Sed mi tortor eu purus senectus.', - description: - 'Lorem ipsum dolor sit amet consectetur. Volutpat velit tincidunt amet diam. Placerat congue ut Sed facilisis faucibus porttitor. Proin suspendisse eu euismod sit lorem quis. ', - location: 'Stockholm, Sweden', - countryFlag: 'assets/icons/SE.png', - status: 'Completed', - projectStatus: 'Self Control', - ), - TenderModel( - date: '2025-01-01', - title: - 'Lorem ipsum dolor sit amet consectetur. Sed mi tortor eu purus senectus.', - description: - 'Lorem ipsum dolor sit amet consectetur. Volutpat velit tincidunt amet diam. Placerat congue ut Sed facilisis faucibus porttitor. Proin suspendisse eu euismod sit lorem quis. ', - location: 'Stockholm, Sweden', - countryFlag: 'assets/icons/SE.png', - status: 'Completed', - projectStatus: 'Patner Ship', - ), - TenderModel( - date: '2025-01-01', - title: - 'Lorem ipsum dolor sit amet consectetur. Sed mi tortor eu purus senectus.', - description: - 'Lorem ipsum dolor sit amet consectetur. Volutpat velit tincidunt amet diam. Placerat congue ut Sed facilisis faucibus porttitor. Proin suspendisse eu euismod sit lorem quis. ', - location: 'Stockholm, Sweden', - countryFlag: 'assets/icons/SE.png', - status: 'Completed', - projectStatus: 'Self Control', - ), -]; - -List tendersSubmitted = [ - TenderModel( - date: '2025-01-01', - title: - 'Lorem ipsum dolor sit amet consectetur. Sed mi tortor eu purus senectus.', - description: - 'Lorem ipsum dolor sit amet consectetur. Volutpat velit tincidunt amet diam. Placerat congue ut Sed facilisis faucibus porttitor. Proin suspendisse eu euismod sit lorem quis. ', - location: 'Stockholm, Sweden', - countryFlag: 'assets/icons/SE.png', - status: 'Won', - projectStatus: 'Self Control', - ), - TenderModel( - date: '2025-01-01', - title: - 'Lorem ipsum dolor sit amet consectetur. Sed mi tortor eu purus senectus.', - description: - 'Lorem ipsum dolor sit amet consectetur. Volutpat velit tincidunt amet diam. Placerat congue ut Sed facilisis faucibus porttitor. Proin suspendisse eu euismod sit lorem quis. ', - location: 'Stockholm, Sweden', - countryFlag: 'assets/icons/SE.png', - status: 'Reject', - projectStatus: 'Patner Ship', - ), - TenderModel( - date: '2025-01-01', - title: - 'Lorem ipsum dolor sit amet consectetur. Sed mi tortor eu purus senectus.', - description: - 'Lorem ipsum dolor sit amet consectetur. Volutpat velit tincidunt amet diam. Placerat congue ut Sed facilisis faucibus porttitor. Proin suspendisse eu euismod sit lorem quis. ', - location: 'Stockholm, Sweden', - countryFlag: 'assets/icons/SE.png', - status: 'Won', - projectStatus: 'Self Control', - ), -]; diff --git a/pubspec.yaml b/pubspec.yaml index 42b28db..749304f 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -22,6 +22,7 @@ dependencies: shared_preferences: ^2.5.3 json_annotation: ^4.8.1 http: ^1.5.0 + intl: ^0.20.2 dev_dependencies: flutter_test: