v1.1.27 deactivate customer
This commit is contained in:
@@ -6,6 +6,8 @@ import 'package:bloc/bloc.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
|
||||
import '../../service/customer_service.dart';
|
||||
|
||||
part 'account_event.dart';
|
||||
part 'account_state.dart';
|
||||
|
||||
@@ -21,6 +23,7 @@ class AccountBloc extends Bloc<AccountEvent, AccountState> {
|
||||
on<AccountLogout>(_onLogout);
|
||||
on<AccountGetTrainees>(_onGetTrainees);
|
||||
on<AccountSelectTrainee>(_onSelectTrainees);
|
||||
on<DeleteAccount>(_onDeleteAccount);
|
||||
}
|
||||
|
||||
void _load() {
|
||||
@@ -56,6 +59,24 @@ class AccountBloc extends Bloc<AccountEvent, AccountState> {
|
||||
emit(AccountReady());
|
||||
}
|
||||
|
||||
void _onDeleteAccount(DeleteAccount event, Emitter<AccountState> emit) async {
|
||||
emit(AccountLoading());
|
||||
await Cache().logout();
|
||||
customerRepository.customer = event.customer;
|
||||
customerRepository.emptyTrainees();
|
||||
loggedIn = false;
|
||||
|
||||
//delete local store
|
||||
int customerId = customerRepository.customer!.customerId!;
|
||||
await Cache().deleteCustomerId(customerId);
|
||||
customerRepository.customer = null;
|
||||
|
||||
// deactivate user
|
||||
await CustomerApi().deactivateCustomer(customerId);
|
||||
|
||||
emit(AccountReady());
|
||||
}
|
||||
|
||||
void _onGetTrainees(AccountGetTrainees event, Emitter<AccountState> emit) async {
|
||||
emit(AccountLoading());
|
||||
await customerRepository.getTrainees();
|
||||
|
||||
@@ -20,6 +20,14 @@ class AccountLogin extends AccountEvent {
|
||||
const AccountLogin();
|
||||
}
|
||||
|
||||
class DeleteAccount extends AccountEvent {
|
||||
final Customer customer;
|
||||
|
||||
const DeleteAccount ({required this.customer});
|
||||
@override
|
||||
List<Object> get props => [customer];
|
||||
}
|
||||
|
||||
class AccountLogInFinished extends AccountEvent {
|
||||
final Customer customer;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user