verification before payment and email fixes
This commit is contained in:
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:pshared/models/payment/operation.dart';
|
||||
|
||||
import 'package:pweb/models/load_more_state.dart';
|
||||
import 'package:pweb/pages/report/cards/items.dart';
|
||||
|
||||
import 'package:pweb/generated/i18n/app_localizations.dart';
|
||||
@@ -10,11 +11,15 @@ import 'package:pweb/generated/i18n/app_localizations.dart';
|
||||
class OperationsCardsList extends StatelessWidget {
|
||||
final List<OperationItem> operations;
|
||||
final ValueChanged<OperationItem>? onTap;
|
||||
final LoadMoreState loadMoreState;
|
||||
final VoidCallback? onLoadMore;
|
||||
|
||||
const OperationsCardsList({
|
||||
super.key,
|
||||
required this.operations,
|
||||
this.onTap,
|
||||
this.loadMoreState = LoadMoreState.hidden,
|
||||
this.onLoadMore,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -26,18 +31,42 @@ class OperationsCardsList extends StatelessWidget {
|
||||
onTap: onTap,
|
||||
);
|
||||
|
||||
if (operations.isEmpty) {
|
||||
return Expanded(
|
||||
child: Center(
|
||||
child: Text(
|
||||
loc.reportPaymentsEmpty,
|
||||
style: Theme.of(context).textTheme.bodyMedium,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
final extraItems = loadMoreState == LoadMoreState.hidden ? 0 : 1;
|
||||
return Expanded(
|
||||
child: operations.isEmpty
|
||||
? Center(
|
||||
child: Text(
|
||||
loc.reportPaymentsEmpty,
|
||||
style: Theme.of(context).textTheme.bodyMedium,
|
||||
child: ListView.builder(
|
||||
itemCount: items.length + extraItems,
|
||||
itemBuilder: (context, index) {
|
||||
if (index < items.length) {
|
||||
return items[index];
|
||||
}
|
||||
if (loadMoreState == LoadMoreState.loading) {
|
||||
return const Padding(
|
||||
padding: EdgeInsets.symmetric(vertical: 16),
|
||||
child: Center(child: CircularProgressIndicator()),
|
||||
);
|
||||
}
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 16),
|
||||
child: Center(
|
||||
child: TextButton(
|
||||
onPressed: onLoadMore,
|
||||
child: Text(loc.loadMore),
|
||||
),
|
||||
)
|
||||
: ListView.builder(
|
||||
itemCount: items.length,
|
||||
itemBuilder: (context, index) => items[index],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,16 +4,14 @@ import 'package:go_router/go_router.dart';
|
||||
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import 'package:pshared/models/payment/payment.dart';
|
||||
import 'package:pshared/models/payment/status.dart';
|
||||
import 'package:pshared/provider/payment/payments.dart';
|
||||
|
||||
import 'package:pweb/app/router/payout_routes.dart';
|
||||
import 'package:pweb/controllers/payment_details.dart';
|
||||
import 'package:pweb/pages/report/details/content.dart';
|
||||
import 'package:pweb/pages/report/details/states/error.dart';
|
||||
import 'package:pweb/pages/report/details/states/not_found.dart';
|
||||
import 'package:pweb/utils/report/download_act.dart';
|
||||
import 'package:pweb/utils/report/payment_mapper.dart';
|
||||
|
||||
import 'package:pweb/generated/i18n/app_localizations.dart';
|
||||
|
||||
@@ -26,39 +24,48 @@ class PaymentDetailsPage extends StatelessWidget {
|
||||
required this.paymentId,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ChangeNotifierProxyProvider<PaymentsProvider, PaymentDetailsController>(
|
||||
create: (_) => PaymentDetailsController(paymentId: paymentId),
|
||||
update: (_, payments, controller) => controller!
|
||||
..update(payments, paymentId),
|
||||
child: const _PaymentDetailsView(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _PaymentDetailsView extends StatelessWidget {
|
||||
const _PaymentDetailsView();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Consumer<PaymentsProvider>(
|
||||
builder: (context, provider, child) {
|
||||
child: Consumer<PaymentDetailsController>(
|
||||
builder: (context, controller, child) {
|
||||
final loc = AppLocalizations.of(context)!;
|
||||
if (provider.isLoading) {
|
||||
if (controller.isLoading) {
|
||||
return const Center(child: CircularProgressIndicator());
|
||||
}
|
||||
|
||||
if (provider.error != null) {
|
||||
if (controller.error != null) {
|
||||
return PaymentDetailsError(
|
||||
message: provider.error?.toString() ?? loc.noErrorInformation,
|
||||
onRetry: () => provider.refresh(),
|
||||
message: controller.error?.toString() ?? loc.noErrorInformation,
|
||||
onRetry: () => controller.refresh(),
|
||||
);
|
||||
}
|
||||
|
||||
final payment = _findPayment(provider.payments, paymentId);
|
||||
final payment = controller.payment;
|
||||
if (payment == null) {
|
||||
return PaymentDetailsNotFound(onBack: () => _handleBack(context));
|
||||
}
|
||||
|
||||
final status = statusFromPayment(payment);
|
||||
final paymentRef = payment.paymentRef ?? '';
|
||||
final canDownload = status == OperationStatus.success &&
|
||||
paymentRef.trim().isNotEmpty;
|
||||
|
||||
return PaymentDetailsContent(
|
||||
payment: payment,
|
||||
onBack: () => _handleBack(context),
|
||||
onDownloadAct: canDownload
|
||||
? () => downloadPaymentAct(context, paymentRef)
|
||||
onDownloadAct: controller.canDownload
|
||||
? () => downloadPaymentAct(context, payment.paymentRef ?? '')
|
||||
: null,
|
||||
);
|
||||
},
|
||||
@@ -66,16 +73,6 @@ class PaymentDetailsPage extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
Payment? _findPayment(List<Payment> payments, String paymentId) {
|
||||
final trimmed = paymentId.trim();
|
||||
if (trimmed.isEmpty) return null;
|
||||
for (final payment in payments) {
|
||||
if (payment.paymentRef == trimmed) return payment;
|
||||
if (payment.idempotencyKey == trimmed) return payment;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
void _handleBack(BuildContext context) {
|
||||
final router = GoRouter.of(context);
|
||||
if (router.canPop()) {
|
||||
|
||||
@@ -12,6 +12,7 @@ import 'package:pweb/controllers/report_operations.dart';
|
||||
import 'package:pweb/pages/report/table/filters.dart';
|
||||
import 'package:pweb/utils/report/payment_mapper.dart';
|
||||
import 'package:pweb/app/router/payout_routes.dart';
|
||||
import 'package:pweb/models/load_more_state.dart';
|
||||
|
||||
import 'package:pweb/generated/i18n/app_localizations.dart';
|
||||
|
||||
@@ -124,6 +125,11 @@ class _OperationHistoryView extends StatelessWidget {
|
||||
OperationsCardsList(
|
||||
operations: filteredOperations,
|
||||
onTap: (operation) => _openPaymentDetails(context, operation),
|
||||
loadMoreState: controller.loadMoreState,
|
||||
onLoadMore: controller.loadMoreState ==
|
||||
LoadMoreState.available
|
||||
? () => controller.loadMore()
|
||||
: null,
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user