verification before payment and email fixes
This commit is contained in:
@@ -17,6 +17,7 @@ class MultiplePayoutsController extends ChangeNotifier {
|
||||
MultiplePayoutsProvider? _provider;
|
||||
WalletsController? _wallets;
|
||||
_PickState _pickState = _PickState.idle;
|
||||
Exception? _uiError;
|
||||
|
||||
MultiplePayoutsController({
|
||||
required CsvInputService csvInput,
|
||||
@@ -46,7 +47,7 @@ class MultiplePayoutsController extends ChangeNotifier {
|
||||
String? get selectedFileName => _provider?.selectedFileName;
|
||||
List<CsvPayoutRow> get rows => _provider?.rows ?? const <CsvPayoutRow>[];
|
||||
int get sentCount => _provider?.sentCount ?? 0;
|
||||
Exception? get error => _provider?.error;
|
||||
Exception? get error => _uiError ?? _provider?.error;
|
||||
|
||||
bool get isQuoting => _provider?.isQuoting ?? false;
|
||||
bool get isSending => _provider?.isSending ?? false;
|
||||
@@ -71,15 +72,19 @@ class MultiplePayoutsController extends ChangeNotifier {
|
||||
Future<void> pickAndQuote() async {
|
||||
if (_pickState == _PickState.picking) return;
|
||||
final provider = _provider;
|
||||
if (provider == null) return;
|
||||
if (provider == null) {
|
||||
_setUiError(StateError('Multiple payouts provider is not ready'));
|
||||
return;
|
||||
}
|
||||
|
||||
_clearUiError();
|
||||
_pickState = _PickState.picking;
|
||||
try {
|
||||
final picked = await _csvInput.pickCsv();
|
||||
if (picked == null) return;
|
||||
final wallet = _selectedWallet;
|
||||
if (wallet == null) {
|
||||
provider.setError(StateError('Select source wallet first'));
|
||||
_setUiError(StateError('Select source wallet first'));
|
||||
return;
|
||||
}
|
||||
await provider.quoteFromCsv(
|
||||
@@ -88,7 +93,7 @@ class MultiplePayoutsController extends ChangeNotifier {
|
||||
sourceWallet: wallet,
|
||||
);
|
||||
} catch (e) {
|
||||
provider.setError(e);
|
||||
_setUiError(e);
|
||||
} finally {
|
||||
_pickState = _PickState.idle;
|
||||
}
|
||||
@@ -98,10 +103,16 @@ class MultiplePayoutsController extends ChangeNotifier {
|
||||
return _provider?.send() ?? const <Payment>[];
|
||||
}
|
||||
|
||||
Future<MultiplePayoutSendOutcome> sendAndStorePayments() async {
|
||||
final payments =
|
||||
await _provider?.sendAndStorePayments() ?? const <Payment>[];
|
||||
final hasError = _provider?.error != null;
|
||||
Future<MultiplePayoutSendOutcome> sendAndGetOutcome() async {
|
||||
_clearUiError();
|
||||
final provider = _provider;
|
||||
if (provider == null) {
|
||||
_setUiError(StateError('Multiple payouts provider is not ready'));
|
||||
return MultiplePayoutSendOutcome.failure;
|
||||
}
|
||||
|
||||
final payments = await provider.send();
|
||||
final hasError = provider.error != null;
|
||||
if (hasError || payments.isEmpty) {
|
||||
return MultiplePayoutSendOutcome.failure;
|
||||
}
|
||||
@@ -110,6 +121,7 @@ class MultiplePayoutsController extends ChangeNotifier {
|
||||
|
||||
void removeUploadedFile() {
|
||||
_provider?.removeUploadedFile();
|
||||
_clearUiError(notify: false);
|
||||
}
|
||||
|
||||
void _onProviderChanged() {
|
||||
@@ -122,6 +134,19 @@ class MultiplePayoutsController extends ChangeNotifier {
|
||||
|
||||
Wallet? get _selectedWallet => _wallets?.selectedWallet;
|
||||
|
||||
void _setUiError(Object error) {
|
||||
_uiError = error is Exception ? error : Exception(error.toString());
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void _clearUiError({bool notify = true}) {
|
||||
if (_uiError == null) return;
|
||||
_uiError = null;
|
||||
if (notify) {
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_provider?.removeListener(_onProviderChanged);
|
||||
|
||||
Reference in New Issue
Block a user