54 lines
2.0 KiB
Dart
54 lines
2.0 KiB
Dart
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)),
|
|
];
|