Fixed issue with wallet form feild and made page selecor in dashboard into a router
This commit is contained in:
53
frontend/pweb/lib/app/router/payout_routes.dart
Normal file
53
frontend/pweb/lib/app/router/payout_routes.dart
Normal file
@@ -0,0 +1,53 @@
|
||||
import 'package:pweb/app/router/pages.dart';
|
||||
|
||||
import 'package:pweb/widgets/sidebar/destinations.dart';
|
||||
|
||||
|
||||
const _payoutBasePath = Pages.dashboard;
|
||||
|
||||
String payoutPath(PayoutDestination destination) {
|
||||
final base = routerPage(_payoutBasePath);
|
||||
switch (destination) {
|
||||
case PayoutDestination.dashboard:
|
||||
return base;
|
||||
case PayoutDestination.recipients:
|
||||
return '$base/recipients';
|
||||
case PayoutDestination.addrecipient:
|
||||
return '$base/recipients/add';
|
||||
case PayoutDestination.payment:
|
||||
return '$base/payment';
|
||||
case PayoutDestination.settings:
|
||||
return '$base/settings';
|
||||
case PayoutDestination.reports:
|
||||
return '$base/reports';
|
||||
case PayoutDestination.methods:
|
||||
return '$base/methods';
|
||||
case PayoutDestination.editwallet:
|
||||
return '$base/methods/edit';
|
||||
case PayoutDestination.sendPayout:
|
||||
return '$base/send';
|
||||
}
|
||||
}
|
||||
|
||||
PayoutDestination payoutDestinationFromLocation(String location) {
|
||||
final path = Uri.parse(location).path;
|
||||
|
||||
// Check longer paths first to avoid prefix collisions.
|
||||
for (final entry in _orderedRoutes) {
|
||||
if (path.startsWith(entry.value)) return entry.key;
|
||||
}
|
||||
|
||||
return PayoutDestination.dashboard;
|
||||
}
|
||||
|
||||
final List<MapEntry<PayoutDestination, String>> _orderedRoutes = [
|
||||
MapEntry(PayoutDestination.editwallet, payoutPath(PayoutDestination.editwallet)),
|
||||
MapEntry(PayoutDestination.addrecipient, payoutPath(PayoutDestination.addrecipient)),
|
||||
MapEntry(PayoutDestination.payment, payoutPath(PayoutDestination.payment)),
|
||||
MapEntry(PayoutDestination.recipients, payoutPath(PayoutDestination.recipients)),
|
||||
MapEntry(PayoutDestination.methods, payoutPath(PayoutDestination.methods)),
|
||||
MapEntry(PayoutDestination.reports, payoutPath(PayoutDestination.reports)),
|
||||
MapEntry(PayoutDestination.settings, payoutPath(PayoutDestination.settings)),
|
||||
MapEntry(PayoutDestination.sendPayout, payoutPath(PayoutDestination.sendPayout)),
|
||||
MapEntry(PayoutDestination.dashboard, payoutPath(PayoutDestination.dashboard)),
|
||||
];
|
||||
Reference in New Issue
Block a user