Skip to content

Commit

Permalink
refactor(expensify card): apply code guidelines
Browse files Browse the repository at this point in the history
  • Loading branch information
pac-guerreiro committed Sep 11, 2023
1 parent 90f323a commit 760fcb3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
11 changes: 3 additions & 8 deletions src/components/CardPreview.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@ import React from 'react';
import {View} from 'react-native';
import {withOnyx} from 'react-native-onyx';
import PropTypes from 'prop-types';

import styles from '../styles/styles';
import Text from './Text';
import usePrivatePersonalDetails from '../hooks/usePrivatePersonalDetails';
import ONYXKEYS from '../ONYXKEYS';

import ExpensifyCardImage from '../../assets/images/expensify-card.svg';

const propTypes = {
Expand All @@ -32,12 +30,9 @@ const defaultProps = {
},
};

function CardPreview(props) {
function CardPreview({privatePersonalDetails: {legalFirstName, legalLastName}, session: {email}}) {
usePrivatePersonalDetails();
const legalFirstName = props.privatePersonalDetails.legalFirstName || '';
const legalLastName = props.privatePersonalDetails.legalLastName || '';

const cardHolder = legalFirstName && legalLastName ? `${legalFirstName} ${legalLastName}` : props.session.email;
const cardHolder = legalFirstName && legalLastName ? `${legalFirstName} ${legalLastName}` : email;

return (
<View style={styles.walletCard}>
Expand All @@ -59,7 +54,7 @@ function CardPreview(props) {

CardPreview.propTypes = propTypes;
CardPreview.defaultProps = defaultProps;
CardPreview.displayName = CardPreview;
CardPreview.displayName = 'CardPreview';

export default withOnyx({
privatePersonalDetails: {
Expand Down
3 changes: 1 addition & 2 deletions src/pages/settings/Wallet/ExpensifyCardPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import Navigation from '../../../libs/Navigation/Navigation';
import styles from '../../../styles/styles';
import * as CurrencyUtils from '../../../libs/CurrencyUtils';
import MenuItemWithTopDescription from '../../../components/MenuItemWithTopDescription';

import CardPreview from '../../../components/CardPreview';
import useLocalize from '../../../hooks/useLocalize';

Expand Down Expand Up @@ -55,6 +54,6 @@ function ExpensifyCardPage(props) {

ExpensifyCardPage.propTypes = propTypes;
ExpensifyCardPage.defaultProps = defaultProps;
ExpensifyCardPage.displayName = ExpensifyCardPage;
ExpensifyCardPage.displayName = 'ExpensifyCardPage';

export default ExpensifyCardPage;

0 comments on commit 760fcb3

Please sign in to comment.