Top Up Balance logic and Added fixes for routing
This commit is contained in:
112
frontend/pweb/lib/app/router/payout_routes.dart
Normal file
112
frontend/pweb/lib/app/router/payout_routes.dart
Normal file
@@ -0,0 +1,112 @@
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
import 'package:pweb/widgets/sidebar/destinations.dart';
|
||||
|
||||
|
||||
class PayoutRoutes {
|
||||
static const dashboard = 'dashboard';
|
||||
static const sendPayout = payment;
|
||||
static const recipients = 'payout-recipients';
|
||||
static const addRecipient = 'payout-add-recipient';
|
||||
static const payment = 'payout-payment';
|
||||
static const settings = 'payout-settings';
|
||||
static const reports = 'payout-reports';
|
||||
static const methods = 'payout-methods';
|
||||
static const editWallet = 'payout-edit-wallet';
|
||||
static const walletTopUp = 'payout-wallet-top-up';
|
||||
|
||||
static const dashboardPath = '/dashboard';
|
||||
static const recipientsPath = '/dashboard/recipients';
|
||||
static const addRecipientPath = '/dashboard/recipients/add';
|
||||
static const paymentPath = '/dashboard/payment';
|
||||
static const settingsPath = '/dashboard/settings';
|
||||
static const reportsPath = '/dashboard/reports';
|
||||
static const methodsPath = '/dashboard/methods';
|
||||
static const editWalletPath = '/dashboard/methods/edit';
|
||||
static const walletTopUpPath = '/dashboard/wallet/top-up';
|
||||
|
||||
static String nameFor(PayoutDestination destination) {
|
||||
switch (destination) {
|
||||
case PayoutDestination.dashboard:
|
||||
return dashboard;
|
||||
case PayoutDestination.sendPayout:
|
||||
return payment;
|
||||
case PayoutDestination.recipients:
|
||||
return recipients;
|
||||
case PayoutDestination.addrecipient:
|
||||
return addRecipient;
|
||||
case PayoutDestination.payment:
|
||||
return payment;
|
||||
case PayoutDestination.settings:
|
||||
return settings;
|
||||
case PayoutDestination.reports:
|
||||
return reports;
|
||||
case PayoutDestination.methods:
|
||||
return methods;
|
||||
case PayoutDestination.editwallet:
|
||||
return editWallet;
|
||||
case PayoutDestination.walletTopUp:
|
||||
return walletTopUp;
|
||||
}
|
||||
}
|
||||
|
||||
static String pathFor(PayoutDestination destination) {
|
||||
switch (destination) {
|
||||
case PayoutDestination.dashboard:
|
||||
return dashboardPath;
|
||||
case PayoutDestination.sendPayout:
|
||||
return paymentPath;
|
||||
case PayoutDestination.recipients:
|
||||
return recipientsPath;
|
||||
case PayoutDestination.addrecipient:
|
||||
return addRecipientPath;
|
||||
case PayoutDestination.payment:
|
||||
return paymentPath;
|
||||
case PayoutDestination.settings:
|
||||
return settingsPath;
|
||||
case PayoutDestination.reports:
|
||||
return reportsPath;
|
||||
case PayoutDestination.methods:
|
||||
return methodsPath;
|
||||
case PayoutDestination.editwallet:
|
||||
return editWalletPath;
|
||||
case PayoutDestination.walletTopUp:
|
||||
return walletTopUpPath;
|
||||
}
|
||||
}
|
||||
|
||||
static PayoutDestination? destinationFor(String? routeName) {
|
||||
switch (routeName) {
|
||||
case dashboard:
|
||||
return PayoutDestination.dashboard;
|
||||
case sendPayout:
|
||||
return PayoutDestination.payment;
|
||||
case recipients:
|
||||
return PayoutDestination.recipients;
|
||||
case addRecipient:
|
||||
return PayoutDestination.addrecipient;
|
||||
case payment:
|
||||
return PayoutDestination.payment;
|
||||
case settings:
|
||||
return PayoutDestination.settings;
|
||||
case reports:
|
||||
return PayoutDestination.reports;
|
||||
case methods:
|
||||
return PayoutDestination.methods;
|
||||
case editWallet:
|
||||
return PayoutDestination.editwallet;
|
||||
case walletTopUp:
|
||||
return PayoutDestination.walletTopUp;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension PayoutNavigation on BuildContext {
|
||||
void goToPayout(PayoutDestination destination) => goNamed(PayoutRoutes.nameFor(destination));
|
||||
|
||||
void pushToPayout(PayoutDestination destination) => pushNamed(PayoutRoutes.nameFor(destination));
|
||||
}
|
||||
Reference in New Issue
Block a user