TF-34 Add domain layer MailboxDashBoard for fix bug mock data user
This commit is contained in:
@@ -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));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user