-
Notifications
You must be signed in to change notification settings - Fork 104
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): [#175329974] Test enable/disable bpd …
…on payment method (#2304) * draft store action reducers * wip * complete reducer for bpdPaymentMethodActivation * wip * add update logic * [#175010541] draft layout * wip * poc pot! * rework store * schedule retry * wip retry * better focus handling * clean code * refinements * renaming * move style to styles * EnrollPaymentMethodScreen static content * link to business logic * add comment * [#175329974] Add TMPBpdScreen * fix typescript * fix test fail * [#174794326,174794981] support get payment status * [#174794326,174794981] support update (enroll + delete) payment status * support 409 http response status code * use const for loadingState * fix merge * [#175329974] sync activationDate&deactivationDate with local type definition Co-authored-by: Matteo Boschi <mbmaken@gmail.com>
- Loading branch information
1 parent
b26fe2d
commit 37938e2
Showing
7 changed files
with
169 additions
and
16 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// TODO: remove after the introduction of the bpd detail screen | ||
import { NavigationActions } from "react-navigation"; | ||
import BPD_ROUTES from "../routes"; | ||
|
||
export const navigateToBpdTestScreen = () => | ||
NavigationActions.navigate({ | ||
routeName: BPD_ROUTES.TEST | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
import * as pot from "italia-ts-commons/lib/pot"; | ||
import { View } from "native-base"; | ||
import { useEffect } from "react"; | ||
import * as React from "react"; | ||
import { SafeAreaView, ScrollView } from "react-native"; | ||
import { connect } from "react-redux"; | ||
import { Dispatch } from "redux"; | ||
import { Body } from "../../../../../components/core/typography/Body"; | ||
import { H1 } from "../../../../../components/core/typography/H1"; | ||
import { Label } from "../../../../../components/core/typography/Label"; | ||
import { LabelSmall } from "../../../../../components/core/typography/LabelSmall"; | ||
import { IOStyles } from "../../../../../components/core/variables/IOStyles"; | ||
import BaseScreenComponent from "../../../../../components/screens/BaseScreenComponent"; | ||
import FooterWithButtons from "../../../../../components/ui/FooterWithButtons"; | ||
import { GlobalState } from "../../../../../store/reducers/types"; | ||
import { walletsSelector } from "../../../../../store/reducers/wallet/wallets"; | ||
import { Wallet } from "../../../../../types/pagopa"; | ||
import { cancelButtonProps } from "../../../bonusVacanze/components/buttons/ButtonConfigurations"; | ||
import { PaymentMethodBpdList } from "../../components/PaymentMethodBpdList"; | ||
import { | ||
fold, | ||
isReady, | ||
isUndefined, | ||
RemoteValue | ||
} from "../../model/RemoteValue"; | ||
import { bpdLoadActivationStatus } from "../../store/actions/details"; | ||
import { bpdDeleteUserFromProgram } from "../../store/actions/onboarding"; | ||
import { bpdEnabledSelector } from "../../store/reducers/details/activation"; | ||
|
||
export type Props = ReturnType<typeof mapDispatchToProps> & | ||
ReturnType<typeof mapStateToProps>; | ||
|
||
const renderBpdActive = (value: RemoteValue<boolean, Error>) => | ||
fold( | ||
() => <LabelSmall color={"bluegrey"}>Sconosciuta</LabelSmall>, | ||
() => <LabelSmall color={"bluegrey"}>In caricamento</LabelSmall>, | ||
active => ( | ||
<LabelSmall color={active ? "blue" : "red"}> | ||
{active ? "Attiva" : "Non attiva"} | ||
</LabelSmall> | ||
), | ||
_ => <LabelSmall color={"red"}>Errore durante il caricamento</LabelSmall> | ||
)(value); | ||
|
||
const renderPaymentMethod = ( | ||
potWallets: pot.Pot<ReadonlyArray<Wallet>, Error> | ||
) => | ||
pot.fold( | ||
potWallets, | ||
// TODO: handle error, loading with spinner if needed | ||
() => ( | ||
<LabelSmall color={"bluegrey"}> | ||
Metodi di pagamento sconosciuti | ||
</LabelSmall> | ||
), | ||
() => ( | ||
<LabelSmall color={"bluegrey"}> | ||
Metodi di pagamento in caricamento | ||
</LabelSmall> | ||
), | ||
_ => null, | ||
_ => ( | ||
<LabelSmall color={"red"}> | ||
Errore nel recuperare i metodi di pagamento | ||
</LabelSmall> | ||
), | ||
value => <PaymentMethodBpdList paymentList={value} />, | ||
value => <PaymentMethodBpdList paymentList={value} />, | ||
value => <PaymentMethodBpdList paymentList={value} />, | ||
value => <PaymentMethodBpdList paymentList={value} /> | ||
); | ||
|
||
/** | ||
* A temp screen created to allow the test of some bpd functionalities waiting for the detail screen. | ||
* TODO: remove after bpd detail screen | ||
* @constructor | ||
*/ | ||
const TmpBpdScreen: React.FunctionComponent<Props> = props => { | ||
const bpdActive = renderBpdActive(props.bpdActive); | ||
|
||
useEffect(() => { | ||
if (isUndefined(props.bpdActive)) { | ||
props.loadBpdActivation(); | ||
} | ||
}, []); | ||
|
||
return ( | ||
<BaseScreenComponent goBack={true} headerTitle={"Test Bpd"}> | ||
<SafeAreaView style={IOStyles.flex}> | ||
<View style={[IOStyles.horizontalContentPadding, IOStyles.flex]}> | ||
<ScrollView> | ||
<View spacer={true} large={true} /> | ||
<H1>Test bpd screen</H1> | ||
<View spacer={true} large={true} /> | ||
<Body>La tua iscrizione al cashback è: {bpdActive}</Body> | ||
<View spacer={true} large={true} /> | ||
{isReady(props.bpdActive) && props.bpdActive.value ? ( | ||
<> | ||
<Label color={"bluegrey"}>Metodi di pagamento:</Label> | ||
{renderPaymentMethod(props.potWallets)} | ||
</> | ||
) : ( | ||
<Body> | ||
Iscriviti al cashback per visualizzare la lista dei metodi di | ||
pagamento | ||
</Body> | ||
)} | ||
</ScrollView> | ||
</View> | ||
{isReady(props.bpdActive) && props.bpdActive.value && ( | ||
<FooterWithButtons | ||
type={"SingleButton"} | ||
leftButton={cancelButtonProps( | ||
props.cancelBpd, | ||
"Cancella la tua iscrizione al cashback" | ||
)} | ||
/> | ||
)} | ||
</SafeAreaView> | ||
</BaseScreenComponent> | ||
); | ||
}; | ||
|
||
const mapDispatchToProps = (dispatch: Dispatch) => ({ | ||
loadBpdActivation: () => dispatch(bpdLoadActivationStatus.request()), | ||
cancelBpd: () => dispatch(bpdDeleteUserFromProgram.request()) | ||
}); | ||
|
||
const mapStateToProps = (state: GlobalState) => ({ | ||
bpdActive: bpdEnabledSelector(state), | ||
potWallets: walletsSelector(state) | ||
}); | ||
|
||
export default connect(mapStateToProps, mapDispatchToProps)(TmpBpdScreen); |
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