redesigned payment page + a lot of fixes
This commit is contained in:
@@ -15,6 +15,7 @@ class PayoutRoutes {
|
||||
static const recipients = 'payout-recipients';
|
||||
static const invitations = 'payout-invitations';
|
||||
static const addRecipient = 'payout-add-recipient';
|
||||
static const editRecipient = 'payout-edit-recipient';
|
||||
static const payment = 'payout-payment';
|
||||
static const settings = 'payout-settings';
|
||||
static const reports = 'payout-reports';
|
||||
@@ -24,20 +25,21 @@ class PayoutRoutes {
|
||||
static const walletTopUp = 'payout-wallet-top-up';
|
||||
|
||||
static const paymentTypeQuery = 'paymentType';
|
||||
static const returnToQuery = 'returnTo';
|
||||
static const reportPaymentIdQuery = 'paymentId';
|
||||
|
||||
static const dashboardPath = '/dashboard';
|
||||
static const recipientsPath = '/dashboard/recipients';
|
||||
static const invitationsPath = '/dashboard/invitations';
|
||||
static const addRecipientPath = '/dashboard/recipients/add';
|
||||
static const paymentPath = '/dashboard/payment';
|
||||
static const settingsPath = '/dashboard/settings';
|
||||
static const reportsPath = '/dashboard/reports';
|
||||
static const reportPaymentPath = '/dashboard/reports/payment';
|
||||
static const methodsPath = '/dashboard/methods';
|
||||
static const editWalletPath = '/dashboard/methods/edit';
|
||||
static const walletTopUpPath = '/dashboard/wallet/top-up';
|
||||
static const recipientsPath = '/recipients';
|
||||
static const invitationsPath = '/invitations';
|
||||
static const addRecipientPath = '/recipients/add';
|
||||
static const editRecipientPath = '/recipients/edit';
|
||||
static const paymentPath = '/payment';
|
||||
static const settingsPath = '/settings';
|
||||
static const reportsPath = '/reports';
|
||||
static const reportPaymentPath = '/reports/payment';
|
||||
static const methodsPath = '/methods';
|
||||
static const editWalletPath = '/methods/edit';
|
||||
static const walletTopUpPath = '/wallet/top-up';
|
||||
|
||||
|
||||
static String nameFor(PayoutDestination destination) {
|
||||
switch (destination) {
|
||||
@@ -105,6 +107,8 @@ class PayoutRoutes {
|
||||
return PayoutDestination.invitations;
|
||||
case addRecipient:
|
||||
return PayoutDestination.addrecipient;
|
||||
case editRecipient:
|
||||
return PayoutDestination.addrecipient;
|
||||
case settings:
|
||||
return PayoutDestination.settings;
|
||||
case reports:
|
||||
@@ -122,11 +126,9 @@ class PayoutRoutes {
|
||||
|
||||
static Map<String, String> buildQueryParameters({
|
||||
PaymentType? paymentType,
|
||||
PayoutDestination? returnTo,
|
||||
}) {
|
||||
final params = <String, String>{
|
||||
if (paymentType != null) paymentTypeQuery: paymentType.name,
|
||||
if (returnTo != null) returnToQuery: nameFor(returnTo),
|
||||
};
|
||||
return params;
|
||||
}
|
||||
@@ -138,13 +140,6 @@ class PayoutRoutes {
|
||||
? null
|
||||
: PaymentType.values.firstWhereOrNull((type) => type.name == raw);
|
||||
|
||||
static PayoutDestination fallbackFromState(
|
||||
GoRouterState state, {
|
||||
PayoutDestination defaultDestination = PayoutDestination.dashboard,
|
||||
}) {
|
||||
final raw = state.uri.queryParameters[returnToQuery];
|
||||
return destinationFor(raw) ?? defaultDestination;
|
||||
}
|
||||
}
|
||||
|
||||
extension PayoutNavigation on BuildContext {
|
||||
@@ -154,25 +149,11 @@ extension PayoutNavigation on BuildContext {
|
||||
|
||||
void goToPayment({
|
||||
PaymentType? paymentType,
|
||||
PayoutDestination? returnTo,
|
||||
}) =>
|
||||
goNamed(
|
||||
PayoutRoutes.payment,
|
||||
queryParameters: PayoutRoutes.buildQueryParameters(
|
||||
paymentType: paymentType,
|
||||
returnTo: returnTo,
|
||||
),
|
||||
);
|
||||
|
||||
void pushToPayment({
|
||||
PaymentType? paymentType,
|
||||
PayoutDestination? returnTo,
|
||||
}) =>
|
||||
pushNamed(
|
||||
PayoutRoutes.payment,
|
||||
queryParameters: PayoutRoutes.buildQueryParameters(
|
||||
paymentType: paymentType,
|
||||
returnTo: returnTo,
|
||||
),
|
||||
);
|
||||
|
||||
@@ -190,13 +171,7 @@ extension PayoutNavigation on BuildContext {
|
||||
},
|
||||
);
|
||||
|
||||
void pushToWalletTopUp({PayoutDestination? returnTo}) => pushNamed(
|
||||
PayoutRoutes.walletTopUp,
|
||||
queryParameters: PayoutRoutes.buildQueryParameters(returnTo: returnTo),
|
||||
);
|
||||
void pushToWalletTopUp() => pushNamed(PayoutRoutes.walletTopUp);
|
||||
|
||||
void pushToEditWallet({PayoutDestination? returnTo}) => pushNamed(
|
||||
PayoutRoutes.editWallet,
|
||||
queryParameters: PayoutRoutes.buildQueryParameters(returnTo: returnTo),
|
||||
);
|
||||
void pushToEditWallet() => pushNamed(PayoutRoutes.editWallet);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user