-
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(Bonus Pagamenti Digitali): [#174847319] Iban insertion screen (#…
…2259) * add screens * add comments * Add navigation stack * add screen events layout * wip * wip * wip * rework ibaninsertion * clean code * file mssing * cleaning * reorder store * clean code * add comments * comments * add locales and validation iban * revert wallet * fix * Update ts/features/bonus/bpd/saga/orchestration/onboarding/enrollToBpd.ts Co-authored-by: Matteo Boschi <[email protected]> * Update ts/features/bonus/bpd/screens/iban/IbanLoadingUpsert.tsx Co-authored-by: Matteo Boschi <[email protected]> * Update ts/features/bonus/bpd/screens/iban/insertion/IbanInsertionComponent.tsx Co-authored-by: Matteo Boschi <[email protected]> * Update ts/features/bonus/bpd/screens/iban/insertion/IbanInsertionComponent.tsx Co-authored-by: Matteo Boschi <[email protected]> Co-authored-by: Matteo Boschi <[email protected]>
- Loading branch information
1 parent
e2c180b
commit 6351eff
Showing
12 changed files
with
142 additions
and
61 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
51 changes: 0 additions & 51 deletions
51
ts/features/bonus/bpd/screens/iban/IbanInsertionScreen.tsx
This file was deleted.
Oops, something went wrong.
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
77 changes: 77 additions & 0 deletions
77
ts/features/bonus/bpd/screens/iban/insertion/IbanInsertionComponent.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,77 @@ | ||
import { Input, Item, View } from "native-base"; | ||
import * as React from "react"; | ||
import { useState } from "react"; | ||
import { SafeAreaView } from "react-native"; | ||
import { Iban } from "../../../../../../../definitions/backend/Iban"; | ||
import { Body } from "../../../../../../components/core/typography/Body"; | ||
import { H1 } from "../../../../../../components/core/typography/H1"; | ||
import { H5 } from "../../../../../../components/core/typography/H5"; | ||
import { IOStyles } from "../../../../../../components/core/variables/IOStyles"; | ||
import BaseScreenComponent from "../../../../../../components/screens/BaseScreenComponent"; | ||
import I18n from "../../../../../../i18n"; | ||
import { FooterTwoButtons } from "../../../../bonusVacanze/components/markdown/FooterTwoButtons"; | ||
|
||
type Props = { | ||
onBack: () => void; | ||
onIbanConfirm: (iban: Iban) => void; | ||
onContinue: () => void; | ||
}; | ||
|
||
// https://en.wikipedia.org/wiki/International_Bank_Account_Number | ||
// Italian Iban max length: 27 (sample: IT60X0542811101000000123456) | ||
const IbanMaxLength = 34; | ||
|
||
const loadLocales = () => ({ | ||
headerTitle: I18n.t("bonus.bpd.title"), | ||
title: I18n.t("bonus.bpd.iban.insertion.title"), | ||
body1: I18n.t("bonus.bpd.iban.insertion.body1"), | ||
body2: I18n.t("bonus.bpd.iban.insertion.body2"), | ||
ibanDescription: I18n.t("bonus.bpd.iban.iban"), | ||
skip: I18n.t("bonus.bpd.iban.skip") | ||
}); | ||
|
||
export const IbanInsertionComponent: React.FunctionComponent<Props> = props => { | ||
const [iban, setIban] = useState(""); | ||
const isInvalidIban = iban.length > 0 && Iban.decode(iban).isLeft(); | ||
const userCanContinue = !isInvalidIban && iban.length > 0; | ||
const { | ||
headerTitle, | ||
title, | ||
body1, | ||
body2, | ||
ibanDescription, | ||
skip | ||
} = loadLocales(); | ||
|
||
return ( | ||
<BaseScreenComponent goBack={props.onBack} headerTitle={headerTitle}> | ||
<SafeAreaView style={IOStyles.flex}> | ||
<View style={[IOStyles.horizontalContentPadding, IOStyles.flex]}> | ||
<View spacer={true} large={true} /> | ||
<H1>{title}</H1> | ||
<View spacer={true} large={true} /> | ||
<Body>{body1}</Body> | ||
<View spacer={true} large={true} /> | ||
<H5>{ibanDescription}</H5> | ||
<Item error={isInvalidIban}> | ||
<Input | ||
value={iban} | ||
maxLength={IbanMaxLength} | ||
onChangeText={text => setIban(text.toUpperCase().trim())} | ||
/> | ||
</Item> | ||
<View spacer={true} large={true} /> | ||
<View spacer={true} small={true} /> | ||
<Body>{body2}</Body> | ||
</View> | ||
<FooterTwoButtons | ||
rightDisabled={!userCanContinue} | ||
onRight={() => Iban.decode(iban).map(props.onIbanConfirm)} | ||
onCancel={props.onContinue} | ||
rightText={I18n.t("global.buttons.continue")} | ||
leftText={skip} | ||
/> | ||
</SafeAreaView> | ||
</BaseScreenComponent> | ||
); | ||
}; |
39 changes: 39 additions & 0 deletions
39
ts/features/bonus/bpd/screens/iban/insertion/IbanInsertionScreen.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,39 @@ | ||
import * as React from "react"; | ||
import { connect } from "react-redux"; | ||
import { Dispatch } from "redux"; | ||
import { Iban } from "../../../../../../../definitions/backend/Iban"; | ||
import { GlobalState } from "../../../../../../store/reducers/types"; | ||
import { | ||
bpdIbanInsertionCancel, | ||
bpdIbanInsertionContinue, | ||
bpdUpsertIban | ||
} from "../../../store/actions/iban"; | ||
import { IbanInsertionComponent } from "./IbanInsertionComponent"; | ||
|
||
export type Props = ReturnType<typeof mapDispatchToProps> & | ||
ReturnType<typeof mapStateToProps>; | ||
|
||
/** | ||
* This screen allows the user to add / modify an iban to be used to receive the refund provided by bpd | ||
* @constructor | ||
*/ | ||
const IbanInsertionScreen: React.FunctionComponent<Props> = props => ( | ||
<IbanInsertionComponent | ||
onBack={props.cancel} | ||
onContinue={props.continue} | ||
onIbanConfirm={props.submitIban} | ||
/> | ||
); | ||
|
||
const mapDispatchToProps = (dispatch: Dispatch) => ({ | ||
cancel: () => dispatch(bpdIbanInsertionCancel()), | ||
continue: () => dispatch(bpdIbanInsertionContinue()), | ||
submitIban: (iban: Iban) => dispatch(bpdUpsertIban.request(iban)) | ||
}); | ||
|
||
const mapStateToProps = (_: GlobalState) => ({}); | ||
|
||
export default connect( | ||
mapStateToProps, | ||
mapDispatchToProps | ||
)(IbanInsertionScreen); |
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