Skip to content

Commit

Permalink
chore: addressed review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
Hantex9 committed Jan 23, 2024
1 parent 9db9856 commit 5ca24f7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
import * as pot from "@pagopa/ts-commons/lib/pot";
import {
NavigatorScreenParams,
RouteProp,
useNavigation,
useRoute
} from "@react-navigation/native";
import { RouteProp, useNavigation, useRoute } from "@react-navigation/native";
import * as O from "fp-ts/lib/Option";
import { pipe } from "fp-ts/lib/function";
import React from "react";
Expand Down Expand Up @@ -65,9 +60,8 @@ const WalletPaymentOutcomeScreen = () => {

const handleClose = () => {
if (paymentStartRoute) {
navigation.navigate(paymentStartRoute.routeName as keyof AppParamsList, {
screen:
paymentStartRoute.routeKey as keyof NavigatorScreenParams<AppParamsList>["screen"]
navigation.navigate(paymentStartRoute.routeName, {
screen: paymentStartRoute.routeKey
});
return;
}
Expand Down
28 changes: 17 additions & 11 deletions ts/features/walletV3/payment/store/reducers/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import _ from "lodash";
import * as pot from "@pagopa/ts-commons/lib/pot";
import * as O from "fp-ts/lib/Option";
import { NavigatorScreenParams } from "@react-navigation/native";
import { getType } from "typesafe-actions";
import { pipe } from "fp-ts/lib/function";
import { sequenceS } from "fp-ts/lib/Apply";
import { Bundle } from "../../../../../../definitions/pagopa/ecommerce/Bundle";
import { NewTransactionResponse } from "../../../../../../definitions/pagopa/ecommerce/NewTransactionResponse";
import { PaymentRequestsGetResponse } from "../../../../../../definitions/pagopa/ecommerce/PaymentRequestsGetResponse";
Expand All @@ -28,6 +31,7 @@ import { WalletInfo } from "../../../../../../definitions/pagopa/walletv3/Wallet
import { WalletPaymentFailure } from "../../types/failure";
import { RptId } from "../../../../../../definitions/pagopa/ecommerce/RptId";
import NavigationService from "../../../../../navigation/NavigationService";
import { AppParamsList } from "../../../../../navigation/params/AppParamsList";

export type WalletPaymentState = {
rptId?: RptId;
Expand All @@ -46,8 +50,8 @@ export type WalletPaymentState = {
>;
authorizationUrl: pot.Pot<string, NetworkError>;
startRoute?: {
routeName: string;
routeKey: string;
routeName: keyof AppParamsList;
routeKey: keyof NavigatorScreenParams<AppParamsList>["screen"];
};
};

Expand All @@ -69,15 +73,17 @@ const reducer = (
): WalletPaymentState => {
switch (action.type) {
case getType(walletPaymentInitState):
const currentRouteName = NavigationService.getCurrentRouteName();
const currentRouteKey = NavigationService.getCurrentRouteKey();
const startRoute =
currentRouteKey && currentRouteName
? {
routeName: currentRouteName,
routeKey: currentRouteKey
}
: undefined;
const startRoute = pipe(
sequenceS(O.Monad)({
routeName: O.fromNullable(
NavigationService.getCurrentRouteName() as keyof AppParamsList
),
routeKey: O.fromNullable(
NavigationService.getCurrentRouteKey() as keyof NavigatorScreenParams<AppParamsList>["screen"]
)
}),
O.toUndefined
);
return {
...INITIAL_STATE,
startRoute
Expand Down

0 comments on commit 5ca24f7

Please sign in to comment.