Files
enaklo-flutter/lib/application/wallet/wallet_loader/wallet_loader_bloc.dart
T
efrilmandClaude Opus 5.5 f5e3075205 EnakPoint & EnakCoin wallet, PIN, outlet, order, community, reward
- 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>
2026-10-01 01:43:22 +07:00

48 lines
1.3 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 'wallet_loader_event.dart';
part 'wallet_loader_state.dart';
part 'wallet_loader_bloc.freezed.dart';
@injectable
class WalletLoaderBloc extends Bloc<WalletLoaderEvent, WalletLoaderState> {
final IWalletRepository _repository;
WalletLoaderBloc(this._repository) : super(WalletLoaderState.initial()) {
on<WalletLoaderEvent>(_onWalletLoaderEvent);
}
Future<void> _onWalletLoaderEvent(
WalletLoaderEvent event,
Emitter<WalletLoaderState> emit,
) {
return event.map(
fetched: (e) async {
emit(state.copyWith(isFetching: true, failureOption: none()));
final result = await _repository.getWallet();
final data = result.fold(
(f) => state.copyWith(failureOption: optionOf(f)),
(summary) => state.copyWith(summary: summary, hasLoaded: true),
);
emit(data.copyWith(isFetching: false));
},
coinBalanceUpdated: (e) async {
emit(
state.copyWith(
summary: state.summary.copyWith(coinBalance: e.coinBalance),
),
);
},
cleared: (e) async => emit(WalletLoaderState.initial()),
);
}
}