- Wallet EnakPoint & EnakCoin: beranda, riwayat, saldo kedaluwarsa, kode bayar, tukar EnakCoin, transfer - PIN (buat, ganti, lupa), outlet, riwayat order, game spin - Halaman community, webview, coming soon, dan ikon menu beranda baru - Redesign Reward Saya: kartu tiket, filter chip, detail kode + QR - Hapus customer point loader, menu, dan checkout lama - Base URL ke enaklo-pos-api.altru.id Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
41 lines
1.2 KiB
Dart
41 lines
1.2 KiB
Dart
import 'package:bloc/bloc.dart';
|
|
import 'package:dartz/dartz.dart';
|
|
import 'package:freezed_annotation/freezed_annotation.dart';
|
|
import 'package:injectable/injectable.dart';
|
|
|
|
import '../../../domain/wallet/wallet.dart';
|
|
|
|
part 'outlet_loader_event.dart';
|
|
part 'outlet_loader_state.dart';
|
|
part 'outlet_loader_bloc.freezed.dart';
|
|
|
|
@injectable
|
|
class OutletLoaderBloc extends Bloc<OutletLoaderEvent, OutletLoaderState> {
|
|
final IOutletRepository _repository;
|
|
|
|
OutletLoaderBloc(this._repository) : super(OutletLoaderState.initial()) {
|
|
on<OutletLoaderEvent>(_onOutletLoaderEvent);
|
|
}
|
|
|
|
Future<void> _onOutletLoaderEvent(
|
|
OutletLoaderEvent event,
|
|
Emitter<OutletLoaderState> emit,
|
|
) {
|
|
return event.map(
|
|
fetched: (e) async {
|
|
emit(state.copyWith(isFetching: true, failureOption: none()));
|
|
|
|
final result = await _repository.getOutlets();
|
|
|
|
final data = result.fold(
|
|
(f) => state.copyWith(failureOption: optionOf(f)),
|
|
(outlets) => state.copyWith(outlets: outlets, hasLoaded: true),
|
|
);
|
|
|
|
emit(data.copyWith(isFetching: false));
|
|
},
|
|
cleared: (e) async => emit(OutletLoaderState.initial()),
|
|
);
|
|
}
|
|
}
|