-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Carta Giovani Nazionale): [#176443044] Adds directories skeleton…
… for CGN implementation (#2718) * [#176443044] Adds some skaffolding for CGN store, reducer and navigation * [#176443044] Minor fixes * Update ts/features/bonus/cgn/screens/onboarding/CgnInformationScreen.tsx Co-authored-by: Matteo Boschi <[email protected]> * Update ts/features/bonus/cgn/navigation/routes.ts Co-authored-by: Matteo Boschi <[email protected]> * Update ts/features/bonus/cgn/navigation/actions.ts Co-authored-by: fabriziofff <[email protected]> * Update ts/features/bonus/cgn/navigation/actions.ts Co-authored-by: fabriziofff <[email protected]> * Update ts/features/bonus/cgn/navigation/actions.ts Co-authored-by: fabriziofff <[email protected]> * Update ts/features/bonus/cgn/navigation/actions.ts Co-authored-by: fabriziofff <[email protected]> * [#176443044] Adds a locale for activate CTA * [#176443044] removes comment * Update locales/en/index.yml Co-authored-by: Matteo Boschi <[email protected]> Co-authored-by: fabriziofff <[email protected]>
- Loading branch information
1 parent
24f09f5
commit 5bc6f7b
Showing
17 changed files
with
208 additions
and
5 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
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
Empty file.
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,23 @@ | ||
import { NavigationActions } from "react-navigation"; | ||
import CGN_ROUTES from "./routes"; | ||
|
||
export const navigateToCgnOnboardingLoadActivationStatus = () => | ||
NavigationActions.navigate({ | ||
routeName: CGN_ROUTES.ACTIVATION.LOAD_CHECK_ACTIVATION_STATUS | ||
}); | ||
|
||
export const navigateToCgnOnboardingInformationTos = () => | ||
NavigationActions.navigate({ | ||
routeName: CGN_ROUTES.ACTIVATION.INFORMATION_TOS | ||
}); | ||
|
||
export const navigateToCgnOnboardingLoadActivate = () => | ||
NavigationActions.navigate({ | ||
routeName: CGN_ROUTES.ACTIVATION.LOAD_ACTIVATE | ||
}); | ||
|
||
// Details | ||
export const navigateToCgnDetails = () => | ||
NavigationActions.navigate({ | ||
routeName: CGN_ROUTES.DETAILS | ||
}); |
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,20 @@ | ||
import { createStackNavigator } from "react-navigation"; | ||
import CgnInformationScreen from "../screens/onboarding/CgnInformationScreen"; | ||
import CGN_ROUTES from "./routes"; | ||
|
||
const CgnNavigator = createStackNavigator( | ||
{ | ||
[CGN_ROUTES.ACTIVATION.INFORMATION_TOS]: { | ||
screen: CgnInformationScreen | ||
} | ||
}, | ||
{ | ||
// Let each screen handle the header and navigation | ||
headerMode: "none", | ||
defaultNavigationOptions: { | ||
gesturesEnabled: false | ||
} | ||
} | ||
); | ||
|
||
export default CgnNavigator; |
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,14 @@ | ||
const CGN_ROUTES = { | ||
MAIN: "CGN_ROUTES_MAIN", | ||
|
||
ACTIVATION: { | ||
LOAD_CHECK_ACTIVATION_STATUS: "CGN_LOAD_CHECK_ACTIVATION_STATUS", | ||
INFORMATION_TOS: "CGN_INFORMATION_TOS", | ||
LOAD_ACTIVATE: "CGN_LOAD_ACTIVATE" | ||
}, | ||
|
||
DETAILS: "CGN_DETAILS", | ||
CTA_START_CGN: "CTA_START_CGN" | ||
}; | ||
|
||
export default CGN_ROUTES; |
49 changes: 49 additions & 0 deletions
49
ts/features/bonus/cgn/screens/onboarding/CgnInformationScreen.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import * as React from "react"; | ||
import { connect } from "react-redux"; | ||
import I18n from "../../../../../i18n"; | ||
import { Dispatch } from "../../../../../store/actions/types"; | ||
import { GlobalState } from "../../../../../store/reducers/types"; | ||
import { emptyContextualHelp } from "../../../../../utils/emptyContextualHelp"; | ||
import { availableBonusTypesSelectorFromId } from "../../../bonusVacanze/store/reducers/availableBonusesTypes"; | ||
import { ID_CGN_TYPE } from "../../../bonusVacanze/utils/bonus"; | ||
import BonusInformationComponent from "../../../common/components/BonusInformationComponent"; | ||
import { navigateBack } from "../../../../../store/actions/navigation"; | ||
|
||
export type Props = ReturnType<typeof mapDispatchToProps> & | ||
ReturnType<typeof mapStateToProps>; | ||
|
||
/** | ||
* This Screen shows all the information about the cgn program, with the rules and t&c. | ||
*/ | ||
const CgnInformationScreen: React.FunctionComponent<Props> = (props: Props) => { | ||
const onConfirm = () => props.userActivateCgn(); | ||
|
||
return ( | ||
<> | ||
{props.bonus ? ( | ||
<BonusInformationComponent | ||
primaryCtaText={I18n.t("bonus.cgn.cta.activeBonus")} | ||
bonus={props.bonus} | ||
onConfirm={onConfirm} | ||
onCancel={props.onCancel} | ||
contextualHelp={emptyContextualHelp} | ||
/> | ||
) : null} | ||
</> | ||
); | ||
}; | ||
|
||
const mapStateToProps = (state: GlobalState) => ({ | ||
// display the error with the retry only in case of networking errors | ||
bonus: availableBonusTypesSelectorFromId(ID_CGN_TYPE)(state) | ||
}); | ||
|
||
const mapDispatchToProps = (dispatch: Dispatch) => ({ | ||
userActivateCgn: () => null, | ||
onCancel: () => dispatch(navigateBack()) | ||
}); | ||
|
||
export default connect( | ||
mapStateToProps, | ||
mapDispatchToProps | ||
)(CgnInformationScreen); |
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,13 @@ | ||
import { ActionType, createAsyncAction } from "typesafe-actions"; | ||
import { NullType } from "io-ts"; | ||
|
||
/** | ||
* get and handle activation state of a CGN | ||
*/ | ||
export const cgnActivationStatus = createAsyncAction( | ||
"CGN_ACTIVATION_STATUS_REQUEST", | ||
"CGN_ACTIVATION_STATUS_SUCCESS", | ||
"CGN_ACTIVATION_STATUS_FAILURE" | ||
)<void, NullType, Error>(); // Replace when API spec is correctly linked and defined | ||
|
||
export type CgnActivationActions = ActionType<typeof cgnActivationStatus>; |
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,3 @@ | ||
import { CgnActivationActions } from "./activation"; | ||
|
||
export type CgnActions = CgnActivationActions; |
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,47 @@ | ||
// bonus reducer | ||
import { getType } from "typesafe-actions"; | ||
import { Action } from "../../../../../store/actions/types"; | ||
import { cgnActivationStatus } from "../actions/activation"; | ||
|
||
export enum CgnActivationProgressEnum { | ||
"UNDEFINED" = "UNDEFINED", | ||
"PROGRESS" = "PROGRESS", // The request is started | ||
"PENDING" = "PENDING", // Polling time exceeded | ||
"ERROR" = "ERROR", // The request is started | ||
"EXISTS" = "EXISTS", // Another bonus related to this user was found | ||
"SUCCESS" = "SUCCESS" // Activation has been completed | ||
} | ||
|
||
export type ActivationState = { | ||
status: CgnActivationProgressEnum; | ||
}; | ||
|
||
const INITIAL_STATE: ActivationState = { | ||
status: CgnActivationProgressEnum.UNDEFINED | ||
}; | ||
const reducer = ( | ||
state: ActivationState = INITIAL_STATE, | ||
action: Action | ||
): ActivationState => { | ||
switch (action.type) { | ||
// bonus activation | ||
case getType(cgnActivationStatus.request): | ||
return { | ||
...state, | ||
status: CgnActivationProgressEnum.PROGRESS | ||
}; | ||
case getType(cgnActivationStatus.success): | ||
return { | ||
...state, | ||
status: CgnActivationProgressEnum.SUCCESS // To replace with action payload when types are defined | ||
}; | ||
case getType(cgnActivationStatus.failure): | ||
return { | ||
...state, | ||
status: CgnActivationProgressEnum.ERROR | ||
}; | ||
} | ||
return state; | ||
}; | ||
|
||
export default reducer; |
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,12 @@ | ||
import { Action, combineReducers } from "redux"; | ||
import cgnActivationReducer, { ActivationState } from "./activation"; | ||
|
||
export type CgnState = { | ||
activation: ActivationState; | ||
}; | ||
|
||
const cgnReducer = combineReducers<CgnState, Action>({ | ||
activation: cgnActivationReducer | ||
}); | ||
|
||
export default cgnReducer; |
Empty file.
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