-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: [IOBP-236] Banner pay with CIE into IDPay discount initiative (#…
…5005) ##⚠️ This PR depends on #4983 and #4995 ## Short description This PR adds a `Banner` inside a discount initiative details if the user has already a CIE onboarded to his account. The banner is shown from the first time the user lands in the bonus detail, and remains visible until: 1. The user closes it via "X" close button 2. The user enables the initiative (either via banner or via toggle within the relevant section) ## List of changes proposed in this pull request - Added a new action preferences to dismiss the banner, the state is persisted on the device based on the initiativeId; - Added a new component `IdPayCodeCieBanner` where is handled all the business logic to show or not the banner ## How to test Open a discount initiative, the first time you open the detail you should see the banner. If you dismiss it, even restarting the app you should not see it anymore. ## Preview https://github.com/pagopa/io-app/assets/34343582/01245e66-b80f-4f72-94f9-5a7b87b37c1c --------- Co-authored-by: forrest57 <[email protected]> Co-authored-by: Federico Mastrini <[email protected]>
- Loading branch information
1 parent
40c3f6f
commit 2e90981
Showing
9 changed files
with
183 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
import * as React from "react"; | ||
import { VSpacer, Banner } from "@pagopa/io-app-design-system"; | ||
import { useNavigation } from "@react-navigation/native"; | ||
|
||
import I18n from "../../../../i18n"; | ||
import { useIODispatch, useIOSelector } from "../../../../store/hooks"; | ||
import { idpayInitiativeInstrumentsGet } from "../../configuration/store/actions"; | ||
import { showIdPayCodeBannerSelector } from "../store/selectors"; | ||
import { IdPayCodeParamsList } from "../navigation/params"; | ||
import { IdPayCodeRoutes } from "../navigation/routes"; | ||
import { IOStackNavigationProp } from "../../../../navigation/params/AppParamsList"; | ||
import { isLoadingDiscountInitiativeInstrumentsSelector } from "../../configuration/store"; | ||
import { idPayCodeCieBannerClose } from "../store/actions"; | ||
|
||
export type IdPayCodeCIEBannerParams = { | ||
initiativeId: string; | ||
}; | ||
|
||
const IdPayCodeCieBanner = ({ initiativeId }: IdPayCodeCIEBannerParams) => { | ||
const bannerViewRef = React.useRef(null); | ||
const navigation = | ||
useNavigation<IOStackNavigationProp<IdPayCodeParamsList>>(); | ||
const dispatch = useIODispatch(); | ||
const showBanner = useIOSelector(showIdPayCodeBannerSelector); | ||
const isLoadingInitiativeInstruments = useIOSelector( | ||
isLoadingDiscountInitiativeInstrumentsSelector | ||
); | ||
|
||
React.useEffect(() => { | ||
if (initiativeId) { | ||
dispatch( | ||
idpayInitiativeInstrumentsGet.request({ | ||
initiativeId | ||
}) | ||
); | ||
} | ||
}, [initiativeId, dispatch]); | ||
|
||
const handleOnCloseBanner = () => { | ||
dispatch(idPayCodeCieBannerClose({ initiativeId })); | ||
}; | ||
|
||
const handleNavigateToOnboardingStart = () => { | ||
navigation.navigate(IdPayCodeRoutes.IDPAY_CODE_MAIN, { | ||
screen: IdPayCodeRoutes.IDPAY_CODE_ONBOARDING, | ||
params: { | ||
initiativeId | ||
} | ||
}); | ||
}; | ||
|
||
if (showBanner && !isLoadingInitiativeInstruments) { | ||
return ( | ||
<> | ||
<Banner | ||
color="turquoise" | ||
pictogramName="cie" | ||
title={I18n.t( | ||
"idpay.initiative.discountDetails.IDPayCode.banner.title" | ||
)} | ||
size="big" | ||
content={I18n.t( | ||
"idpay.initiative.discountDetails.IDPayCode.banner.body" | ||
)} | ||
action={I18n.t( | ||
"idpay.initiative.discountDetails.IDPayCode.banner.action" | ||
)} | ||
onPress={handleNavigateToOnboardingStart} | ||
onClose={handleOnCloseBanner} | ||
labelClose={I18n.t( | ||
"idpay.initiative.discountDetails.IDPayCode.banner.close" | ||
)} | ||
viewRef={bannerViewRef} | ||
/> | ||
<VSpacer size={24} /> | ||
</> | ||
); | ||
} | ||
|
||
return <></>; | ||
}; | ||
|
||
export { IdPayCodeCieBanner }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters