Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Bonus Pagamenti Digitali): [#176578587] Cobadge detail screen #2751

Merged
merged 52 commits into from
Feb 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
5ab52ed
[#176578578] create cobadge list selector
debiff Jan 22, 2021
7a350b0
[#176578578] add optional abiInfo to creditCardPaymentMethod
debiff Jan 22, 2021
ef55ab3
[#176578578] add cobadgeCard to walletPreview
debiff Jan 22, 2021
2b87b60
[#176578578] create cobadgePreview card
debiff Jan 22, 2021
6bd5658
[#176578578] add cobadge card
debiff Jan 22, 2021
932dda7
[#176578578] wip enhance crediCard
debiff Jan 22, 2021
0808de8
[#176578578] enhance creditCard with abiInfo
debiff Jan 22, 2021
5cc37ae
[#176578578] renaming
debiff Jan 22, 2021
1864c06
[#176578578] add void CobadgeDetailScreen
debiff Jan 22, 2021
08f6ee7
[#176578578] add navigation to cobadgeDetailScreen action
debiff Jan 22, 2021
26d95dd
[#176578578] add testId to cardPreview
debiff Jan 22, 2021
26c4d12
[#176578578] add fake cobadgeDetailScreen
debiff Jan 22, 2021
4a437b7
[#176578578] add navigation to cobadgeWalletDetail
debiff Jan 22, 2021
a4a3b1a
[#176578578] add cobadgeWalletPreview tests
debiff Jan 22, 2021
e56cf51
[#176578578] Merge branch 'master' into 176578578-cobadge-preview-card
debiff Jan 22, 2021
22fe698
[#176578587] modify paymentMethodCapabilities test description
debiff Jan 25, 2021
ff53c94
[#176578587] extract cobadge param from navigation
debiff Jan 25, 2021
556c728
[#176578587] add dark layout
debiff Jan 25, 2021
e00b673
[#176578587] add paymentMethodCapabilities
debiff Jan 25, 2021
a5d1d49
[#176578587] add delete button
debiff Jan 25, 2021
aaea376
[#176578587] add cobadge card labels
debiff Jan 25, 2021
2f93b90
[#176578587] add cobadge card
debiff Jan 25, 2021
d4ec699
[#176578587] Merge branch 'master' into 176578587-cobadge-detail-screen
debiff Jan 25, 2021
07a66ba
[#176578587] drill brandLogo from cobadgeWalletPreview to CobadgeCard…
debiff Jan 25, 2021
cb2149a
[#176578587] remove bankName as abiLogo fallback
debiff Jan 25, 2021
25b290e
[#176578587] update CobadgeWalletPreview test
debiff Jan 25, 2021
19a032a
[#176578587] add abiLogo fallback
debiff Jan 25, 2021
e3e84d9
Merge branch 'master' into 176578578-cobadge-preview-card
fabriziofff Jan 25, 2021
b08a6b6
[#176578587] update expirationDate label
debiff Jan 25, 2021
c7d4112
[#176578587] add expirationDate testId
debiff Jan 25, 2021
9c9bf8b
[#176578587] add CobadgeCard tests
debiff Jan 25, 2021
a398fd5
[#176578587] Merge branch 'master' into 176578587-cobadge-detail-screen
debiff Jan 25, 2021
75c41c9
[#176578587] update labels
debiff Jan 25, 2021
3e6e53a
[#176578587] removed unused import
debiff Jan 25, 2021
4087a27
[#176578578] remove bancomat or bpay reference
debiff Jan 27, 2021
37a4d42
[#176578578] use already existing getCardIconFromBrandLogo function i…
debiff Jan 27, 2021
ff295e4
[#176578578] add issuerAbiCode condition on cobadgeListVisibleInWalle…
debiff Jan 27, 2021
1adec61
[#176578578] Merge remote-tracking branch 'origin/master' into 176578…
fabriziofff Jan 29, 2021
2f1cb51
[#176578578] fix
fabriziofff Jan 29, 2021
2644155
[#176578578] Merge remote-tracking branch 'origin/master' into 176578…
fabriziofff Jan 29, 2021
953d534
[#176578587] Merge branch '176578578-cobadge-preview-card' into 17657…
fabriziofff Jan 29, 2021
b9a2250
[#176578587] fix merge
fabriziofff Jan 29, 2021
88c9401
[#176578587] fix merge
fabriziofff Jan 29, 2021
78aa15d
Merge branch 'master' into 176578587-cobadge-detail-screen
fabriziofff Jan 29, 2021
0280969
[#176578587] fix typo in test name
debiff Feb 1, 2021
8e95104
[#176578587] align brandLogo size with invision
debiff Feb 1, 2021
0816b1d
[#176578587] pass the whole cobadge card instead of separate prop
debiff Feb 1, 2021
a6c4e84
[#176578587] add key to abiLogo in cobadge card
debiff Feb 1, 2021
919d5f2
[#176578587] remove unused import
debiff Feb 1, 2021
313ff6e
[#176578587] update test
debiff Feb 1, 2021
577e0b6
Merge branch 'master' into 176578587-cobadge-detail-screen
debiff Feb 1, 2021
c182524
[#176578587] Merge branch 'master' into 176578587-cobadge-detail-screen
fabriziofff Feb 2, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added img/wallet/cards-icons/abiLogoFallback.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions locales/en/index.yml
Original file line number Diff line number Diff line change
Expand Up @@ -759,6 +759,8 @@ wallet:
dateTime: Date and time
detailTitle: Details
help: If you have encountered a problem entering this payment method, write for more information and details
details:
header: Method detail
searchAbi:
header: "Add {{methodName}}"
bancomat:
Expand Down Expand Up @@ -1174,6 +1176,10 @@ wallet:
one: "Satispay"
two: " can't be used yet to make payments through IO"
three: ": this feature will be enabled on future app version release."
cobadge:
details:
card:
validUntil: "Valid until {{expireMonth}}/{{expireYear}}"
newRemove:
title: "Delete this payment method?"
body: "This payment method will be removed. Any related feature, such as Cashback, will be disabled within 24 hours."
Expand Down
6 changes: 6 additions & 0 deletions locales/it/index.yml
Original file line number Diff line number Diff line change
Expand Up @@ -779,6 +779,8 @@ wallet:
dateTime: Data e ora
detailTitle: Dettaglio
help: Se hai riscontrato un problema durante l'inserimento di questo metodo di pagamento, scrivi per maggiori informazioni e dettagli
details:
header: Dettaglio Metodo
searchAbi:
header: Aggiungi {{methodName}}
bancomat:
Expand Down Expand Up @@ -1201,6 +1203,10 @@ wallet:
one: "Satispay"
two: " non consente ancora di pagare tramite IO"
three: ": questa funzione verrà abilitata con le prossime versioni dell’app."
cobadge:
details:
card:
validUntil: "Valida fino al {{expireMonth}}/{{expireYear}}"
newRemove:
title: "Vuoi eliminare questo metodo?"
body: "Questo metodo di pagamento verrà rimosso. Eventuali funzioni collegate, come il Cashback, verranno disattivate entro 24h."
Expand Down
112 changes: 112 additions & 0 deletions ts/features/wallet/cobadge/component/CobadgeCard.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
import * as React from "react";
import {
Image,
ImageSourcePropType,
ImageStyle,
StyleProp,
StyleSheet
} from "react-native";
import { View } from "native-base";
import I18n from "../../../../i18n";
import BaseCardComponent from "../../component/BaseCardComponent";
import { useImageResize } from "../../onboarding/bancomat/screens/hooks/useImageResize";
import { H4 } from "../../../../components/core/typography/H4";
import { H5 } from "../../../../components/core/typography/H5";
import abiLogoFallback from "../../../../../img/wallet/cards-icons/abiLogoFallback.png";

type Props = {
caption?: string;
expireMonth?: string;
expireYear?: string;
abiLogo?: string;
brandLogo: ImageSourcePropType;
};

const styles = StyleSheet.create({
abiLogoFallback: {
width: 40,
height: 40,
resizeMode: "contain"
},
brandLogo: {
width: 48,
height: 31,
resizeMode: "contain"
},
bankName: { textTransform: "capitalize" }
});

const BASE_IMG_W = 160;
const BASE_IMG_H = 40;

const CobadgeCard: React.FunctionComponent<Props> = (props: Props) => {
const imgDimensions = useImageResize(BASE_IMG_W, BASE_IMG_H, props.abiLogo);

const imageStyle: StyleProp<ImageStyle> | undefined = imgDimensions.fold(
undefined,
imgDim => ({
width: imgDim[0],
height: imgDim[1],
resizeMode: "contain"
})
);
return (
<BaseCardComponent
topLeftCorner={
<>
{props.abiLogo && imageStyle ? (
<Image
source={{ uri: props.abiLogo }}
style={imageStyle}
key={"abiLogo"}
testID={"abiLogo"}
/>
) : (
<Image
source={abiLogoFallback}
style={styles.abiLogoFallback}
key={"abiLogoFallback"}
testID={"abiLogoFallback"}
/>
)}
{props.expireMonth && props.expireYear && (
<>
<View spacer={true} />
<H5
weight={"Regular"}
color={"bluegrey"}
testID={"expirationDate"}
>
{I18n.t("wallet.cobadge.details.card.validUntil", {
expireMonth: props.expireMonth,
expireYear: props.expireYear
})}
</H5>
</>
)}
</>
}
bottomLeftCorner={
<View>
{props.caption && (
<>
<View style={{ flexDirection: "row" }}>
<H4 weight={"Regular"} testID="caption">
{props.caption}
</H4>
</View>
<View spacer small />
</>
)}
</View>
}
bottomRightCorner={
<View style={{ justifyContent: "flex-end", flexDirection: "column" }}>
<Image style={styles.brandLogo} source={props.brandLogo} />
</View>
}
/>
);
};

export default CobadgeCard;
12 changes: 7 additions & 5 deletions ts/features/wallet/cobadge/component/CobadgeWalletPreview.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { Option } from "fp-ts/lib/Option";
import * as React from "react";
import { Image, ImageStyle, StyleProp } from "react-native";
import { Option } from "fp-ts/lib/Option";
import { connect } from "react-redux";
import { Dispatch } from "redux";
import { Body } from "../../../../components/core/typography/Body";
import { IOStyles } from "../../../../components/core/variables/IOStyles";
import { GlobalState } from "../../../../store/reducers/types";
import { CardPreview } from "../../component/CardPreview";
import { getCardIconFromBrandLogo } from "../../../../components/wallet/card/Logo";
import { navigateToCobadgeDetailScreen } from "../../../../store/actions/navigation";
import { GlobalState } from "../../../../store/reducers/types";
import { CreditCardPaymentMethod } from "../../../../types/pagopa";
import { CardPreview } from "../../component/CardPreview";
import { useImageResize } from "../../onboarding/bancomat/screens/hooks/useImageResize";
import { getCardIconFromBrandLogo } from "../../../../components/wallet/card/Logo";

type OwnProps = {
cobadge: CreditCardPaymentMethod;
Expand Down Expand Up @@ -62,10 +62,12 @@ const CobadgeWalletPreview: React.FunctionComponent<Props> = props => {
BASE_IMG_H,
props.cobadge.abiInfo?.logoUrl
);

const brandLogo = getCardIconFromBrandLogo(props.cobadge.info);
return (
<CardPreview
left={renderLeft(props, imgDimensions)}
image={getCardIconFromBrandLogo(props.cobadge.info)}
image={brandLogo}
onPress={() => props.navigateToCobadgeDetails(props.cobadge)}
/>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
import { render } from "@testing-library/react-native";
import * as React from "react";
import { ImageSourcePropType } from "react-native";
import { Store } from "redux";
import { Provider } from "react-redux";
import configureMockStore from "redux-mock-store";
// import { pot } from "italia-ts-commons";
import { none, some } from "fp-ts/lib/Option";
import * as hooks from "../../../onboarding/bancomat/screens/hooks/useImageResize";
import CobadgeCard from "../CobadgeCard";
import defaultCardIcon from "../../../../../../img/wallet/cards-icons/unknown.png";

jest.mock("../../../onboarding/bancomat/screens/hooks/useImageResize");

const aCaption = "****1234";
const anAbiLogo = "http://127.0.0.1:3000/static_contents/logos/abi/03069.png";
const aBrandLogo = defaultCardIcon;
const anExpireMonth = "6";
const anExpireYear = "2021";
describe("CoBadgeWalletPreview component", () => {
const mockStore = configureMockStore();
// eslint-disable-next-line functional/no-let
let store: ReturnType<typeof mockStore>;

beforeEach(() => {
store = mockStore();
});
it("should show the abiLogoFallback if there isn't the abiLogo", () => {
jest.spyOn(hooks, "useImageResize").mockReturnValue(none);
const component = getComponent(store, aBrandLogo);
const abiLogoFallbackComponent = component.queryByTestId("abiLogoFallback");

expect(abiLogoFallbackComponent).not.toBeNull();
expect(abiLogoFallbackComponent).toHaveProp("source", {
testUri: "../../../img/wallet/cards-icons/abiLogoFallback.png"
});
});

it("should show the abiLogo if there is an abiLogo and useImageResize return some value", () => {
jest.spyOn(hooks, "useImageResize").mockReturnValue(some([15, 15]));
const component = getComponent(store, aBrandLogo, anAbiLogo);
const abiLogo = component.queryByTestId("abiLogo");

expect(abiLogo).not.toBeNull();
expect(abiLogo).toHaveProp("source", { uri: anAbiLogo });
});

it("should show the expiration date if both expireMonth and expireYear are defined", () => {
jest.spyOn(hooks, "useImageResize").mockReturnValue(none);
const component = getComponent(
store,
aBrandLogo,
anAbiLogo,
aCaption,
anExpireMonth,
anExpireYear
);
const expirationDate = component.queryByTestId("expirationDate");

expect(expirationDate).not.toBeNull();
expect(expirationDate).toHaveTextContent(
`Valid until ${anExpireMonth}/${anExpireYear}`
);
});

it("should show the caption if is defined", () => {
jest.spyOn(hooks, "useImageResize").mockReturnValue(none);
const component = getComponent(store, aBrandLogo, anAbiLogo, aCaption);
const caption = component.queryByTestId("caption");

expect(caption).not.toBeNull();
expect(caption).toHaveTextContent(aCaption);
});
});

const getComponent = (
store: Store<unknown>,
brandLogo: ImageSourcePropType,
abiLogo?: string,
caption?: string,
expireMonth?: string,
expireYear?: string
) =>
render(
<Provider store={store}>
<CobadgeCard
brandLogo={brandLogo}
caption={caption}
expireMonth={expireMonth}
expireYear={expireYear}
abiLogo={abiLogo}
/>
</Provider>
);
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,9 @@ describe("CobadgeWalletPreview component", () => {
const expectedPayload = {
type: NavigationActions.NAVIGATE,
routeName: ROUTES.WALLET_COBADGE_DETAIL,
params: { cobadge: aCobadgeCard }
params: {
cobadge: aCobadgeCard
}
};
if (cardComponent) {
fireEvent.press(cardComponent);
Expand Down
Loading