-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: [PE-628] CGN - deactivate button on expired card detail screen (#…
…5992) ## Short description Add deactivate button on expired card detail screen ## List of changes proposed in this pull request - add i18n key - refactor original deactivation button into hook + component - create a new button for deactivating (original section not modified to not disrupt existing validations) ## How to test [figma](https://www.figma.com/design/yOoBGDr1MJpa0LY5lDUFSd/IOapp_CartaGiovaniNazionale?node-id=6171-28477&t=1CciY9sMGswSE3dR-4) - you need to have an expired CGN card in your wallet (possibile steps to reproduce) - login into the app - go to wallet - add CGN - at this point the server should return { "status" : "EXPIRED", ... } on GET /api/v1/cgn/status - login into the app - go to you wallet - go to CGN card - at this point there should be an alert stating that the card is expired and the new button for deactivating the card should be there --------- Co-authored-by: Alessandro <[email protected]> Co-authored-by: mariateresaventura <[email protected]>
- Loading branch information
1 parent
ea4c74b
commit 10738b2
Showing
6 changed files
with
157 additions
and
107 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
48 changes: 3 additions & 45 deletions
48
ts/features/bonus/cgn/components/detail/CgnUnsubscribe.tsx
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,50 @@ | ||
import { useEffect, useRef } from "react"; | ||
import { Alert } from "react-native"; | ||
import { IOToast } from "@pagopa/io-app-design-system"; | ||
import { useIODispatch, useIOSelector } from "../../../../store/hooks"; | ||
import { cgnUnsubscribeSelector } from "../store/reducers/unsubscribe"; | ||
import I18n from "../../../../i18n"; | ||
import { cgnUnsubscribe } from "../store/actions/unsubscribe"; | ||
import { isError, isReady } from "../../../../common/model/RemoteValue"; | ||
import { cgnDetails } from "../store/actions/details"; | ||
import { useIONavigation } from "../../../../navigation/params/AppParamsList"; | ||
|
||
export function useCgnUnsubscribe() { | ||
const dispatch = useIODispatch(); | ||
const navigation = useIONavigation(); | ||
const unsubscriptionStatus = useIOSelector(cgnUnsubscribeSelector); | ||
const isFirstRender = useRef<boolean>(true); | ||
|
||
const requestUnsubscription = () => { | ||
Alert.alert( | ||
I18n.t("bonus.cgn.activation.deactivate.alert.title"), | ||
I18n.t("bonus.cgn.activation.deactivate.alert.message"), | ||
[ | ||
{ | ||
text: I18n.t("global.buttons.cancel"), | ||
style: "cancel" | ||
}, | ||
{ | ||
text: I18n.t("global.buttons.deactivate"), | ||
onPress: () => dispatch(cgnUnsubscribe.request()) | ||
} | ||
] | ||
); | ||
}; | ||
|
||
useEffect(() => { | ||
if (isReady(unsubscriptionStatus)) { | ||
navigation.goBack(); | ||
dispatch(cgnDetails.request()); | ||
IOToast.success(I18n.t("bonus.cgn.activation.deactivate.toast")); | ||
} | ||
if (isError(unsubscriptionStatus) && !isFirstRender.current) { | ||
IOToast.error(I18n.t("global.genericError")); | ||
} | ||
|
||
// eslint-disable-next-line functional/immutable-data | ||
isFirstRender.current = false; | ||
}, [unsubscriptionStatus, navigation, dispatch]); | ||
|
||
return { requestUnsubscription }; | ||
} |
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