feat: sync payment methods
This commit is contained in:
@@ -8,17 +8,18 @@ part 'payment_methods_event.dart';
|
||||
part 'payment_methods_state.dart';
|
||||
part 'payment_methods_bloc.freezed.dart';
|
||||
|
||||
class PaymentMethodsBloc extends Bloc<PaymentMethodsEvent, PaymentMethodsState> {
|
||||
class PaymentMethodsBloc
|
||||
extends Bloc<PaymentMethodsEvent, PaymentMethodsState> {
|
||||
final PaymentMethodsRemoteDatasource datasource;
|
||||
|
||||
|
||||
PaymentMethodsBloc(this.datasource) : super(const _Initial()) {
|
||||
on<_FetchPaymentMethods>((event, emit) async {
|
||||
emit(const _Loading());
|
||||
final response = await datasource.getPaymentMethods();
|
||||
response.fold(
|
||||
(l) => emit(_Error(l)),
|
||||
(r) => emit(_Loaded(r.data ?? [])),
|
||||
(r) => emit(_Loaded(r.data?.paymentMethods ?? [])),
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user