Skip to content

Commit

Permalink
feat: [#173767853] Add underage Infoscreen (#2051)
Browse files Browse the repository at this point in the history
* [#173767853] add UnderageScreen

* [#173767853] navigate to underage when received error status 451

Co-authored-by: Matteo Boschi <[email protected]>
  • Loading branch information
fabriziofff and Undermaken authored Jul 17, 2020
1 parent 49d320e commit fa6dbea
Show file tree
Hide file tree
Showing 9 changed files with 96 additions and 5 deletions.
2 changes: 2 additions & 0 deletions locales/en/index.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions locales/it/index.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions ts/features/bonusVacanze/navigation/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions ts/features/bonusVacanze/navigation/navigator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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
},
Expand Down
20 changes: 18 additions & 2 deletions ts/features/bonusVacanze/navigation/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
Expand All @@ -33,8 +49,8 @@ type BonusVacanzeRouteType = {
BONUS_REQUEST_INFORMATION: string;
BONUS_TOS_SCREEN: string;
BONUS_ACTIVE_DETAIL_SCREEN: string;
ELIGIBILITY: Record<string, string>;
ACTIVATION: Record<string, string>;
ELIGIBILITY: Record<Eligibility, string>;
ACTIVATION: Record<Activation, string>;
};

export default BONUSVACANZE_ROUTES;
53 changes: 53 additions & 0 deletions ts/features/bonusVacanze/screens/eligibility/UnderageScreen.tsx
Original file line number Diff line number Diff line change
@@ -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<typeof mapDispatchToProps>;

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> = props => {
const title = I18n.t("bonus.bonusVacanze.eligibility.underage.title");
const cancel = I18n.t("global.buttons.exit");

useHardwareBackButton(() => {
props.onCancel();
return true;
});

return (
<SafeAreaView style={bonusVacanzeStyle.flex}>
<InfoScreenComponent image={renderInfoRasterImage(image)} title={title} />
<FooterWithButtons
type={"SingleButton"}
leftButton={cancelButtonProps(props.onCancel, cancel)}
/>
</SafeAreaView>
);
};

const mapDispatchToProps = (dispatch: Dispatch) => ({
onCancel: () => dispatch(cancelBonusVacanzeRequest())
});

export default connect(
null,
mapDispatchToProps
)(UnderageScreen);
3 changes: 2 additions & 1 deletion ts/features/bonusVacanze/store/reducers/eligibility.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ import {
navigateToEligible,
navigateToIseeNotAvailable,
navigateToIseeNotEligible,
navigateToTimeoutEligibilityCheck
navigateToTimeoutEligibilityCheck,
navigateToUnderage
} from "../../../navigation/action";
import BONUSVACANZE_ROUTES from "../../../navigation/routes";
import {
Expand All @@ -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<typeof bonusEligibilitySaga>;
Expand Down

0 comments on commit fa6dbea

Please sign in to comment.