TF-34 Add domain layer MailboxDashBoard for fix bug mock data user

This commit is contained in:
dab246
2021-08-25 13:13:04 +07:00
committed by Dat H. Pham
parent cae1252fc8
commit 4393caf179
2 changed files with 43 additions and 0 deletions
@@ -0,0 +1,21 @@
import 'package:core/core.dart';
import 'package:core/presentation/state/failure.dart';
import 'package:model/model.dart';
class GetUserProfileSuccess extends UIState {
final UserProfile userProfile;
GetUserProfileSuccess(this.userProfile);
@override
List<Object> get props => [];
}
class GetUserProfileFailure extends FeatureFailure {
final exception;
GetUserProfileFailure(this.exception);
@override
List<Object> get props => [exception];
}
@@ -0,0 +1,22 @@
import 'dart:core';
import 'package:core/core.dart';
import 'package:dartz/dartz.dart';
import 'package:tmail_ui_user/features/login/domain/repository/credential_repository.dart';
import 'package:tmail_ui_user/features/mailbox_dashboard/domain/state/get_user_profile_state.dart';
class GetUserProfileInteractor {
final CredentialRepository credentialRepository;
GetUserProfileInteractor(this.credentialRepository);
Stream<Either<Failure, Success>> execute() async* {
try {
yield Right<Failure, Success>(UIState.loading);
final userProfile = await credentialRepository.getUserProfile();
yield Right(GetUserProfileSuccess(userProfile));
} catch (exception) {
yield Left(GetUserProfileFailure(exception));
}
}
}