Skip to content

Commit

Permalink
Merge branch 'master' into IOCOM-866-tags
Browse files Browse the repository at this point in the history
  • Loading branch information
adelloste authored Jan 30, 2024
2 parents 46c9b1a + 644157f commit 2207604
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { walletPaymentCalculateFees } from "../../../store/actions/networking";
import { handleWalletPaymentCalculateFees } from "../handleWalletPaymentCalculateFees";
import { CalculateFeeRequest } from "../../../../../../../definitions/pagopa/ecommerce/CalculateFeeRequest";
import { selectWalletPaymentSessionToken } from "../../../store/selectors";
import { preferredLanguageSelector } from "../../../../../../store/reducers/persistedPreferences";

describe("Test handleWalletPaymentCalculateFees saga", () => {
const calculateFeesPayload: CalculateFeeRequest & {
Expand Down Expand Up @@ -41,6 +42,8 @@ describe("Test handleWalletPaymentCalculateFees saga", () => {
walletPaymentCalculateFees.request(calculateFeesPayload)
)
.next()
.select(preferredLanguageSelector)
.next("IT")
.select(selectWalletPaymentSessionToken)
.next(T_SESSION_TOKEN)
.call(
Expand All @@ -66,6 +69,8 @@ describe("Test handleWalletPaymentCalculateFees saga", () => {
walletPaymentCalculateFees.request(calculateFeesPayload)
)
.next()
.select(preferredLanguageSelector)
.next("IT")
.select(selectWalletPaymentSessionToken)
.next(T_SESSION_TOKEN)
.call(
Expand Down Expand Up @@ -94,6 +99,8 @@ describe("Test handleWalletPaymentCalculateFees saga", () => {
walletPaymentCalculateFees.request(calculateFeesPayload)
)
.next()
.select(preferredLanguageSelector)
.next("IT")
.select(selectWalletPaymentSessionToken)
.next(T_SESSION_TOKEN)
.call(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import * as E from "fp-ts/lib/Either";
import * as O from "fp-ts/lib/Option";
import { pipe } from "fp-ts/lib/function";
import { toUpper } from "lodash";
import { call, put, select } from "typed-redux-saga/macro";
import { ActionType } from "typesafe-actions";
import { CalculateFeeResponse } from "../../../../../../definitions/pagopa/ecommerce/CalculateFeeResponse";
import { preferredLanguageSelector } from "../../../../../store/reducers/persistedPreferences";
import { SagaCallReturnType } from "../../../../../types/utils";
import { getGenericError, getNetworkError } from "../../../../../utils/errors";
import { readablePrivacyReport } from "../../../../../utils/reporters";
Expand All @@ -19,6 +22,13 @@ export function* handleWalletPaymentCalculateFees(
action: ActionType<(typeof walletPaymentCalculateFees)["request"]>
) {
try {
const preferredLanguageOption = yield* select(preferredLanguageSelector);
const language = pipe(
preferredLanguageOption,
O.map(toUpper),
O.getOrElse(() => "IT")
);

const sessionToken = yield* getOrFetchWalletSessionToken();

if (sessionToken === undefined) {
Expand All @@ -30,7 +40,7 @@ export function* handleWalletPaymentCalculateFees(
return;
}

const { paymentMethodId, ...body } = action.payload;
const { paymentMethodId, ...body } = { ...action.payload, language };
const calculateFeesRequest = calculateFees({
eCommerceSessionToken: sessionToken,
id: paymentMethodId,
Expand Down

0 comments on commit 2207604

Please sign in to comment.