diff --git a/lib/data/repositories/profile_repository.dart b/lib/data/repositories/profile_repository.dart index 2540ce6..c5a11b7 100644 --- a/lib/data/repositories/profile_repository.dart +++ b/lib/data/repositories/profile_repository.dart @@ -1,3 +1,4 @@ +import 'package:tm_app/data/services/model/company_profile_response/company_profile_response.dart'; import 'package:tm_app/data/services/profile_service.dart'; import '../../core/utils/result.dart'; @@ -11,4 +12,8 @@ class ProfileRepository { Future> getProfile() async { return _profileService.getProfile(); } + + Future> getCompanyProfile() { + return _profileService.getCompanyProfile(); + } } diff --git a/lib/data/services/model/company_profile_data/company_profile_data.dart b/lib/data/services/model/company_profile_data/company_profile_data.dart new file mode 100644 index 0000000..dc1561a --- /dev/null +++ b/lib/data/services/model/company_profile_data/company_profile_data.dart @@ -0,0 +1,21 @@ +// ignore_for_file: invalid_annotation_target + +import 'package:freezed_annotation/freezed_annotation.dart'; + +part 'company_profile_data.freezed.dart'; +part 'company_profile_data.g.dart'; + +@freezed +abstract class CompanyProfileData with _$CompanyProfileData { + const factory CompanyProfileData({ + required String? id, + required String? name, + @JsonKey(name: 'registration_number') required String? registrationNumber, + required String? industry, + @JsonKey(name: 'founded_year') required int? foundedYear, + @JsonKey(name: 'created_at') required int? createdAt, + }) = _CompanyProfileData; + + factory CompanyProfileData.fromJson(Map json) => + _$CompanyProfileDataFromJson(json); +} diff --git a/lib/data/services/model/company_profile_data/company_profile_data.freezed.dart b/lib/data/services/model/company_profile_data/company_profile_data.freezed.dart new file mode 100644 index 0000000..2519855 --- /dev/null +++ b/lib/data/services/model/company_profile_data/company_profile_data.freezed.dart @@ -0,0 +1,292 @@ +// 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 'company_profile_data.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +// dart format off +T _$identity(T value) => value; + +/// @nodoc +mixin _$CompanyProfileData { + + String? get id; String? get name;@JsonKey(name: 'registration_number') String? get registrationNumber; String? get industry;@JsonKey(name: 'founded_year') int? get foundedYear;@JsonKey(name: 'created_at') int? get createdAt; +/// Create a copy of CompanyProfileData +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$CompanyProfileDataCopyWith get copyWith => _$CompanyProfileDataCopyWithImpl(this as CompanyProfileData, _$identity); + + /// Serializes this CompanyProfileData to a JSON map. + Map toJson(); + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is CompanyProfileData&&(identical(other.id, id) || other.id == id)&&(identical(other.name, name) || other.name == name)&&(identical(other.registrationNumber, registrationNumber) || other.registrationNumber == registrationNumber)&&(identical(other.industry, industry) || other.industry == industry)&&(identical(other.foundedYear, foundedYear) || other.foundedYear == foundedYear)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,id,name,registrationNumber,industry,foundedYear,createdAt); + +@override +String toString() { + return 'CompanyProfileData(id: $id, name: $name, registrationNumber: $registrationNumber, industry: $industry, foundedYear: $foundedYear, createdAt: $createdAt)'; +} + + +} + +/// @nodoc +abstract mixin class $CompanyProfileDataCopyWith<$Res> { + factory $CompanyProfileDataCopyWith(CompanyProfileData value, $Res Function(CompanyProfileData) _then) = _$CompanyProfileDataCopyWithImpl; +@useResult +$Res call({ + String? id, String? name,@JsonKey(name: 'registration_number') String? registrationNumber, String? industry,@JsonKey(name: 'founded_year') int? foundedYear,@JsonKey(name: 'created_at') int? createdAt +}); + + + + +} +/// @nodoc +class _$CompanyProfileDataCopyWithImpl<$Res> + implements $CompanyProfileDataCopyWith<$Res> { + _$CompanyProfileDataCopyWithImpl(this._self, this._then); + + final CompanyProfileData _self; + final $Res Function(CompanyProfileData) _then; + +/// Create a copy of CompanyProfileData +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? id = freezed,Object? name = freezed,Object? registrationNumber = freezed,Object? industry = freezed,Object? foundedYear = freezed,Object? createdAt = freezed,}) { + return _then(_self.copyWith( +id: freezed == id ? _self.id : id // ignore: cast_nullable_to_non_nullable +as String?,name: freezed == name ? _self.name : name // ignore: cast_nullable_to_non_nullable +as String?,registrationNumber: freezed == registrationNumber ? _self.registrationNumber : registrationNumber // ignore: cast_nullable_to_non_nullable +as String?,industry: freezed == industry ? _self.industry : industry // ignore: cast_nullable_to_non_nullable +as String?,foundedYear: freezed == foundedYear ? _self.foundedYear : foundedYear // ignore: cast_nullable_to_non_nullable +as int?,createdAt: freezed == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable +as int?, + )); +} + +} + + +/// Adds pattern-matching-related methods to [CompanyProfileData]. +extension CompanyProfileDataPatterns on CompanyProfileData { +/// 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( _CompanyProfileData value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _CompanyProfileData() 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( _CompanyProfileData value) $default,){ +final _that = this; +switch (_that) { +case _CompanyProfileData(): +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( _CompanyProfileData value)? $default,){ +final _that = this; +switch (_that) { +case _CompanyProfileData() 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? name, @JsonKey(name: 'registration_number') String? registrationNumber, String? industry, @JsonKey(name: 'founded_year') int? foundedYear, @JsonKey(name: 'created_at') int? createdAt)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _CompanyProfileData() when $default != null: +return $default(_that.id,_that.name,_that.registrationNumber,_that.industry,_that.foundedYear,_that.createdAt);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? name, @JsonKey(name: 'registration_number') String? registrationNumber, String? industry, @JsonKey(name: 'founded_year') int? foundedYear, @JsonKey(name: 'created_at') int? createdAt) $default,) {final _that = this; +switch (_that) { +case _CompanyProfileData(): +return $default(_that.id,_that.name,_that.registrationNumber,_that.industry,_that.foundedYear,_that.createdAt);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? name, @JsonKey(name: 'registration_number') String? registrationNumber, String? industry, @JsonKey(name: 'founded_year') int? foundedYear, @JsonKey(name: 'created_at') int? createdAt)? $default,) {final _that = this; +switch (_that) { +case _CompanyProfileData() when $default != null: +return $default(_that.id,_that.name,_that.registrationNumber,_that.industry,_that.foundedYear,_that.createdAt);case _: + return null; + +} +} + +} + +/// @nodoc +@JsonSerializable() + +class _CompanyProfileData implements CompanyProfileData { + const _CompanyProfileData({required this.id, required this.name, @JsonKey(name: 'registration_number') required this.registrationNumber, required this.industry, @JsonKey(name: 'founded_year') required this.foundedYear, @JsonKey(name: 'created_at') required this.createdAt}); + factory _CompanyProfileData.fromJson(Map json) => _$CompanyProfileDataFromJson(json); + +@override final String? id; +@override final String? name; +@override@JsonKey(name: 'registration_number') final String? registrationNumber; +@override final String? industry; +@override@JsonKey(name: 'founded_year') final int? foundedYear; +@override@JsonKey(name: 'created_at') final int? createdAt; + +/// Create a copy of CompanyProfileData +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$CompanyProfileDataCopyWith<_CompanyProfileData> get copyWith => __$CompanyProfileDataCopyWithImpl<_CompanyProfileData>(this, _$identity); + +@override +Map toJson() { + return _$CompanyProfileDataToJson(this, ); +} + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _CompanyProfileData&&(identical(other.id, id) || other.id == id)&&(identical(other.name, name) || other.name == name)&&(identical(other.registrationNumber, registrationNumber) || other.registrationNumber == registrationNumber)&&(identical(other.industry, industry) || other.industry == industry)&&(identical(other.foundedYear, foundedYear) || other.foundedYear == foundedYear)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,id,name,registrationNumber,industry,foundedYear,createdAt); + +@override +String toString() { + return 'CompanyProfileData(id: $id, name: $name, registrationNumber: $registrationNumber, industry: $industry, foundedYear: $foundedYear, createdAt: $createdAt)'; +} + + +} + +/// @nodoc +abstract mixin class _$CompanyProfileDataCopyWith<$Res> implements $CompanyProfileDataCopyWith<$Res> { + factory _$CompanyProfileDataCopyWith(_CompanyProfileData value, $Res Function(_CompanyProfileData) _then) = __$CompanyProfileDataCopyWithImpl; +@override @useResult +$Res call({ + String? id, String? name,@JsonKey(name: 'registration_number') String? registrationNumber, String? industry,@JsonKey(name: 'founded_year') int? foundedYear,@JsonKey(name: 'created_at') int? createdAt +}); + + + + +} +/// @nodoc +class __$CompanyProfileDataCopyWithImpl<$Res> + implements _$CompanyProfileDataCopyWith<$Res> { + __$CompanyProfileDataCopyWithImpl(this._self, this._then); + + final _CompanyProfileData _self; + final $Res Function(_CompanyProfileData) _then; + +/// Create a copy of CompanyProfileData +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? id = freezed,Object? name = freezed,Object? registrationNumber = freezed,Object? industry = freezed,Object? foundedYear = freezed,Object? createdAt = freezed,}) { + return _then(_CompanyProfileData( +id: freezed == id ? _self.id : id // ignore: cast_nullable_to_non_nullable +as String?,name: freezed == name ? _self.name : name // ignore: cast_nullable_to_non_nullable +as String?,registrationNumber: freezed == registrationNumber ? _self.registrationNumber : registrationNumber // ignore: cast_nullable_to_non_nullable +as String?,industry: freezed == industry ? _self.industry : industry // ignore: cast_nullable_to_non_nullable +as String?,foundedYear: freezed == foundedYear ? _self.foundedYear : foundedYear // ignore: cast_nullable_to_non_nullable +as int?,createdAt: freezed == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable +as int?, + )); +} + + +} + +// dart format on diff --git a/lib/data/services/model/company_profile_data/company_profile_data.g.dart b/lib/data/services/model/company_profile_data/company_profile_data.g.dart new file mode 100644 index 0000000..4098288 --- /dev/null +++ b/lib/data/services/model/company_profile_data/company_profile_data.g.dart @@ -0,0 +1,27 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'company_profile_data.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_CompanyProfileData _$CompanyProfileDataFromJson(Map json) => + _CompanyProfileData( + id: json['id'] as String?, + name: json['name'] as String?, + registrationNumber: json['registration_number'] as String?, + industry: json['industry'] as String?, + foundedYear: (json['founded_year'] as num?)?.toInt(), + createdAt: (json['created_at'] as num?)?.toInt(), + ); + +Map _$CompanyProfileDataToJson(_CompanyProfileData instance) => + { + 'id': instance.id, + 'name': instance.name, + 'registration_number': instance.registrationNumber, + 'industry': instance.industry, + 'founded_year': instance.foundedYear, + 'created_at': instance.createdAt, + }; diff --git a/lib/data/services/model/company_profile_response/company_profile_response.dart b/lib/data/services/model/company_profile_response/company_profile_response.dart new file mode 100644 index 0000000..ef20044 --- /dev/null +++ b/lib/data/services/model/company_profile_response/company_profile_response.dart @@ -0,0 +1,22 @@ +// ignore_for_file: invalid_annotation_target + +import 'package:freezed_annotation/freezed_annotation.dart'; + +import '../company_profile_data/company_profile_data.dart'; +import '../error/error_model.dart'; + +part 'company_profile_response.freezed.dart'; +part 'company_profile_response.g.dart'; + +@freezed +abstract class CompanyProfileResponse with _$CompanyProfileResponse { + const factory CompanyProfileResponse({ + required String? message, + required bool? success, + required ErrorModel? error, + required CompanyProfileData? data, + }) = _CompanyProfileResponse; + + factory CompanyProfileResponse.fromJson(Map json) => + _$CompanyProfileResponseFromJson(json); +} diff --git a/lib/data/services/model/company_profile_response/company_profile_response.freezed.dart b/lib/data/services/model/company_profile_response/company_profile_response.freezed.dart new file mode 100644 index 0000000..f21c323 --- /dev/null +++ b/lib/data/services/model/company_profile_response/company_profile_response.freezed.dart @@ -0,0 +1,334 @@ +// 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 'company_profile_response.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +// dart format off +T _$identity(T value) => value; + +/// @nodoc +mixin _$CompanyProfileResponse { + + String? get message; bool? get success; ErrorModel? get error; CompanyProfileData? get data; +/// Create a copy of CompanyProfileResponse +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$CompanyProfileResponseCopyWith get copyWith => _$CompanyProfileResponseCopyWithImpl(this as CompanyProfileResponse, _$identity); + + /// Serializes this CompanyProfileResponse to a JSON map. + Map toJson(); + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is CompanyProfileResponse&&(identical(other.message, message) || other.message == message)&&(identical(other.success, success) || other.success == success)&&(identical(other.error, error) || other.error == error)&&(identical(other.data, data) || other.data == data)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,message,success,error,data); + +@override +String toString() { + return 'CompanyProfileResponse(message: $message, success: $success, error: $error, data: $data)'; +} + + +} + +/// @nodoc +abstract mixin class $CompanyProfileResponseCopyWith<$Res> { + factory $CompanyProfileResponseCopyWith(CompanyProfileResponse value, $Res Function(CompanyProfileResponse) _then) = _$CompanyProfileResponseCopyWithImpl; +@useResult +$Res call({ + String? message, bool? success, ErrorModel? error, CompanyProfileData? data +}); + + +$ErrorModelCopyWith<$Res>? get error;$CompanyProfileDataCopyWith<$Res>? get data; + +} +/// @nodoc +class _$CompanyProfileResponseCopyWithImpl<$Res> + implements $CompanyProfileResponseCopyWith<$Res> { + _$CompanyProfileResponseCopyWithImpl(this._self, this._then); + + final CompanyProfileResponse _self; + final $Res Function(CompanyProfileResponse) _then; + +/// Create a copy of CompanyProfileResponse +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? message = freezed,Object? success = freezed,Object? error = freezed,Object? data = freezed,}) { + return _then(_self.copyWith( +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?,error: freezed == error ? _self.error : error // ignore: cast_nullable_to_non_nullable +as ErrorModel?,data: freezed == data ? _self.data : data // ignore: cast_nullable_to_non_nullable +as CompanyProfileData?, + )); +} +/// Create a copy of CompanyProfileResponse +/// 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)); + }); +}/// Create a copy of CompanyProfileResponse +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$CompanyProfileDataCopyWith<$Res>? get data { + if (_self.data == null) { + return null; + } + + return $CompanyProfileDataCopyWith<$Res>(_self.data!, (value) { + return _then(_self.copyWith(data: value)); + }); +} +} + + +/// Adds pattern-matching-related methods to [CompanyProfileResponse]. +extension CompanyProfileResponsePatterns on CompanyProfileResponse { +/// 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( _CompanyProfileResponse value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _CompanyProfileResponse() 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( _CompanyProfileResponse value) $default,){ +final _that = this; +switch (_that) { +case _CompanyProfileResponse(): +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( _CompanyProfileResponse value)? $default,){ +final _that = this; +switch (_that) { +case _CompanyProfileResponse() 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? message, bool? success, ErrorModel? error, CompanyProfileData? data)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _CompanyProfileResponse() when $default != null: +return $default(_that.message,_that.success,_that.error,_that.data);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? message, bool? success, ErrorModel? error, CompanyProfileData? data) $default,) {final _that = this; +switch (_that) { +case _CompanyProfileResponse(): +return $default(_that.message,_that.success,_that.error,_that.data);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? message, bool? success, ErrorModel? error, CompanyProfileData? data)? $default,) {final _that = this; +switch (_that) { +case _CompanyProfileResponse() when $default != null: +return $default(_that.message,_that.success,_that.error,_that.data);case _: + return null; + +} +} + +} + +/// @nodoc +@JsonSerializable() + +class _CompanyProfileResponse implements CompanyProfileResponse { + const _CompanyProfileResponse({required this.message, required this.success, required this.error, required this.data}); + factory _CompanyProfileResponse.fromJson(Map json) => _$CompanyProfileResponseFromJson(json); + +@override final String? message; +@override final bool? success; +@override final ErrorModel? error; +@override final CompanyProfileData? data; + +/// Create a copy of CompanyProfileResponse +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$CompanyProfileResponseCopyWith<_CompanyProfileResponse> get copyWith => __$CompanyProfileResponseCopyWithImpl<_CompanyProfileResponse>(this, _$identity); + +@override +Map toJson() { + return _$CompanyProfileResponseToJson(this, ); +} + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _CompanyProfileResponse&&(identical(other.message, message) || other.message == message)&&(identical(other.success, success) || other.success == success)&&(identical(other.error, error) || other.error == error)&&(identical(other.data, data) || other.data == data)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,message,success,error,data); + +@override +String toString() { + return 'CompanyProfileResponse(message: $message, success: $success, error: $error, data: $data)'; +} + + +} + +/// @nodoc +abstract mixin class _$CompanyProfileResponseCopyWith<$Res> implements $CompanyProfileResponseCopyWith<$Res> { + factory _$CompanyProfileResponseCopyWith(_CompanyProfileResponse value, $Res Function(_CompanyProfileResponse) _then) = __$CompanyProfileResponseCopyWithImpl; +@override @useResult +$Res call({ + String? message, bool? success, ErrorModel? error, CompanyProfileData? data +}); + + +@override $ErrorModelCopyWith<$Res>? get error;@override $CompanyProfileDataCopyWith<$Res>? get data; + +} +/// @nodoc +class __$CompanyProfileResponseCopyWithImpl<$Res> + implements _$CompanyProfileResponseCopyWith<$Res> { + __$CompanyProfileResponseCopyWithImpl(this._self, this._then); + + final _CompanyProfileResponse _self; + final $Res Function(_CompanyProfileResponse) _then; + +/// Create a copy of CompanyProfileResponse +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? message = freezed,Object? success = freezed,Object? error = freezed,Object? data = freezed,}) { + return _then(_CompanyProfileResponse( +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?,error: freezed == error ? _self.error : error // ignore: cast_nullable_to_non_nullable +as ErrorModel?,data: freezed == data ? _self.data : data // ignore: cast_nullable_to_non_nullable +as CompanyProfileData?, + )); +} + +/// Create a copy of CompanyProfileResponse +/// 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)); + }); +}/// Create a copy of CompanyProfileResponse +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$CompanyProfileDataCopyWith<$Res>? get data { + if (_self.data == null) { + return null; + } + + return $CompanyProfileDataCopyWith<$Res>(_self.data!, (value) { + return _then(_self.copyWith(data: value)); + }); +} +} + +// dart format on diff --git a/lib/data/services/model/company_profile_response/company_profile_response.g.dart b/lib/data/services/model/company_profile_response/company_profile_response.g.dart new file mode 100644 index 0000000..f037dba --- /dev/null +++ b/lib/data/services/model/company_profile_response/company_profile_response.g.dart @@ -0,0 +1,31 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'company_profile_response.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_CompanyProfileResponse _$CompanyProfileResponseFromJson( + Map json, +) => _CompanyProfileResponse( + message: json['message'] as String?, + success: json['success'] as bool?, + error: + json['error'] == null + ? null + : ErrorModel.fromJson(json['error'] as Map), + data: + json['data'] == null + ? null + : CompanyProfileData.fromJson(json['data'] as Map), +); + +Map _$CompanyProfileResponseToJson( + _CompanyProfileResponse instance, +) => { + 'message': instance.message, + 'success': instance.success, + 'error': instance.error, + 'data': instance.data, +}; diff --git a/lib/data/services/model/tender_approvals_state_response/tender_approvals_state_response.freezed.dart b/lib/data/services/model/tender_approvals_state_response/tender_approvals_state_response.freezed.dart index 7d973e5..a2dfc7b 100644 --- a/lib/data/services/model/tender_approvals_state_response/tender_approvals_state_response.freezed.dart +++ b/lib/data/services/model/tender_approvals_state_response/tender_approvals_state_response.freezed.dart @@ -15,7 +15,7 @@ T _$identity(T value) => value; /// @nodoc mixin _$TenderApprovalsStateResponse { -@JsonKey(name: "success") bool? get success;@JsonKey(name: "message") String? get message;@JsonKey(name: "error") ErrorModel? get error;@JsonKey(name: "data") TenderApprovalsStateData? get data; +@JsonKey(name: 'success') bool? get success;@JsonKey(name: 'message') String? get message;@JsonKey(name: 'error') ErrorModel? get error;@JsonKey(name: 'data') TenderApprovalsStateData? get data; /// Create a copy of TenderApprovalsStateResponse /// with the given fields replaced by the non-null parameter values. @JsonKey(includeFromJson: false, includeToJson: false) @@ -48,7 +48,7 @@ abstract mixin class $TenderApprovalsStateResponseCopyWith<$Res> { factory $TenderApprovalsStateResponseCopyWith(TenderApprovalsStateResponse value, $Res Function(TenderApprovalsStateResponse) _then) = _$TenderApprovalsStateResponseCopyWithImpl; @useResult $Res call({ -@JsonKey(name: "success") bool? success,@JsonKey(name: "message") String? message,@JsonKey(name: "error") ErrorModel? error,@JsonKey(name: "data") TenderApprovalsStateData? data +@JsonKey(name: 'success') bool? success,@JsonKey(name: 'message') String? message,@JsonKey(name: 'error') ErrorModel? error,@JsonKey(name: 'data') TenderApprovalsStateData? data }); @@ -180,7 +180,7 @@ return $default(_that);case _: /// } /// ``` -@optionalTypeArgs TResult maybeWhen(TResult Function(@JsonKey(name: "success") bool? success, @JsonKey(name: "message") String? message, @JsonKey(name: "error") ErrorModel? error, @JsonKey(name: "data") TenderApprovalsStateData? data)? $default,{required TResult orElse(),}) {final _that = this; +@optionalTypeArgs TResult maybeWhen(TResult Function(@JsonKey(name: 'success') bool? success, @JsonKey(name: 'message') String? message, @JsonKey(name: 'error') ErrorModel? error, @JsonKey(name: 'data') TenderApprovalsStateData? data)? $default,{required TResult orElse(),}) {final _that = this; switch (_that) { case _TenderApprovalsStateResponse() when $default != null: return $default(_that.success,_that.message,_that.error,_that.data);case _: @@ -201,7 +201,7 @@ return $default(_that.success,_that.message,_that.error,_that.data);case _: /// } /// ``` -@optionalTypeArgs TResult when(TResult Function(@JsonKey(name: "success") bool? success, @JsonKey(name: "message") String? message, @JsonKey(name: "error") ErrorModel? error, @JsonKey(name: "data") TenderApprovalsStateData? data) $default,) {final _that = this; +@optionalTypeArgs TResult when(TResult Function(@JsonKey(name: 'success') bool? success, @JsonKey(name: 'message') String? message, @JsonKey(name: 'error') ErrorModel? error, @JsonKey(name: 'data') TenderApprovalsStateData? data) $default,) {final _that = this; switch (_that) { case _TenderApprovalsStateResponse(): return $default(_that.success,_that.message,_that.error,_that.data);case _: @@ -221,7 +221,7 @@ return $default(_that.success,_that.message,_that.error,_that.data);case _: /// } /// ``` -@optionalTypeArgs TResult? whenOrNull(TResult? Function(@JsonKey(name: "success") bool? success, @JsonKey(name: "message") String? message, @JsonKey(name: "error") ErrorModel? error, @JsonKey(name: "data") TenderApprovalsStateData? data)? $default,) {final _that = this; +@optionalTypeArgs TResult? whenOrNull(TResult? Function(@JsonKey(name: 'success') bool? success, @JsonKey(name: 'message') String? message, @JsonKey(name: 'error') ErrorModel? error, @JsonKey(name: 'data') TenderApprovalsStateData? data)? $default,) {final _that = this; switch (_that) { case _TenderApprovalsStateResponse() when $default != null: return $default(_that.success,_that.message,_that.error,_that.data);case _: @@ -236,13 +236,13 @@ return $default(_that.success,_that.message,_that.error,_that.data);case _: @JsonSerializable(explicitToJson: true) class _TenderApprovalsStateResponse implements TenderApprovalsStateResponse { - const _TenderApprovalsStateResponse({@JsonKey(name: "success") required this.success, @JsonKey(name: "message") required this.message, @JsonKey(name: "error") this.error, @JsonKey(name: "data") this.data}); + const _TenderApprovalsStateResponse({@JsonKey(name: 'success') required this.success, @JsonKey(name: 'message') required this.message, @JsonKey(name: 'error') this.error, @JsonKey(name: 'data') this.data}); factory _TenderApprovalsStateResponse.fromJson(Map json) => _$TenderApprovalsStateResponseFromJson(json); -@override@JsonKey(name: "success") final bool? success; -@override@JsonKey(name: "message") final String? message; -@override@JsonKey(name: "error") final ErrorModel? error; -@override@JsonKey(name: "data") final TenderApprovalsStateData? data; +@override@JsonKey(name: 'success') final bool? success; +@override@JsonKey(name: 'message') final String? message; +@override@JsonKey(name: 'error') final ErrorModel? error; +@override@JsonKey(name: 'data') final TenderApprovalsStateData? data; /// Create a copy of TenderApprovalsStateResponse /// with the given fields replaced by the non-null parameter values. @@ -277,7 +277,7 @@ abstract mixin class _$TenderApprovalsStateResponseCopyWith<$Res> implements $Te factory _$TenderApprovalsStateResponseCopyWith(_TenderApprovalsStateResponse value, $Res Function(_TenderApprovalsStateResponse) _then) = __$TenderApprovalsStateResponseCopyWithImpl; @override @useResult $Res call({ -@JsonKey(name: "success") bool? success,@JsonKey(name: "message") String? message,@JsonKey(name: "error") ErrorModel? error,@JsonKey(name: "data") TenderApprovalsStateData? data +@JsonKey(name: 'success') bool? success,@JsonKey(name: 'message') String? message,@JsonKey(name: 'error') ErrorModel? error,@JsonKey(name: 'data') TenderApprovalsStateData? data }); diff --git a/lib/data/services/profile_service.dart b/lib/data/services/profile_service.dart index b23a4e1..58012d5 100644 --- a/lib/data/services/profile_service.dart +++ b/lib/data/services/profile_service.dart @@ -1,3 +1,4 @@ +import 'package:tm_app/data/services/model/company_profile_response/company_profile_response.dart'; import 'package:tm_app/data/services/model/profile_response/profile_response.dart'; import '../../core/network/network_manager.dart'; @@ -17,4 +18,13 @@ class ProfileService { ); return result; } + + Future> getCompanyProfile() async { + final result = await _networkManager.makeRequest( + '/api/v1/companies', + method: 'GET', + (json) => CompanyProfileResponse.fromJson(json), + ); + return result; + } } diff --git a/lib/view_models/profile_view_model.dart b/lib/view_models/profile_view_model.dart index 5776751..579b892 100644 --- a/lib/view_models/profile_view_model.dart +++ b/lib/view_models/profile_view_model.dart @@ -1,5 +1,7 @@ import 'package:flutter/material.dart'; import 'package:tm_app/data/repositories/auth_repository.dart'; +import 'package:tm_app/data/services/model/company_profile_data/company_profile_data.dart'; +import 'package:tm_app/data/services/model/company_profile_response/company_profile_response.dart'; import 'package:tm_app/data/services/model/profile_data/profile_data.dart'; import '../core/utils/result.dart'; @@ -16,18 +18,20 @@ class ProfileViewModel with ChangeNotifier { required AuthRepository authRepository, }) : _profileRepository = profileRepository, _authRepository = authRepository { - getProfile(); + getCompanyProfile(); } bool _isLoading = false; String? _errorMessage; ProfileData? _profileData; + CompanyProfileData? _companyProfileData; bool _loggedOut = false; bool get isLoading => _isLoading; bool get loggedOut => _loggedOut; String? get errorMessage => _errorMessage; ProfileData? get profileData => _profileData; + CompanyProfileData? get companyProfileData => _companyProfileData; Future getProfile() async { _isLoading = true; @@ -50,6 +54,27 @@ class ProfileViewModel with ChangeNotifier { notifyListeners(); } + Future getCompanyProfile() async { + _isLoading = true; + _errorMessage = null; + notifyListeners(); + + final result = await _profileRepository.getCompanyProfile(); + + switch (result) { + case Ok(): + _companyProfileData = result.value.data; + break; + case Error(): + _errorMessage = result.error.toString(); + break; + } + _isLoading = false; + notifyListeners(); + _errorMessage = null; + notifyListeners(); + } + Future localLogout() async { await _authRepository.localLogout(); _loggedOut = true; diff --git a/lib/views/profile/pages/m_profile_page.dart b/lib/views/profile/pages/m_profile_page.dart index 7f5364f..8b54fb3 100644 --- a/lib/views/profile/pages/m_profile_page.dart +++ b/lib/views/profile/pages/m_profile_page.dart @@ -75,23 +75,24 @@ class _MobileProfilePageState extends State { SizedBox(height: 36.0.h()), TitleDescription( title: 'Company Name', - description: 'Telecom Solutions GmbH', + description: viewModel.companyProfileData!.name!, ), TitleDescription( title: 'National ID', - description: '12345678901', + description: viewModel.companyProfileData!.id!, ), TitleDescription( title: 'Registration No.', - description: 'DE-55667788', + description: + viewModel.companyProfileData!.registrationNumber!, ), + TitleDescription(title: 'Business Type', description: '-'), TitleDescription( - title: 'Business Type', - description: 'Telecommunications', + title: 'Founded', + description: + viewModel.companyProfileData!.foundedYear!.toString(), ), - TitleDescription(title: 'Founded', description: '2010'), SizedBox(height: 32.0.h()), - Align( alignment: AlignmentDirectional.centerStart, child: Text( diff --git a/lib/views/your_tenders/widgets/approved_tenders.dart b/lib/views/your_tenders/widgets/approved_tenders.dart index 29defa3..dc1b00e 100644 --- a/lib/views/your_tenders/widgets/approved_tenders.dart +++ b/lib/views/your_tenders/widgets/approved_tenders.dart @@ -11,51 +11,54 @@ class ApprovedTenders extends StatelessWidget { @override Widget build(BuildContext context) { - return ListView.builder( - padding: const EdgeInsets.only(top: 20), - itemCount: approvedTenders.data!.length, - itemBuilder: (context, index) { - final tender = approvedTenders.data![index]; - return TenderCard( - date: tender.createdAt!.toString(), - title: tender.tender!.title!, - description: tender.tender!.description!, - location: tender.tender!.countryCode!, - countryFlag: AssetsManager.seFlag, - status: tender.status, - projectStatus: tender.tender!.status!, - backgroundColor: - tender.status == 'Won' - ? AppColors.green0 - : tender.status == 'approved' - ? AppColors.grey0 - : AppColors.red0.withValues(alpha: 0.2), - borderColor: - tender.status == 'Won' - ? AppColors.green10 - : tender.status == 'approved' - ? AppColors.grey30 - : AppColors.red0, - statusIcon: - tender.status == 'Won' - ? AssetsManager.tickCircle - : tender.status == 'approved' - ? null - : AssetsManager.closeCircle, - statusCardColor: - tender.status == 'Won' - ? AppColors.green20 - : tender.status == 'approved' - ? AppColors.green20 - : AppColors.red0, - statusTextColor: - tender.status == 'Won' - ? AppColors.green30 - : tender.status == 'approved' - ? AppColors.green30 - : AppColors.red10, + return approvedTenders.data == null + ? const Center(child: Text('No data available')) + : ListView.builder( + padding: const EdgeInsets.only(top: 20), + itemCount: approvedTenders.data!.length, + itemBuilder: (context, index) { + final tender = approvedTenders.data![index]; + return TenderCard( + date: tender.createdAt!.toString(), + title: tender.tender!.title!, + description: tender.tender!.description!, + location: tender.tender!.countryCode!, + countryFlag: AssetsManager.seFlag, + status: tender.status, + countryCode: tender.tender!.countryCode!, + projectStatus: tender.tender!.status!, + backgroundColor: + tender.status == 'Won' + ? AppColors.green0 + : tender.status == 'approved' + ? AppColors.grey0 + : AppColors.red0.withValues(alpha: 0.2), + borderColor: + tender.status == 'Won' + ? AppColors.green10 + : tender.status == 'approved' + ? AppColors.grey30 + : AppColors.red0, + statusIcon: + tender.status == 'Won' + ? AssetsManager.tickCircle + : tender.status == 'approved' + ? null + : AssetsManager.closeCircle, + statusCardColor: + tender.status == 'Won' + ? AppColors.green20 + : tender.status == 'approved' + ? AppColors.green20 + : AppColors.red0, + statusTextColor: + tender.status == 'Won' + ? AppColors.green30 + : tender.status == 'approved' + ? AppColors.green30 + : AppColors.red10, + ); + }, ); - }, - ); } } diff --git a/lib/views/your_tenders/widgets/tender_card.dart b/lib/views/your_tenders/widgets/tender_card.dart index ccc869e..c8dee35 100644 --- a/lib/views/your_tenders/widgets/tender_card.dart +++ b/lib/views/your_tenders/widgets/tender_card.dart @@ -1,3 +1,4 @@ +import 'package:country_flags/country_flags.dart'; import 'package:flutter/material.dart'; import 'package:flutter_svg/svg.dart'; @@ -18,12 +19,14 @@ class TenderCard extends StatelessWidget { final String? statusIcon; final Color? statusCardColor; final Color? statusTextColor; + final String countryCode; const TenderCard({ required this.date, required this.title, required this.description, required this.location, + required this.countryCode, this.countryFlag = 'assets/icons/SE.png', this.status = 'Completed', this.projectStatus = 'Self Control', @@ -155,10 +158,13 @@ class TenderCard extends StatelessWidget { ), SizedBox(width: 8.0.w()), // Country flag - Image.asset( - countryFlag, + SizedBox( width: 32.0.w(), height: 21.0.h(), + child: CountryFlag.fromCountryCode( + countryCode, + shape: RoundedRectangle(4), + ), ), ], ), diff --git a/lib/views/your_tenders/widgets/tenders_submitted.dart b/lib/views/your_tenders/widgets/tenders_submitted.dart index e9a5b34..725d21c 100644 --- a/lib/views/your_tenders/widgets/tenders_submitted.dart +++ b/lib/views/your_tenders/widgets/tenders_submitted.dart @@ -23,6 +23,7 @@ class TendersSubmitted extends StatelessWidget { location: tender.location, countryFlag: tender.countryFlag, status: tender.status, + countryCode: '', projectStatus: tender.projectStatus, backgroundColor: tender.status == 'Won'