TF-34 Add data layer login for fix bug mock data user
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:model/model.dart';
|
||||
import 'package:tmail_ui_user/features/login/data/model/converter/presentation_email_address_converter.dart';
|
||||
|
||||
part 'presentation_account_response.g.dart';
|
||||
|
||||
@PresentationEmailAddressConverter()
|
||||
@JsonSerializable()
|
||||
class PresentationAccountResponse with EquatableMixin {
|
||||
final List<PresentationEmailAddress>? emails;
|
||||
final int preferredEmailIndex;
|
||||
final AccountType type;
|
||||
|
||||
PresentationAccountResponse(this.emails, this.preferredEmailIndex, this.type);
|
||||
|
||||
factory PresentationAccountResponse.fromJson(Map<String, dynamic> json) => _$PresentationAccountResponseFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => _$PresentationAccountResponseToJson(this);
|
||||
|
||||
@override
|
||||
List<Object?> get props => [emails, preferredEmailIndex, type];
|
||||
}
|
||||
|
||||
extension PresentationAccountResponseExtension on PresentationAccountResponse {
|
||||
PresentationAccount toPresentationAccount() {
|
||||
return PresentationAccount(emails ?? [], preferredEmailIndex, type);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:model/model.dart';
|
||||
import 'package:tmail_ui_user/features/login/data/model/converter/avatar_id_converter.dart';
|
||||
import 'package:tmail_ui_user/features/login/data/model/converter/avatar_id_nullable_converter.dart';
|
||||
import 'package:tmail_ui_user/features/login/data/model/converter/user_id_converter.dart';
|
||||
import 'package:tmail_ui_user/features/login/data/model/response/presentation_account_response.dart';
|
||||
import 'package:tmail_ui_user/features/login/data/utils/attribute.dart';
|
||||
|
||||
part 'user_profile_response.g.dart';
|
||||
|
||||
@AvatarIdNullableConverter()
|
||||
@AvatarIdConverter()
|
||||
@UserIdConverter()
|
||||
@JsonSerializable()
|
||||
class UserProfileResponse with EquatableMixin {
|
||||
|
||||
@JsonKey(name: Attribute.id, includeIfNull: false)
|
||||
final UserId id;
|
||||
@JsonKey(name: Attribute.firstname, includeIfNull: false)
|
||||
final String? firstName;
|
||||
@JsonKey(name: Attribute.lastname, includeIfNull: false)
|
||||
final String? lastName;
|
||||
@JsonKey(name: Attribute.job_title, includeIfNull: false)
|
||||
final String? jobTitle;
|
||||
@JsonKey(includeIfNull: false)
|
||||
final String? service;
|
||||
@JsonKey(name: Attribute.building_location, includeIfNull: false)
|
||||
final String? buildingLocation;
|
||||
@JsonKey(name: Attribute.office_location, includeIfNull: false)
|
||||
final String? officeLocation;
|
||||
@JsonKey(name: Attribute.main_phone, includeIfNull: false)
|
||||
final String? mainPhone;
|
||||
@JsonKey(includeIfNull: false)
|
||||
final String? description;
|
||||
@JsonKey(includeIfNull: false)
|
||||
final AvatarId? currentAvatar;
|
||||
@JsonKey(includeIfNull: false)
|
||||
final List<AvatarId>? avatars;
|
||||
@JsonKey(includeIfNull: false)
|
||||
final List<PresentationAccountResponse>? accounts;
|
||||
|
||||
UserProfileResponse(
|
||||
this.id,
|
||||
this.firstName,
|
||||
this.lastName,
|
||||
this.jobTitle,
|
||||
this.service,
|
||||
this.buildingLocation,
|
||||
this.officeLocation,
|
||||
this.mainPhone,
|
||||
this.description,
|
||||
this.currentAvatar,
|
||||
this.avatars,
|
||||
this.accounts
|
||||
);
|
||||
|
||||
factory UserProfileResponse.fromJson(Map<String, dynamic> json) => _$UserProfileResponseFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => _$UserProfileResponseToJson(this);
|
||||
|
||||
@override
|
||||
List<Object?> get props => [
|
||||
id,
|
||||
firstName,
|
||||
lastName,
|
||||
accounts,
|
||||
];
|
||||
}
|
||||
|
||||
extension UserProfileResponseExtension on UserProfileResponse {
|
||||
UserProfile toUserProfile() {
|
||||
return UserProfile(
|
||||
id,
|
||||
firstName ?? '',
|
||||
lastName ?? '',
|
||||
jobTitle ?? '',
|
||||
service ?? '',
|
||||
buildingLocation ?? '',
|
||||
officeLocation ?? '',
|
||||
mainPhone ?? '',
|
||||
description ?? '',
|
||||
currentAvatar ?? AvatarId.initial(),
|
||||
avatars ?? [],
|
||||
accounts != null ? accounts!.map((account) => account.toPresentationAccount()).toList() : []
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
import 'package:core/data/constants/constant.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:model/model.dart';
|
||||
import 'package:tmail_ui_user/features/login/data/model/converter/user_id_converter.dart';
|
||||
|
||||
part 'user_response.g.dart';
|
||||
|
||||
@UserIdConverter()
|
||||
@JsonSerializable()
|
||||
class UserResponse with EquatableMixin {
|
||||
|
||||
@JsonKey(name: Constant.userId)
|
||||
final UserId userId;
|
||||
@JsonKey(name: Constant.firstName)
|
||||
final String firstName;
|
||||
@JsonKey(name: Constant.lastName)
|
||||
final String lastName;
|
||||
|
||||
UserResponse(
|
||||
this.userId,
|
||||
this.firstName,
|
||||
this.lastName
|
||||
);
|
||||
|
||||
factory UserResponse.fromJson(Map<String, dynamic> json) => _$UserResponseFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => _$UserResponseToJson(this);
|
||||
|
||||
@override
|
||||
List<Object?> get props => [
|
||||
userId,
|
||||
firstName,
|
||||
lastName,
|
||||
];
|
||||
}
|
||||
|
||||
extension UserResponseExtension on UserResponse {
|
||||
User toUser() {
|
||||
return User(
|
||||
userId,
|
||||
firstName,
|
||||
lastName,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user