Skip to content

Commit bc8e2f4

Browse files
authored
feat: [IOBP-1898] Add show merchants button when webview url present (#7323)
## Short description This PR introduces a new "Show merchants" secondary action to the IDPay initiative details screen, provided the `webViewUrl` is included in the response, allowing users to view participating merchants that redirect to an external link specified in the backend response. ## List of changes proposed in this pull request - Added a "Show merchants" (`secondaryCta`) button to the initiative details footer, which opens the initiative's `webViewUrl` in the browser if available; otherwise, it displays an error toast. ## How to test With the dev-server started, verify that a bonus of type `DISCOUNT` with the `webViewUrl` property filled shows a secondary CTA that redirects to the provided URL as an external link, opening the device's browser. ## Preview https://github.com/user-attachments/assets/84c79f6b-ca21-46d0-a9d4-196f2bd253c9
1 parent 5071ff3 commit bc8e2f4

File tree

3 files changed

+30
-7
lines changed

3 files changed

+30
-7
lines changed

locales/en/index.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5648,7 +5648,8 @@
56485648
"body": "If you forget the code, reset it under Settings > Security.",
56495649
"cta": "Ok, chiudi"
56505650
}
5651-
}
5651+
},
5652+
"secondaryCta": "Show merchants"
56525653
},
56535654
"beneficiaryDetails": {
56545655
"infobox": {

locales/it/index.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5629,6 +5629,7 @@
56295629
"generateBarcode": "Genera un codice sconto"
56305630
},
56315631
"authorizeButton": "Usa il bonus",
5632+
"secondaryCta": "Mostra esercenti",
56325633
"addExpenseButton": "Aggiungi spesa",
56335634
"IDPayCode": {
56345635
"banner": {

ts/features/idpay/details/screens/IdPayInitiativeDetailsScreen.tsx

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {
33
ContentWrapper,
44
H6,
55
IOButton,
6+
IOToast,
67
Pictogram,
78
VSpacer
89
} from "@pagopa/io-app-design-system";
@@ -13,7 +14,7 @@ import { sequenceS } from "fp-ts/lib/Apply";
1314
import * as O from "fp-ts/lib/Option";
1415
import { pipe } from "fp-ts/lib/function";
1516
import { useCallback } from "react";
16-
import { View } from "react-native";
17+
import { Linking, View } from "react-native";
1718
import Animated, { LinearTransition } from "react-native-reanimated";
1819
import I18n from "i18next";
1920
import { ServiceId } from "../../../../../definitions/backend/ServiceId";
@@ -315,6 +316,14 @@ const IdPayInitiativeDetailsScreenComponent = () => {
315316
)
316317
);
317318

319+
const handleOnShowMerchants = () => {
320+
if (!initiative.webViewUrl) {
321+
IOToast.error(I18n.t("global.genericError"));
322+
return;
323+
}
324+
void Linking.openURL(initiative.webViewUrl);
325+
};
326+
318327
const getInitiativeFooterProps = (
319328
rewardType?: InitiativeRewardTypeEnum
320329
): IOScrollViewActions | undefined => {
@@ -326,12 +335,24 @@ const IdPayInitiativeDetailsScreenComponent = () => {
326335
) {
327336
return;
328337
}
338+
const useBonusButton = {
339+
label: I18n.t("idpay.initiative.discountDetails.authorizeButton"),
340+
onPress: discountBottomSheet.present
341+
};
342+
const showMerchantsButton = {
343+
label: I18n.t("idpay.initiative.discountDetails.secondaryCta"),
344+
onPress: handleOnShowMerchants
345+
};
346+
if (!initiative.webViewUrl) {
347+
return {
348+
type: "SingleButton",
349+
primary: useBonusButton
350+
};
351+
}
329352
return {
330-
type: "SingleButton",
331-
primary: {
332-
label: I18n.t("idpay.initiative.discountDetails.authorizeButton"),
333-
onPress: discountBottomSheet.present
334-
}
353+
type: "TwoButtons",
354+
primary: useBonusButton,
355+
secondary: showMerchantsButton
335356
};
336357
}
337358
case InitiativeRewardTypeEnum.EXPENSE:

0 commit comments

Comments
 (0)