-
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): [#177142358] Added privative issuers …
…configuration and choice screen (#2876) * [#177142358] add privative config import * [#177142358] add api * [#177142358] add networking for privative config * [#177142358] add privative trigger * [#177142358] renaming and fixing * [#177142358] fix import * [#177142358] add screens * [#177142358] search brandissuer * [#177142358] update text * [#177142358] add issuers * [#177142358] add tests * [#177142358] add fidelty name to privative issuer item * copy suggestions * [#177142358] fix typescript * [#177142358] update comment Co-authored-by: Simone <[email protected]> Co-authored-by: Jacopo Pompilii <[email protected]>
- Loading branch information
1 parent
572f28e
commit e8b559a
Showing
25 changed files
with
734 additions
and
103 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
14 changes: 12 additions & 2 deletions
14
ts/features/wallet/onboarding/privative/navigation/action.ts
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
38 changes: 38 additions & 0 deletions
38
ts/features/wallet/onboarding/privative/saga/networking/loadPrivativeConfiguration.ts
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,38 @@ | ||
import { readableReport } from "italia-ts-commons/lib/reporters"; | ||
import { call, put } from "redux-saga/effects"; | ||
import { ActionType } from "typesafe-actions"; | ||
import { ContentClient } from "../../../../../../api/content"; | ||
import { SagaCallReturnType } from "../../../../../../types/utils"; | ||
import { getNetworkError } from "../../../../../../utils/errors"; | ||
import { loadPrivativeIssuers } from "../../store/actions"; | ||
|
||
/** | ||
* Load Privative Issuers configuration | ||
*/ | ||
export function* handleLoadPrivativeConfiguration( | ||
getPrivativeServices: ReturnType< | ||
typeof ContentClient | ||
>["getPrivativeServices"], | ||
_: ActionType<typeof loadPrivativeIssuers.request> | ||
) { | ||
try { | ||
const getPrivativeServicesResult: SagaCallReturnType<typeof getPrivativeServices> = yield call( | ||
getPrivativeServices | ||
); | ||
if (getPrivativeServicesResult.isRight()) { | ||
if (getPrivativeServicesResult.value.status === 200) { | ||
yield put( | ||
loadPrivativeIssuers.success(getPrivativeServicesResult.value.value) | ||
); | ||
} else { | ||
throw new Error( | ||
`response status ${getPrivativeServicesResult.value.status}` | ||
); | ||
} | ||
} else { | ||
throw new Error(readableReport(getPrivativeServicesResult.value)); | ||
} | ||
} catch (e) { | ||
yield put(loadPrivativeIssuers.failure(getNetworkError(e))); | ||
} | ||
} |
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
25 changes: 0 additions & 25 deletions
25
ts/features/wallet/onboarding/privative/screens/ChoosePrivativeBrandScreen.tsx
This file was deleted.
Oops, something went wrong.
118 changes: 118 additions & 0 deletions
118
...let/onboarding/privative/screens/choosePrivativeIssuer/ChoosePrivativeIssuerComponent.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,118 @@ | ||
import { View } from "native-base"; | ||
import * as React from "react"; | ||
import { FlatList, ListRenderItemInfo, SafeAreaView } from "react-native"; | ||
import { connect } from "react-redux"; | ||
import { Dispatch } from "redux"; | ||
import { PrivativeServiceStatusEnum } from "../../../../../../../definitions/pagopa/privative/configuration/PrivativeServiceStatus"; | ||
import { Body } from "../../../../../../components/core/typography/Body"; | ||
import { H1 } from "../../../../../../components/core/typography/H1"; | ||
import { IOStyles } from "../../../../../../components/core/variables/IOStyles"; | ||
import BaseScreenComponent from "../../../../../../components/screens/BaseScreenComponent"; | ||
import FooterWithButtons from "../../../../../../components/ui/FooterWithButtons"; | ||
import I18n from "../../../../../../i18n"; | ||
import { GlobalState } from "../../../../../../store/reducers/types"; | ||
import { emptyContextualHelp } from "../../../../../../utils/emptyContextualHelp"; | ||
import { cancelButtonProps } from "../../../../../bonus/bonusVacanze/components/buttons/ButtonConfigurations"; | ||
import { BankPreviewItem } from "../../../bancomat/components/BankPreviewItem"; | ||
import { | ||
navigateToOnboardingPrivativeInsertCardNumberScreen, | ||
navigateToOnboardingPrivativeKoDisabledScreen, | ||
navigateToOnboardingPrivativeKoUnavailableScreen | ||
} from "../../navigation/action"; | ||
import { | ||
walletAddPrivativeCancel, | ||
walletAddPrivativeChooseIssuer | ||
} from "../../store/actions"; | ||
import { PrivativeIssuer } from "../../store/reducers/privativeIssuers"; | ||
import { PrivativeIssuerId } from "../../store/reducers/searchedPrivative"; | ||
|
||
type OwnProps = { | ||
privativeIssuers: ReadonlyArray<PrivativeIssuer>; | ||
}; | ||
|
||
type Props = OwnProps & | ||
ReturnType<typeof mapDispatchToProps> & | ||
ReturnType<typeof mapStateToProps>; | ||
|
||
const loadLocales = () => ({ | ||
headerTitle: I18n.t("wallet.onboarding.privative.headerTitle"), | ||
title: I18n.t("wallet.onboarding.privative.choosePrivativeIssuer.title"), | ||
body: I18n.t("wallet.onboarding.privative.choosePrivativeIssuer.body") | ||
}); | ||
|
||
const handlePress = (pi: PrivativeIssuer, props: Props) => { | ||
switch (pi.status) { | ||
case PrivativeServiceStatusEnum.enabled: | ||
props.chooseIssuer(pi.id); | ||
break; | ||
case PrivativeServiceStatusEnum.disabled: | ||
props.navigateToDisabled(); | ||
break; | ||
case PrivativeServiceStatusEnum.unavailable: | ||
props.navigateToUnavailable(); | ||
break; | ||
} | ||
}; | ||
|
||
const renderItem = (pi: ListRenderItemInfo<PrivativeIssuer>, props: Props) => ( | ||
<BankPreviewItem | ||
bank={{ | ||
abi: pi.item.id, | ||
name: `${pi.item.gdo} - ${pi.item.loyalty}`, | ||
logoUrl: pi.item.gdoLogo | ||
}} | ||
inList={true} | ||
onPress={_ => handlePress(pi.item, props)} | ||
/> | ||
); | ||
|
||
const ChoosePrivativeIssuerComponent = (props: Props): React.ReactElement => { | ||
const { headerTitle, title, body } = loadLocales(); | ||
return ( | ||
<BaseScreenComponent | ||
goBack={true} | ||
headerTitle={headerTitle} | ||
contextualHelp={emptyContextualHelp} | ||
> | ||
<SafeAreaView | ||
style={IOStyles.flex} | ||
testID={"ChoosePrivativeIssuerComponent"} | ||
> | ||
<View style={[IOStyles.horizontalContentPadding, IOStyles.flex]}> | ||
<H1>{title}</H1> | ||
<View spacer={true} /> | ||
<Body>{body}</Body> | ||
<FlatList | ||
data={props.privativeIssuers} | ||
renderItem={v => renderItem(v, props)} | ||
keyExtractor={privativeIssuer => privativeIssuer.id} | ||
keyboardShouldPersistTaps={"handled"} | ||
/> | ||
</View> | ||
<FooterWithButtons | ||
type={"SingleButton"} | ||
leftButton={cancelButtonProps(props.cancel)} | ||
/> | ||
</SafeAreaView> | ||
</BaseScreenComponent> | ||
); | ||
}; | ||
|
||
const mapDispatchToProps = (dispatch: Dispatch) => ({ | ||
cancel: () => dispatch(walletAddPrivativeCancel()), | ||
chooseIssuer: (issuerId: PrivativeIssuerId) => { | ||
dispatch(walletAddPrivativeChooseIssuer(issuerId)); | ||
dispatch(navigateToOnboardingPrivativeInsertCardNumberScreen()); | ||
}, | ||
navigateToDisabled: () => | ||
dispatch(navigateToOnboardingPrivativeKoDisabledScreen()), | ||
navigateToUnavailable: () => | ||
dispatch(navigateToOnboardingPrivativeKoUnavailableScreen()) | ||
}); | ||
|
||
const mapStateToProps = (_: GlobalState) => ({}); | ||
|
||
export default connect( | ||
mapStateToProps, | ||
mapDispatchToProps | ||
)(ChoosePrivativeIssuerComponent); |
Oops, something went wrong.