Skip to content

Commit

Permalink
fix: [#176225603] PSP Icon removal (#2690)
Browse files Browse the repository at this point in the history
* removed PSP icon rendering logic

* refactored getBodyIcon and added comment

* removed default case to take advantage of TS power

Co-authored-by: Simone <[email protected]>
  • Loading branch information
DavideValdo and debiff authored Jan 15, 2021
1 parent 2967024 commit fe949e5
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 32 deletions.
47 changes: 17 additions & 30 deletions ts/components/wallet/card/CardComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ interface FullCommonProps extends BaseProps {
extraSpace?: boolean;
hideFavoriteIcon?: boolean;
onDelete?: () => void;
showPsp?: boolean;
}

interface FullProps extends FullCommonProps {
Expand Down Expand Up @@ -108,7 +107,7 @@ export default class CardComponent extends React.Component<Props> {
if (
this.props.type === "Preview" ||
this.props.type === "Picking" ||
(this.props.type === "Full" && this.props.showPsp)
this.props.type === "Full"
) {
const { wallet } = this.props;
return (
Expand All @@ -118,7 +117,7 @@ export default class CardComponent extends React.Component<Props> {
);
}

if (this.props.type === "Full" || this.props.type === "Header") {
if (this.props.type === "Header") {
const {
hideFavoriteIcon,
isFavorite,
Expand Down Expand Up @@ -186,37 +185,25 @@ export default class CardComponent extends React.Component<Props> {
}

private renderBody(creditCard: CreditCard) {
const { type, wallet } = this.props;

const getBodyIcon = () => {
if (
this.props.type === "Picking" ||
(this.props.type === "Full" && this.props.showPsp)
) {
return wallet.psp ? (
<View style={[styles.cardPsp]}>
<Logo
item={creditCard}
pspLogo={wallet.psp.logoPSP}
imageStyle={styles.pspLogo}
/>
</View>
) : (
<View style={[styles.cardPsp]}>
<Logo />
</View>
);
}
return (
<View style={[styles.cardLogo, { alignSelf: "flex-end" }]}>
<Logo item={creditCard} />
</View>
);
};
const { type } = this.props;

if (type === "Preview") {
return null;
}
// Right icon, basically needed for the sole "Header" variant
const getBodyIcon = () => {
switch (type) {
case "Picking":
case "Full":
return null;
case "Header":
return (
<View style={[styles.cardLogo, { alignSelf: "flex-end" }]}>
<Logo item={creditCard} />
</View>
);
}
};

const expirationDate = buildExpirationDate(creditCard);
const isExpired = isExpiredCard(creditCard);
Expand Down
1 change: 0 additions & 1 deletion ts/screens/wallet/payment/ConfirmPaymentMethodScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ class ConfirmPaymentMethodScreen extends React.Component<Props, never> {
wallet={wallet}
hideMenu={true}
hideFavoriteIcon={true}
showPsp={true}
/>
<View spacer={true} />
{wallet.psp === undefined ? (
Expand Down
2 changes: 1 addition & 1 deletion ts/screens/wallet/payment/PickPaymentMethodScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class PickPaymentMethodScreen extends React.Component<Props> {
dataArray={wallets as any[]} // eslint-disable-line
renderRow={(item): React.ReactElement<any> => (
<CardComponent
type={"Picking"}
type="Picking"
wallet={item}
mainAction={this.props.navigateToConfirmOrPickPsp}
/>
Expand Down

0 comments on commit fe949e5

Please sign in to comment.