diff --git a/locales/en/index.yml b/locales/en/index.yml index f43d94e4da7..01c6e626f84 100644 --- a/locales/en/index.yml +++ b/locales/en/index.yml @@ -1449,6 +1449,8 @@ bonus: activationPending: title: The bonus for your family has already been requested and is being activated. description: You will receive a message when it is activated. + underage: + title: "We're sorry. Only citizens of legal age can apply for the Bonus Vacanze" activation: loading: "We have forwarded your request to the Revenue Agency\nPlease wait." goToDetails: Show Bonus Vacanze diff --git a/locales/it/index.yml b/locales/it/index.yml index 3447fc96c67..85f5aeb6555 100644 --- a/locales/it/index.yml +++ b/locales/it/index.yml @@ -1481,6 +1481,8 @@ bonus: activationPending: title: Il bonus per il tuo nucleo familiare è già stato richiesto ed è in fase di attivazione. description: Riceverai un messaggio quando sarà attivato. + underage: + title: "Siamo spiacenti. Solo i cittadini maggiorenni possono richiedere il Bonus Vacanze" activation: loading: "Abbiamo inoltrato la tua richiesta a Agenzia delle Entrate\nTi preghiamo di attendere." goToDetails: Visualizza Bonus Vacanze diff --git a/ts/features/bonusVacanze/navigation/action.ts b/ts/features/bonusVacanze/navigation/action.ts index 4c521e61bb7..ecdc6299538 100644 --- a/ts/features/bonusVacanze/navigation/action.ts +++ b/ts/features/bonusVacanze/navigation/action.ts @@ -34,6 +34,11 @@ export const navigateToBonusActivationPending = () => routeName: BONUSVACANZE_ROUTES.ELIGIBILITY.PENDING }); +export const navigateToUnderage = () => + NavigationActions.navigate({ + routeName: BONUSVACANZE_ROUTES.ELIGIBILITY.UNDERAGE + }); + export const navigateToAvailableBonusScreen = () => NavigationActions.navigate({ routeName: BONUSVACANZE_ROUTES.BONUS_AVAILABLE_LIST diff --git a/ts/features/bonusVacanze/navigation/navigator.ts b/ts/features/bonusVacanze/navigation/navigator.ts index 63ece9a1452..0c48418baeb 100644 --- a/ts/features/bonusVacanze/navigation/navigator.ts +++ b/ts/features/bonusVacanze/navigation/navigator.ts @@ -14,6 +14,7 @@ import IseeNotAvailableScreen from "../screens/eligibility/isee/IseeNotAvailable import IseeNotEligibleScreen from "../screens/eligibility/isee/IseeNotEligibleScreen"; import LoadBonusEligibilityScreen from "../screens/eligibility/LoadBonusEligibilityScreen"; import TimeoutEligibilityCheckInfoScreen from "../screens/eligibility/TimeoutEligibilityCheckInfoScreen"; +import UnderageScreen from "../screens/eligibility/UnderageScreen"; import BONUSVACANZE_ROUTES from "./routes"; const BonusVacanzeNavigator = createStackNavigator( @@ -45,6 +46,9 @@ const BonusVacanzeNavigator = createStackNavigator( [BONUSVACANZE_ROUTES.ELIGIBILITY.PENDING]: { screen: BonusActivationPending }, + [BONUSVACANZE_ROUTES.ELIGIBILITY.UNDERAGE]: { + screen: UnderageScreen + }, [BONUSVACANZE_ROUTES.ACTIVATION.LOADING]: { screen: LoadActivateBonusScreen }, diff --git a/ts/features/bonusVacanze/navigation/routes.ts b/ts/features/bonusVacanze/navigation/routes.ts index 8b663ebc1a5..87d735cca8f 100644 --- a/ts/features/bonusVacanze/navigation/routes.ts +++ b/ts/features/bonusVacanze/navigation/routes.ts @@ -14,6 +14,7 @@ const BONUSVACANZE_ROUTES: BonusVacanzeRouteType = { ISEE_NOT_ELIGIBLE: "BONUS_ELIGIBILITY_ISEE_NOT_ELIGIBLE", TIMEOUT: "BONUS_ELIGIBILITY_TIMEOUT", PENDING: "BONUS_ELIGIBILITY_ACTIVATION_PENDING", + UNDERAGE: "BONUS_ELIGIBILITY_UNDERAGE", ELIGIBLE: "BONUS_ELIGIBILITY_ELIGIBLE" }, // Grouping the "Bonus Activation" sub-phase @@ -25,6 +26,21 @@ const BONUSVACANZE_ROUTES: BonusVacanzeRouteType = { COMPLETED: "BONUS_ACTIVATION_COMPLETED" } }; +type Eligibility = + | "CHECK_LOADING" + | "ISEE_NOT_AVAILABLE" + | "ISEE_NOT_ELIGIBLE" + | "TIMEOUT" + | "PENDING" + | "UNDERAGE" + | "ELIGIBLE"; + +type Activation = + | "LOADING" + | "TIMEOUT" + | "ELIGIBILITY_EXPIRED" + | "EXISTS" + | "COMPLETED"; type BonusVacanzeRouteType = { MAIN: string; @@ -33,8 +49,8 @@ type BonusVacanzeRouteType = { BONUS_REQUEST_INFORMATION: string; BONUS_TOS_SCREEN: string; BONUS_ACTIVE_DETAIL_SCREEN: string; - ELIGIBILITY: Record; - ACTIVATION: Record; + ELIGIBILITY: Record; + ACTIVATION: Record; }; export default BONUSVACANZE_ROUTES; diff --git a/ts/features/bonusVacanze/screens/eligibility/UnderageScreen.tsx b/ts/features/bonusVacanze/screens/eligibility/UnderageScreen.tsx new file mode 100644 index 00000000000..4b3f9d6af08 --- /dev/null +++ b/ts/features/bonusVacanze/screens/eligibility/UnderageScreen.tsx @@ -0,0 +1,53 @@ +import * as React from "react"; +import { SafeAreaView } from "react-native"; +import { connect } from "react-redux"; +import { Dispatch } from "redux"; +import FooterWithButtons from "../../../../components/ui/FooterWithButtons"; +import I18n from "../../../../i18n"; +import { cancelButtonProps } from "../../components/buttons/ButtonConfigurations"; +import { useHardwareBackButton } from "../../components/hooks/useHardwareBackButton"; +import { renderInfoRasterImage } from "../../components/infoScreen/imageRendering"; +import { InfoScreenComponent } from "../../components/infoScreen/InfoScreenComponent"; +import { bonusVacanzeStyle } from "../../components/Styles"; +import { cancelBonusVacanzeRequest } from "../../store/actions/bonusVacanze"; + +type Props = ReturnType; + +const image = require("../../../../../img/wallet/errors/payment-unknown-icon.png"); + +/** + * This screen informs the user that only citizens of legal age can apply for the bonus. + * It allows only one CTA: exit + * The screen is tied to the business logic and is composed using {@link InfoScreenComponent} + * @param props + * @constructor + */ + +const UnderageScreen: React.FunctionComponent = props => { + const title = I18n.t("bonus.bonusVacanze.eligibility.underage.title"); + const cancel = I18n.t("global.buttons.exit"); + + useHardwareBackButton(() => { + props.onCancel(); + return true; + }); + + return ( + + + + + ); +}; + +const mapDispatchToProps = (dispatch: Dispatch) => ({ + onCancel: () => dispatch(cancelBonusVacanzeRequest()) +}); + +export default connect( + null, + mapDispatchToProps +)(UnderageScreen); diff --git a/ts/features/bonusVacanze/store/reducers/eligibility.ts b/ts/features/bonusVacanze/store/reducers/eligibility.ts index 588dbcabc86..ad62e9a7f42 100644 --- a/ts/features/bonusVacanze/store/reducers/eligibility.ts +++ b/ts/features/bonusVacanze/store/reducers/eligibility.ts @@ -21,7 +21,8 @@ export enum EligibilityRequestProgressEnum { "TIMEOUT" = "TIMEOUT", // too long to complete the request "ERROR" = "ERROR", // generic error / network error "BONUS_ACTIVATION_PENDING" = "BONUS_ACTIVATION_PENDING", // there's already an activation bonus running - "CONFLICT" = "CONFLICT" // eligibility check succeeded but there's already a bonus found for this set of family members. + "CONFLICT" = "CONFLICT", // eligibility check succeeded but there's already a bonus found for this set of family members. + "UNDERAGE" = "UNDERAGE" // only citizens of legal age can apply } export type EligibilityCheckRequest = { diff --git a/ts/features/bonusVacanze/store/sagas/eligibility/getBonusEligibilitySaga.ts b/ts/features/bonusVacanze/store/sagas/eligibility/getBonusEligibilitySaga.ts index 4e5da28b81f..331bb0db573 100644 --- a/ts/features/bonusVacanze/store/sagas/eligibility/getBonusEligibilitySaga.ts +++ b/ts/features/bonusVacanze/store/sagas/eligibility/getBonusEligibilitySaga.ts @@ -165,6 +165,12 @@ export const bonusEligibilitySaga = ( status: EligibilityRequestProgressEnum.BONUS_ACTIVATION_PENDING }); } + // underage + else if (startEligibilityResult.value.status === 451) { + return checkBonusVacanzeEligibility.success({ + status: EligibilityRequestProgressEnum.UNDERAGE + }); + } throw Error(`response status ${startEligibilityResult.value.status}`); } else { diff --git a/ts/features/bonusVacanze/store/sagas/eligibility/handleBonusEligibilitySaga.ts b/ts/features/bonusVacanze/store/sagas/eligibility/handleBonusEligibilitySaga.ts index 7b5b6083869..b479d8fe952 100644 --- a/ts/features/bonusVacanze/store/sagas/eligibility/handleBonusEligibilitySaga.ts +++ b/ts/features/bonusVacanze/store/sagas/eligibility/handleBonusEligibilitySaga.ts @@ -14,7 +14,8 @@ import { navigateToEligible, navigateToIseeNotAvailable, navigateToIseeNotEligible, - navigateToTimeoutEligibilityCheck + navigateToTimeoutEligibilityCheck, + navigateToUnderage } from "../../../navigation/action"; import BONUSVACANZE_ROUTES from "../../../navigation/routes"; import { @@ -35,7 +36,8 @@ const eligibilityToNavigate = new Map([ EligibilityRequestProgressEnum.BONUS_ACTIVATION_PENDING, navigateToBonusActivationPending ], - [EligibilityRequestProgressEnum.CONFLICT, navigateToBonusAlreadyExists] + [EligibilityRequestProgressEnum.CONFLICT, navigateToBonusAlreadyExists], + [EligibilityRequestProgressEnum.UNDERAGE, navigateToUnderage] ]); type BonusEligibilitySagaType = ReturnType;