redesigned payment page + a lot of fixes
This commit is contained in:
@@ -7,16 +7,20 @@ import 'package:pshared/data/mapper/payment/intent/payment.dart';
|
||||
import 'package:pshared/models/payment/intent.dart';
|
||||
import 'package:pshared/models/payment/quote/quotes.dart';
|
||||
import 'package:pshared/provider/organizations.dart';
|
||||
import 'package:pshared/provider/payment/auto_refresh.dart';
|
||||
import 'package:pshared/provider/resource.dart';
|
||||
import 'package:pshared/service/payment/multiple.dart';
|
||||
import 'package:pshared/utils/exception.dart';
|
||||
|
||||
|
||||
class MultiQuotationProvider extends ChangeNotifier {
|
||||
static const Duration _autoRefreshLead = Duration(seconds: 5);
|
||||
|
||||
OrganizationsProvider? _organizations;
|
||||
String? _loadedOrganizationRef;
|
||||
|
||||
Resource<PaymentQuotes> _quotation = Resource(data: null);
|
||||
final AutoRefreshScheduler _autoRefresh = AutoRefreshScheduler();
|
||||
|
||||
List<PaymentIntent>? _lastIntents;
|
||||
bool _lastPreviewOnly = false;
|
||||
@@ -125,12 +129,32 @@ class MultiQuotationProvider extends ChangeNotifier {
|
||||
_lastPreviewOnly = false;
|
||||
_lastMetadata = null;
|
||||
_quotation = Resource(data: null);
|
||||
_syncAutoRefresh();
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void _setResource(Resource<PaymentQuotes> quotation) {
|
||||
_quotation = quotation;
|
||||
_syncAutoRefresh();
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void _syncAutoRefresh() {
|
||||
final scheduledAt = quoteExpiresAt?.subtract(_autoRefreshLead);
|
||||
_autoRefresh.setEnabled(true);
|
||||
_autoRefresh.sync(
|
||||
isLoading: isLoading,
|
||||
canRefresh: canRefresh,
|
||||
scheduledAt: scheduledAt,
|
||||
onRefresh: () async {
|
||||
await refreshQuotation();
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_autoRefresh.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user