fix(personal-data): send all required fields in PUT and autofill form
This commit is contained in:
@@ -7,9 +7,11 @@ part 'update_user_request_dto.g.dart';
|
|||||||
@freezed
|
@freezed
|
||||||
abstract class UpdateUserRequestDto with _$UpdateUserRequestDto {
|
abstract class UpdateUserRequestDto with _$UpdateUserRequestDto {
|
||||||
const factory UpdateUserRequestDto({
|
const factory UpdateUserRequestDto({
|
||||||
String? firstName,
|
required String id,
|
||||||
String? lastName,
|
required String firstName,
|
||||||
String? phone,
|
required String lastName,
|
||||||
|
required String phone,
|
||||||
|
required String language,
|
||||||
}) = _UpdateUserRequestDto;
|
}) = _UpdateUserRequestDto;
|
||||||
|
|
||||||
factory UpdateUserRequestDto.fromJson(Map<String, dynamic> json) =>
|
factory UpdateUserRequestDto.fromJson(Map<String, dynamic> json) =>
|
||||||
@@ -18,8 +20,10 @@ abstract class UpdateUserRequestDto with _$UpdateUserRequestDto {
|
|||||||
|
|
||||||
extension UpdateUserRequestDtoMapper on UpdateUserRequestEntity {
|
extension UpdateUserRequestDtoMapper on UpdateUserRequestEntity {
|
||||||
UpdateUserRequestDto toDto() => UpdateUserRequestDto(
|
UpdateUserRequestDto toDto() => UpdateUserRequestDto(
|
||||||
|
id: id,
|
||||||
firstName: firstName,
|
firstName: firstName,
|
||||||
lastName: lastName,
|
lastName: lastName,
|
||||||
phone: phone,
|
phone: phone,
|
||||||
|
language: language,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ T _$identity<T>(T value) => value;
|
|||||||
/// @nodoc
|
/// @nodoc
|
||||||
mixin _$UpdateUserRequestDto {
|
mixin _$UpdateUserRequestDto {
|
||||||
|
|
||||||
String? get firstName; String? get lastName; String? get phone;
|
String get id; String get firstName; String get lastName; String get phone; String get language;
|
||||||
/// Create a copy of UpdateUserRequestDto
|
/// Create a copy of UpdateUserRequestDto
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||||
@@ -28,16 +28,16 @@ $UpdateUserRequestDtoCopyWith<UpdateUserRequestDto> get copyWith => _$UpdateUser
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
bool operator ==(Object other) {
|
bool operator ==(Object other) {
|
||||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is UpdateUserRequestDto&&(identical(other.firstName, firstName) || other.firstName == firstName)&&(identical(other.lastName, lastName) || other.lastName == lastName)&&(identical(other.phone, phone) || other.phone == phone));
|
return identical(this, other) || (other.runtimeType == runtimeType&&other is UpdateUserRequestDto&&(identical(other.id, id) || other.id == id)&&(identical(other.firstName, firstName) || other.firstName == firstName)&&(identical(other.lastName, lastName) || other.lastName == lastName)&&(identical(other.phone, phone) || other.phone == phone)&&(identical(other.language, language) || other.language == language));
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||||
@override
|
@override
|
||||||
int get hashCode => Object.hash(runtimeType,firstName,lastName,phone);
|
int get hashCode => Object.hash(runtimeType,id,firstName,lastName,phone,language);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'UpdateUserRequestDto(firstName: $firstName, lastName: $lastName, phone: $phone)';
|
return 'UpdateUserRequestDto(id: $id, firstName: $firstName, lastName: $lastName, phone: $phone, language: $language)';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -48,7 +48,7 @@ abstract mixin class $UpdateUserRequestDtoCopyWith<$Res> {
|
|||||||
factory $UpdateUserRequestDtoCopyWith(UpdateUserRequestDto value, $Res Function(UpdateUserRequestDto) _then) = _$UpdateUserRequestDtoCopyWithImpl;
|
factory $UpdateUserRequestDtoCopyWith(UpdateUserRequestDto value, $Res Function(UpdateUserRequestDto) _then) = _$UpdateUserRequestDtoCopyWithImpl;
|
||||||
@useResult
|
@useResult
|
||||||
$Res call({
|
$Res call({
|
||||||
String? firstName, String? lastName, String? phone
|
String id, String firstName, String lastName, String phone, String language
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@@ -65,12 +65,14 @@ class _$UpdateUserRequestDtoCopyWithImpl<$Res>
|
|||||||
|
|
||||||
/// Create a copy of UpdateUserRequestDto
|
/// Create a copy of UpdateUserRequestDto
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
@pragma('vm:prefer-inline') @override $Res call({Object? firstName = freezed,Object? lastName = freezed,Object? phone = freezed,}) {
|
@pragma('vm:prefer-inline') @override $Res call({Object? id = null,Object? firstName = null,Object? lastName = null,Object? phone = null,Object? language = null,}) {
|
||||||
return _then(_self.copyWith(
|
return _then(_self.copyWith(
|
||||||
firstName: freezed == firstName ? _self.firstName : firstName // ignore: cast_nullable_to_non_nullable
|
id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
|
||||||
as String?,lastName: freezed == lastName ? _self.lastName : lastName // ignore: cast_nullable_to_non_nullable
|
as String,firstName: null == firstName ? _self.firstName : firstName // ignore: cast_nullable_to_non_nullable
|
||||||
as String?,phone: freezed == phone ? _self.phone : phone // ignore: cast_nullable_to_non_nullable
|
as String,lastName: null == lastName ? _self.lastName : lastName // ignore: cast_nullable_to_non_nullable
|
||||||
as String?,
|
as String,phone: null == phone ? _self.phone : phone // ignore: cast_nullable_to_non_nullable
|
||||||
|
as String,language: null == language ? _self.language : language // ignore: cast_nullable_to_non_nullable
|
||||||
|
as String,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -155,10 +157,10 @@ return $default(_that);case _:
|
|||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
|
|
||||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String? firstName, String? lastName, String? phone)? $default,{required TResult orElse(),}) {final _that = this;
|
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String id, String firstName, String lastName, String phone, String language)? $default,{required TResult orElse(),}) {final _that = this;
|
||||||
switch (_that) {
|
switch (_that) {
|
||||||
case _UpdateUserRequestDto() when $default != null:
|
case _UpdateUserRequestDto() when $default != null:
|
||||||
return $default(_that.firstName,_that.lastName,_that.phone);case _:
|
return $default(_that.id,_that.firstName,_that.lastName,_that.phone,_that.language);case _:
|
||||||
return orElse();
|
return orElse();
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -176,10 +178,10 @@ return $default(_that.firstName,_that.lastName,_that.phone);case _:
|
|||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
|
|
||||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String? firstName, String? lastName, String? phone) $default,) {final _that = this;
|
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String id, String firstName, String lastName, String phone, String language) $default,) {final _that = this;
|
||||||
switch (_that) {
|
switch (_that) {
|
||||||
case _UpdateUserRequestDto():
|
case _UpdateUserRequestDto():
|
||||||
return $default(_that.firstName,_that.lastName,_that.phone);case _:
|
return $default(_that.id,_that.firstName,_that.lastName,_that.phone,_that.language);case _:
|
||||||
throw StateError('Unexpected subclass');
|
throw StateError('Unexpected subclass');
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -196,10 +198,10 @@ return $default(_that.firstName,_that.lastName,_that.phone);case _:
|
|||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
|
|
||||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String? firstName, String? lastName, String? phone)? $default,) {final _that = this;
|
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String id, String firstName, String lastName, String phone, String language)? $default,) {final _that = this;
|
||||||
switch (_that) {
|
switch (_that) {
|
||||||
case _UpdateUserRequestDto() when $default != null:
|
case _UpdateUserRequestDto() when $default != null:
|
||||||
return $default(_that.firstName,_that.lastName,_that.phone);case _:
|
return $default(_that.id,_that.firstName,_that.lastName,_that.phone,_that.language);case _:
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -211,12 +213,14 @@ return $default(_that.firstName,_that.lastName,_that.phone);case _:
|
|||||||
@JsonSerializable()
|
@JsonSerializable()
|
||||||
|
|
||||||
class _UpdateUserRequestDto implements UpdateUserRequestDto {
|
class _UpdateUserRequestDto implements UpdateUserRequestDto {
|
||||||
const _UpdateUserRequestDto({this.firstName, this.lastName, this.phone});
|
const _UpdateUserRequestDto({required this.id, required this.firstName, required this.lastName, required this.phone, required this.language});
|
||||||
factory _UpdateUserRequestDto.fromJson(Map<String, dynamic> json) => _$UpdateUserRequestDtoFromJson(json);
|
factory _UpdateUserRequestDto.fromJson(Map<String, dynamic> json) => _$UpdateUserRequestDtoFromJson(json);
|
||||||
|
|
||||||
@override final String? firstName;
|
@override final String id;
|
||||||
@override final String? lastName;
|
@override final String firstName;
|
||||||
@override final String? phone;
|
@override final String lastName;
|
||||||
|
@override final String phone;
|
||||||
|
@override final String language;
|
||||||
|
|
||||||
/// Create a copy of UpdateUserRequestDto
|
/// Create a copy of UpdateUserRequestDto
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
@@ -231,16 +235,16 @@ Map<String, dynamic> toJson() {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
bool operator ==(Object other) {
|
bool operator ==(Object other) {
|
||||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _UpdateUserRequestDto&&(identical(other.firstName, firstName) || other.firstName == firstName)&&(identical(other.lastName, lastName) || other.lastName == lastName)&&(identical(other.phone, phone) || other.phone == phone));
|
return identical(this, other) || (other.runtimeType == runtimeType&&other is _UpdateUserRequestDto&&(identical(other.id, id) || other.id == id)&&(identical(other.firstName, firstName) || other.firstName == firstName)&&(identical(other.lastName, lastName) || other.lastName == lastName)&&(identical(other.phone, phone) || other.phone == phone)&&(identical(other.language, language) || other.language == language));
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||||
@override
|
@override
|
||||||
int get hashCode => Object.hash(runtimeType,firstName,lastName,phone);
|
int get hashCode => Object.hash(runtimeType,id,firstName,lastName,phone,language);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'UpdateUserRequestDto(firstName: $firstName, lastName: $lastName, phone: $phone)';
|
return 'UpdateUserRequestDto(id: $id, firstName: $firstName, lastName: $lastName, phone: $phone, language: $language)';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -251,7 +255,7 @@ abstract mixin class _$UpdateUserRequestDtoCopyWith<$Res> implements $UpdateUser
|
|||||||
factory _$UpdateUserRequestDtoCopyWith(_UpdateUserRequestDto value, $Res Function(_UpdateUserRequestDto) _then) = __$UpdateUserRequestDtoCopyWithImpl;
|
factory _$UpdateUserRequestDtoCopyWith(_UpdateUserRequestDto value, $Res Function(_UpdateUserRequestDto) _then) = __$UpdateUserRequestDtoCopyWithImpl;
|
||||||
@override @useResult
|
@override @useResult
|
||||||
$Res call({
|
$Res call({
|
||||||
String? firstName, String? lastName, String? phone
|
String id, String firstName, String lastName, String phone, String language
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@@ -268,12 +272,14 @@ class __$UpdateUserRequestDtoCopyWithImpl<$Res>
|
|||||||
|
|
||||||
/// Create a copy of UpdateUserRequestDto
|
/// Create a copy of UpdateUserRequestDto
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
@override @pragma('vm:prefer-inline') $Res call({Object? firstName = freezed,Object? lastName = freezed,Object? phone = freezed,}) {
|
@override @pragma('vm:prefer-inline') $Res call({Object? id = null,Object? firstName = null,Object? lastName = null,Object? phone = null,Object? language = null,}) {
|
||||||
return _then(_UpdateUserRequestDto(
|
return _then(_UpdateUserRequestDto(
|
||||||
firstName: freezed == firstName ? _self.firstName : firstName // ignore: cast_nullable_to_non_nullable
|
id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
|
||||||
as String?,lastName: freezed == lastName ? _self.lastName : lastName // ignore: cast_nullable_to_non_nullable
|
as String,firstName: null == firstName ? _self.firstName : firstName // ignore: cast_nullable_to_non_nullable
|
||||||
as String?,phone: freezed == phone ? _self.phone : phone // ignore: cast_nullable_to_non_nullable
|
as String,lastName: null == lastName ? _self.lastName : lastName // ignore: cast_nullable_to_non_nullable
|
||||||
as String?,
|
as String,phone: null == phone ? _self.phone : phone // ignore: cast_nullable_to_non_nullable
|
||||||
|
as String,language: null == language ? _self.language : language // ignore: cast_nullable_to_non_nullable
|
||||||
|
as String,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,15 +9,19 @@ part of 'update_user_request_dto.dart';
|
|||||||
_UpdateUserRequestDto _$UpdateUserRequestDtoFromJson(
|
_UpdateUserRequestDto _$UpdateUserRequestDtoFromJson(
|
||||||
Map<String, dynamic> json,
|
Map<String, dynamic> json,
|
||||||
) => _UpdateUserRequestDto(
|
) => _UpdateUserRequestDto(
|
||||||
firstName: json['firstName'] as String?,
|
id: json['id'] as String,
|
||||||
lastName: json['lastName'] as String?,
|
firstName: json['firstName'] as String,
|
||||||
phone: json['phone'] as String?,
|
lastName: json['lastName'] as String,
|
||||||
|
phone: json['phone'] as String,
|
||||||
|
language: json['language'] as String,
|
||||||
);
|
);
|
||||||
|
|
||||||
Map<String, dynamic> _$UpdateUserRequestDtoToJson(
|
Map<String, dynamic> _$UpdateUserRequestDtoToJson(
|
||||||
_UpdateUserRequestDto instance,
|
_UpdateUserRequestDto instance,
|
||||||
) => <String, dynamic>{
|
) => <String, dynamic>{
|
||||||
|
'id': instance.id,
|
||||||
'firstName': instance.firstName,
|
'firstName': instance.firstName,
|
||||||
'lastName': instance.lastName,
|
'lastName': instance.lastName,
|
||||||
'phone': instance.phone,
|
'phone': instance.phone,
|
||||||
|
'language': instance.language,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -5,8 +5,10 @@ part 'update_user_request_entity.freezed.dart';
|
|||||||
@freezed
|
@freezed
|
||||||
abstract class UpdateUserRequestEntity with _$UpdateUserRequestEntity {
|
abstract class UpdateUserRequestEntity with _$UpdateUserRequestEntity {
|
||||||
const factory UpdateUserRequestEntity({
|
const factory UpdateUserRequestEntity({
|
||||||
String? firstName,
|
required String id,
|
||||||
String? lastName,
|
required String firstName,
|
||||||
String? phone,
|
required String lastName,
|
||||||
|
required String phone,
|
||||||
|
required String language,
|
||||||
}) = _UpdateUserRequestEntity;
|
}) = _UpdateUserRequestEntity;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ T _$identity<T>(T value) => value;
|
|||||||
/// @nodoc
|
/// @nodoc
|
||||||
mixin _$UpdateUserRequestEntity {
|
mixin _$UpdateUserRequestEntity {
|
||||||
|
|
||||||
String? get firstName; String? get lastName; String? get phone;
|
String get id; String get firstName; String get lastName; String get phone; String get language;
|
||||||
/// Create a copy of UpdateUserRequestEntity
|
/// Create a copy of UpdateUserRequestEntity
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||||
@@ -25,16 +25,16 @@ $UpdateUserRequestEntityCopyWith<UpdateUserRequestEntity> get copyWith => _$Upda
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
bool operator ==(Object other) {
|
bool operator ==(Object other) {
|
||||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is UpdateUserRequestEntity&&(identical(other.firstName, firstName) || other.firstName == firstName)&&(identical(other.lastName, lastName) || other.lastName == lastName)&&(identical(other.phone, phone) || other.phone == phone));
|
return identical(this, other) || (other.runtimeType == runtimeType&&other is UpdateUserRequestEntity&&(identical(other.id, id) || other.id == id)&&(identical(other.firstName, firstName) || other.firstName == firstName)&&(identical(other.lastName, lastName) || other.lastName == lastName)&&(identical(other.phone, phone) || other.phone == phone)&&(identical(other.language, language) || other.language == language));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
int get hashCode => Object.hash(runtimeType,firstName,lastName,phone);
|
int get hashCode => Object.hash(runtimeType,id,firstName,lastName,phone,language);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'UpdateUserRequestEntity(firstName: $firstName, lastName: $lastName, phone: $phone)';
|
return 'UpdateUserRequestEntity(id: $id, firstName: $firstName, lastName: $lastName, phone: $phone, language: $language)';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -45,7 +45,7 @@ abstract mixin class $UpdateUserRequestEntityCopyWith<$Res> {
|
|||||||
factory $UpdateUserRequestEntityCopyWith(UpdateUserRequestEntity value, $Res Function(UpdateUserRequestEntity) _then) = _$UpdateUserRequestEntityCopyWithImpl;
|
factory $UpdateUserRequestEntityCopyWith(UpdateUserRequestEntity value, $Res Function(UpdateUserRequestEntity) _then) = _$UpdateUserRequestEntityCopyWithImpl;
|
||||||
@useResult
|
@useResult
|
||||||
$Res call({
|
$Res call({
|
||||||
String? firstName, String? lastName, String? phone
|
String id, String firstName, String lastName, String phone, String language
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@@ -62,12 +62,14 @@ class _$UpdateUserRequestEntityCopyWithImpl<$Res>
|
|||||||
|
|
||||||
/// Create a copy of UpdateUserRequestEntity
|
/// Create a copy of UpdateUserRequestEntity
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
@pragma('vm:prefer-inline') @override $Res call({Object? firstName = freezed,Object? lastName = freezed,Object? phone = freezed,}) {
|
@pragma('vm:prefer-inline') @override $Res call({Object? id = null,Object? firstName = null,Object? lastName = null,Object? phone = null,Object? language = null,}) {
|
||||||
return _then(_self.copyWith(
|
return _then(_self.copyWith(
|
||||||
firstName: freezed == firstName ? _self.firstName : firstName // ignore: cast_nullable_to_non_nullable
|
id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
|
||||||
as String?,lastName: freezed == lastName ? _self.lastName : lastName // ignore: cast_nullable_to_non_nullable
|
as String,firstName: null == firstName ? _self.firstName : firstName // ignore: cast_nullable_to_non_nullable
|
||||||
as String?,phone: freezed == phone ? _self.phone : phone // ignore: cast_nullable_to_non_nullable
|
as String,lastName: null == lastName ? _self.lastName : lastName // ignore: cast_nullable_to_non_nullable
|
||||||
as String?,
|
as String,phone: null == phone ? _self.phone : phone // ignore: cast_nullable_to_non_nullable
|
||||||
|
as String,language: null == language ? _self.language : language // ignore: cast_nullable_to_non_nullable
|
||||||
|
as String,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,10 +154,10 @@ return $default(_that);case _:
|
|||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
|
|
||||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String? firstName, String? lastName, String? phone)? $default,{required TResult orElse(),}) {final _that = this;
|
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String id, String firstName, String lastName, String phone, String language)? $default,{required TResult orElse(),}) {final _that = this;
|
||||||
switch (_that) {
|
switch (_that) {
|
||||||
case _UpdateUserRequestEntity() when $default != null:
|
case _UpdateUserRequestEntity() when $default != null:
|
||||||
return $default(_that.firstName,_that.lastName,_that.phone);case _:
|
return $default(_that.id,_that.firstName,_that.lastName,_that.phone,_that.language);case _:
|
||||||
return orElse();
|
return orElse();
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -173,10 +175,10 @@ return $default(_that.firstName,_that.lastName,_that.phone);case _:
|
|||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
|
|
||||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String? firstName, String? lastName, String? phone) $default,) {final _that = this;
|
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String id, String firstName, String lastName, String phone, String language) $default,) {final _that = this;
|
||||||
switch (_that) {
|
switch (_that) {
|
||||||
case _UpdateUserRequestEntity():
|
case _UpdateUserRequestEntity():
|
||||||
return $default(_that.firstName,_that.lastName,_that.phone);case _:
|
return $default(_that.id,_that.firstName,_that.lastName,_that.phone,_that.language);case _:
|
||||||
throw StateError('Unexpected subclass');
|
throw StateError('Unexpected subclass');
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -193,10 +195,10 @@ return $default(_that.firstName,_that.lastName,_that.phone);case _:
|
|||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
|
|
||||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String? firstName, String? lastName, String? phone)? $default,) {final _that = this;
|
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String id, String firstName, String lastName, String phone, String language)? $default,) {final _that = this;
|
||||||
switch (_that) {
|
switch (_that) {
|
||||||
case _UpdateUserRequestEntity() when $default != null:
|
case _UpdateUserRequestEntity() when $default != null:
|
||||||
return $default(_that.firstName,_that.lastName,_that.phone);case _:
|
return $default(_that.id,_that.firstName,_that.lastName,_that.phone,_that.language);case _:
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -208,12 +210,14 @@ return $default(_that.firstName,_that.lastName,_that.phone);case _:
|
|||||||
|
|
||||||
|
|
||||||
class _UpdateUserRequestEntity implements UpdateUserRequestEntity {
|
class _UpdateUserRequestEntity implements UpdateUserRequestEntity {
|
||||||
const _UpdateUserRequestEntity({this.firstName, this.lastName, this.phone});
|
const _UpdateUserRequestEntity({required this.id, required this.firstName, required this.lastName, required this.phone, required this.language});
|
||||||
|
|
||||||
|
|
||||||
@override final String? firstName;
|
@override final String id;
|
||||||
@override final String? lastName;
|
@override final String firstName;
|
||||||
@override final String? phone;
|
@override final String lastName;
|
||||||
|
@override final String phone;
|
||||||
|
@override final String language;
|
||||||
|
|
||||||
/// Create a copy of UpdateUserRequestEntity
|
/// Create a copy of UpdateUserRequestEntity
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
@@ -225,16 +229,16 @@ _$UpdateUserRequestEntityCopyWith<_UpdateUserRequestEntity> get copyWith => __$U
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
bool operator ==(Object other) {
|
bool operator ==(Object other) {
|
||||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _UpdateUserRequestEntity&&(identical(other.firstName, firstName) || other.firstName == firstName)&&(identical(other.lastName, lastName) || other.lastName == lastName)&&(identical(other.phone, phone) || other.phone == phone));
|
return identical(this, other) || (other.runtimeType == runtimeType&&other is _UpdateUserRequestEntity&&(identical(other.id, id) || other.id == id)&&(identical(other.firstName, firstName) || other.firstName == firstName)&&(identical(other.lastName, lastName) || other.lastName == lastName)&&(identical(other.phone, phone) || other.phone == phone)&&(identical(other.language, language) || other.language == language));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
int get hashCode => Object.hash(runtimeType,firstName,lastName,phone);
|
int get hashCode => Object.hash(runtimeType,id,firstName,lastName,phone,language);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'UpdateUserRequestEntity(firstName: $firstName, lastName: $lastName, phone: $phone)';
|
return 'UpdateUserRequestEntity(id: $id, firstName: $firstName, lastName: $lastName, phone: $phone, language: $language)';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -245,7 +249,7 @@ abstract mixin class _$UpdateUserRequestEntityCopyWith<$Res> implements $UpdateU
|
|||||||
factory _$UpdateUserRequestEntityCopyWith(_UpdateUserRequestEntity value, $Res Function(_UpdateUserRequestEntity) _then) = __$UpdateUserRequestEntityCopyWithImpl;
|
factory _$UpdateUserRequestEntityCopyWith(_UpdateUserRequestEntity value, $Res Function(_UpdateUserRequestEntity) _then) = __$UpdateUserRequestEntityCopyWithImpl;
|
||||||
@override @useResult
|
@override @useResult
|
||||||
$Res call({
|
$Res call({
|
||||||
String? firstName, String? lastName, String? phone
|
String id, String firstName, String lastName, String phone, String language
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@@ -262,12 +266,14 @@ class __$UpdateUserRequestEntityCopyWithImpl<$Res>
|
|||||||
|
|
||||||
/// Create a copy of UpdateUserRequestEntity
|
/// Create a copy of UpdateUserRequestEntity
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
@override @pragma('vm:prefer-inline') $Res call({Object? firstName = freezed,Object? lastName = freezed,Object? phone = freezed,}) {
|
@override @pragma('vm:prefer-inline') $Res call({Object? id = null,Object? firstName = null,Object? lastName = null,Object? phone = null,Object? language = null,}) {
|
||||||
return _then(_UpdateUserRequestEntity(
|
return _then(_UpdateUserRequestEntity(
|
||||||
firstName: freezed == firstName ? _self.firstName : firstName // ignore: cast_nullable_to_non_nullable
|
id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
|
||||||
as String?,lastName: freezed == lastName ? _self.lastName : lastName // ignore: cast_nullable_to_non_nullable
|
as String,firstName: null == firstName ? _self.firstName : firstName // ignore: cast_nullable_to_non_nullable
|
||||||
as String?,phone: freezed == phone ? _self.phone : phone // ignore: cast_nullable_to_non_nullable
|
as String,lastName: null == lastName ? _self.lastName : lastName // ignore: cast_nullable_to_non_nullable
|
||||||
as String?,
|
as String,phone: null == phone ? _self.phone : phone // ignore: cast_nullable_to_non_nullable
|
||||||
|
as String,language: null == language ? _self.language : language // ignore: cast_nullable_to_non_nullable
|
||||||
|
as String,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -45,7 +45,12 @@ class PersonalDataViewModel extends Notifier<PersonalDataViewState> {
|
|||||||
final user = await ref.read(userInfoProvider.future);
|
final user = await ref.read(userInfoProvider.future);
|
||||||
if (!ref.mounted) return;
|
if (!ref.mounted) return;
|
||||||
|
|
||||||
|
firstNameController.text = user.firstName;
|
||||||
|
lastNameController.text = user.lastName;
|
||||||
|
|
||||||
final parsed = SfPhoneNumber.tryParse(user.phone);
|
final parsed = SfPhoneNumber.tryParse(user.phone);
|
||||||
|
phoneController.text = parsed?.nationalNumber ?? user.phone;
|
||||||
|
|
||||||
state = state.copyWith(
|
state = state.copyWith(
|
||||||
user: user,
|
user: user,
|
||||||
isoCode: parsed?.isoCode ?? SfPhoneNumber.defaultIsoCode,
|
isoCode: parsed?.isoCode ?? SfPhoneNumber.defaultIsoCode,
|
||||||
@@ -65,10 +70,15 @@ class PersonalDataViewModel extends Notifier<PersonalDataViewState> {
|
|||||||
state = state.copyWith(isoCode: isoCode, errorMessage: '');
|
state = state.copyWith(isoCode: isoCode, errorMessage: '');
|
||||||
}
|
}
|
||||||
|
|
||||||
bool get _hasChanges =>
|
bool get _hasChanges {
|
||||||
firstNameController.text.trim().isNotEmpty ||
|
final user = state.user;
|
||||||
lastNameController.text.trim().isNotEmpty ||
|
if (user == null) return false;
|
||||||
phoneController.text.trim().isNotEmpty;
|
final parsed = SfPhoneNumber.tryParse(user.phone);
|
||||||
|
final originalPhone = parsed?.nationalNumber ?? user.phone;
|
||||||
|
return firstNameController.text.trim() != user.firstName ||
|
||||||
|
lastNameController.text.trim() != user.lastName ||
|
||||||
|
phoneController.text.trim() != originalPhone;
|
||||||
|
}
|
||||||
|
|
||||||
Future<void> updateUser() async {
|
Future<void> updateUser() async {
|
||||||
final user = state.user;
|
final user = state.user;
|
||||||
@@ -95,13 +105,15 @@ class PersonalDataViewModel extends Notifier<PersonalDataViewState> {
|
|||||||
);
|
);
|
||||||
|
|
||||||
final request = UpdateUserRequestEntity(
|
final request = UpdateUserRequestEntity(
|
||||||
|
id: user.id,
|
||||||
firstName: firstNameController.text.trim().isNotEmpty
|
firstName: firstNameController.text.trim().isNotEmpty
|
||||||
? firstNameController.text.trim()
|
? firstNameController.text.trim()
|
||||||
: null,
|
: user.firstName,
|
||||||
lastName: lastNameController.text.trim().isNotEmpty
|
lastName: lastNameController.text.trim().isNotEmpty
|
||||||
? lastNameController.text.trim()
|
? lastNameController.text.trim()
|
||||||
: null,
|
: user.lastName,
|
||||||
phone: fullPhone,
|
phone: fullPhone ?? user.phone,
|
||||||
|
language: user.language,
|
||||||
);
|
);
|
||||||
|
|
||||||
await _usersRepository.updateUser(userId: user.id, request: request);
|
await _usersRepository.updateUser(userId: user.id, request: request);
|
||||||
|
|||||||
Reference in New Issue
Block a user