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
|
||||
abstract class UpdateUserRequestDto with _$UpdateUserRequestDto {
|
||||
const factory UpdateUserRequestDto({
|
||||
String? firstName,
|
||||
String? lastName,
|
||||
String? phone,
|
||||
required String id,
|
||||
required String firstName,
|
||||
required String lastName,
|
||||
required String phone,
|
||||
required String language,
|
||||
}) = _UpdateUserRequestDto;
|
||||
|
||||
factory UpdateUserRequestDto.fromJson(Map<String, dynamic> json) =>
|
||||
@@ -18,8 +20,10 @@ abstract class UpdateUserRequestDto with _$UpdateUserRequestDto {
|
||||
|
||||
extension UpdateUserRequestDtoMapper on UpdateUserRequestEntity {
|
||||
UpdateUserRequestDto toDto() => UpdateUserRequestDto(
|
||||
id: id,
|
||||
firstName: firstName,
|
||||
lastName: lastName,
|
||||
phone: phone,
|
||||
language: language,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ T _$identity<T>(T value) => value;
|
||||
/// @nodoc
|
||||
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
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@@ -28,16 +28,16 @@ $UpdateUserRequestDtoCopyWith<UpdateUserRequestDto> get copyWith => _$UpdateUser
|
||||
|
||||
@override
|
||||
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)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,firstName,lastName,phone);
|
||||
int get hashCode => Object.hash(runtimeType,id,firstName,lastName,phone,language);
|
||||
|
||||
@override
|
||||
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;
|
||||
@useResult
|
||||
$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
|
||||
/// 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(
|
||||
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?,phone: freezed == phone ? _self.phone : phone // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
|
||||
as String,firstName: null == firstName ? _self.firstName : firstName // ignore: cast_nullable_to_non_nullable
|
||||
as String,lastName: null == lastName ? _self.lastName : lastName // ignore: cast_nullable_to_non_nullable
|
||||
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) {
|
||||
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();
|
||||
|
||||
}
|
||||
@@ -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) {
|
||||
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');
|
||||
|
||||
}
|
||||
@@ -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) {
|
||||
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;
|
||||
|
||||
}
|
||||
@@ -211,12 +213,14 @@ return $default(_that.firstName,_that.lastName,_that.phone);case _:
|
||||
@JsonSerializable()
|
||||
|
||||
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);
|
||||
|
||||
@override final String? firstName;
|
||||
@override final String? lastName;
|
||||
@override final String? phone;
|
||||
@override final String id;
|
||||
@override final String firstName;
|
||||
@override final String lastName;
|
||||
@override final String phone;
|
||||
@override final String language;
|
||||
|
||||
/// Create a copy of UpdateUserRequestDto
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@@ -231,16 +235,16 @@ Map<String, dynamic> toJson() {
|
||||
|
||||
@override
|
||||
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)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,firstName,lastName,phone);
|
||||
int get hashCode => Object.hash(runtimeType,id,firstName,lastName,phone,language);
|
||||
|
||||
@override
|
||||
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;
|
||||
@override @useResult
|
||||
$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
|
||||
/// 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(
|
||||
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?,phone: freezed == phone ? _self.phone : phone // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
|
||||
as String,firstName: null == firstName ? _self.firstName : firstName // ignore: cast_nullable_to_non_nullable
|
||||
as String,lastName: null == lastName ? _self.lastName : lastName // ignore: cast_nullable_to_non_nullable
|
||||
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(
|
||||
Map<String, dynamic> json,
|
||||
) => _UpdateUserRequestDto(
|
||||
firstName: json['firstName'] as String?,
|
||||
lastName: json['lastName'] as String?,
|
||||
phone: json['phone'] as String?,
|
||||
id: json['id'] as String,
|
||||
firstName: json['firstName'] as String,
|
||||
lastName: json['lastName'] as String,
|
||||
phone: json['phone'] as String,
|
||||
language: json['language'] as String,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$UpdateUserRequestDtoToJson(
|
||||
_UpdateUserRequestDto instance,
|
||||
) => <String, dynamic>{
|
||||
'id': instance.id,
|
||||
'firstName': instance.firstName,
|
||||
'lastName': instance.lastName,
|
||||
'phone': instance.phone,
|
||||
'language': instance.language,
|
||||
};
|
||||
|
||||
@@ -5,8 +5,10 @@ part 'update_user_request_entity.freezed.dart';
|
||||
@freezed
|
||||
abstract class UpdateUserRequestEntity with _$UpdateUserRequestEntity {
|
||||
const factory UpdateUserRequestEntity({
|
||||
String? firstName,
|
||||
String? lastName,
|
||||
String? phone,
|
||||
required String id,
|
||||
required String firstName,
|
||||
required String lastName,
|
||||
required String phone,
|
||||
required String language,
|
||||
}) = _UpdateUserRequestEntity;
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ T _$identity<T>(T value) => value;
|
||||
/// @nodoc
|
||||
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
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@@ -25,16 +25,16 @@ $UpdateUserRequestEntityCopyWith<UpdateUserRequestEntity> get copyWith => _$Upda
|
||||
|
||||
@override
|
||||
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
|
||||
int get hashCode => Object.hash(runtimeType,firstName,lastName,phone);
|
||||
int get hashCode => Object.hash(runtimeType,id,firstName,lastName,phone,language);
|
||||
|
||||
@override
|
||||
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;
|
||||
@useResult
|
||||
$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
|
||||
/// 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(
|
||||
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?,phone: freezed == phone ? _self.phone : phone // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
|
||||
as String,firstName: null == firstName ? _self.firstName : firstName // ignore: cast_nullable_to_non_nullable
|
||||
as String,lastName: null == lastName ? _self.lastName : lastName // ignore: cast_nullable_to_non_nullable
|
||||
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) {
|
||||
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();
|
||||
|
||||
}
|
||||
@@ -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) {
|
||||
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');
|
||||
|
||||
}
|
||||
@@ -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) {
|
||||
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;
|
||||
|
||||
}
|
||||
@@ -208,12 +210,14 @@ return $default(_that.firstName,_that.lastName,_that.phone);case _:
|
||||
|
||||
|
||||
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? lastName;
|
||||
@override final String? phone;
|
||||
@override final String id;
|
||||
@override final String firstName;
|
||||
@override final String lastName;
|
||||
@override final String phone;
|
||||
@override final String language;
|
||||
|
||||
/// Create a copy of UpdateUserRequestEntity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@@ -225,16 +229,16 @@ _$UpdateUserRequestEntityCopyWith<_UpdateUserRequestEntity> get copyWith => __$U
|
||||
|
||||
@override
|
||||
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
|
||||
int get hashCode => Object.hash(runtimeType,firstName,lastName,phone);
|
||||
int get hashCode => Object.hash(runtimeType,id,firstName,lastName,phone,language);
|
||||
|
||||
@override
|
||||
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;
|
||||
@override @useResult
|
||||
$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
|
||||
/// 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(
|
||||
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?,phone: freezed == phone ? _self.phone : phone // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
|
||||
as String,firstName: null == firstName ? _self.firstName : firstName // ignore: cast_nullable_to_non_nullable
|
||||
as String,lastName: null == lastName ? _self.lastName : lastName // ignore: cast_nullable_to_non_nullable
|
||||
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);
|
||||
if (!ref.mounted) return;
|
||||
|
||||
firstNameController.text = user.firstName;
|
||||
lastNameController.text = user.lastName;
|
||||
|
||||
final parsed = SfPhoneNumber.tryParse(user.phone);
|
||||
phoneController.text = parsed?.nationalNumber ?? user.phone;
|
||||
|
||||
state = state.copyWith(
|
||||
user: user,
|
||||
isoCode: parsed?.isoCode ?? SfPhoneNumber.defaultIsoCode,
|
||||
@@ -65,10 +70,15 @@ class PersonalDataViewModel extends Notifier<PersonalDataViewState> {
|
||||
state = state.copyWith(isoCode: isoCode, errorMessage: '');
|
||||
}
|
||||
|
||||
bool get _hasChanges =>
|
||||
firstNameController.text.trim().isNotEmpty ||
|
||||
lastNameController.text.trim().isNotEmpty ||
|
||||
phoneController.text.trim().isNotEmpty;
|
||||
bool get _hasChanges {
|
||||
final user = state.user;
|
||||
if (user == null) return false;
|
||||
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 {
|
||||
final user = state.user;
|
||||
@@ -95,13 +105,15 @@ class PersonalDataViewModel extends Notifier<PersonalDataViewState> {
|
||||
);
|
||||
|
||||
final request = UpdateUserRequestEntity(
|
||||
id: user.id,
|
||||
firstName: firstNameController.text.trim().isNotEmpty
|
||||
? firstNameController.text.trim()
|
||||
: null,
|
||||
: user.firstName,
|
||||
lastName: lastNameController.text.trim().isNotEmpty
|
||||
? lastNameController.text.trim()
|
||||
: null,
|
||||
phone: fullPhone,
|
||||
: user.lastName,
|
||||
phone: fullPhone ?? user.phone,
|
||||
language: user.language,
|
||||
);
|
||||
|
||||
await _usersRepository.updateUser(userId: user.id, request: request);
|
||||
|
||||
Reference in New Issue
Block a user