Skip to content

Improve eReceipt visually in New Dot #55803

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

Merged
merged 62 commits into from
Mar 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
e076d99
add test branch
mkzie2 Jan 14, 2025
6f5000a
resolve conflict
mkzie2 Jan 27, 2025
0f3ff8f
use only one background
mkzie2 Jan 27, 2025
cc254f6
Merge branch 'main' into mkzie2-issue/55083
mkzie2 Feb 3, 2025
28ce4b8
fix ui in native
mkzie2 Feb 3, 2025
fb3b2fb
update story
mkzie2 Feb 3, 2025
c29d6da
fix lint error
mkzie2 Feb 3, 2025
7bb31bb
remove default value
mkzie2 Feb 3, 2025
f7903f2
Merge branch 'main' into mkzie2-issue/55083
mkzie2 Feb 4, 2025
b60b1fb
update ereceipt style
mkzie2 Feb 4, 2025
6fec798
update background image style
mkzie2 Feb 4, 2025
2303602
Merge branch 'main' into mkzie2-issue/55083
mkzie2 Feb 6, 2025
fd9851c
update ereceipt style and create a new hook
mkzie2 Feb 6, 2025
5eb9482
use generic style
mkzie2 Feb 6, 2025
9e0f9f9
Merge branch 'main' into mkzie2-issue/55083
mkzie2 Feb 7, 2025
0c7d7a0
remove boradius style
mkzie2 Feb 7, 2025
45c1d90
update background color
mkzie2 Feb 8, 2025
f61fcf9
Merge branch 'main' into mkzie2-issue/55083
mkzie2 Feb 8, 2025
f5d92c9
update border radius of icon
mkzie2 Feb 8, 2025
7115d24
Merge branch 'main' into mkzie2-issue/55083
mkzie2 Feb 11, 2025
7ff2699
merge main
mkzie2 Feb 12, 2025
dbcc4d2
update background with svg and update reecipt content background color
mkzie2 Feb 12, 2025
ffb2f11
Merge branch 'main' into mkzie2-issue/55083
mkzie2 Feb 14, 2025
d102c6b
run test
mkzie2 Feb 14, 2025
35103ce
fix lint
mkzie2 Feb 14, 2025
b98e443
Merge branch 'main' into mkzie2-issue/55083
mkzie2 Feb 16, 2025
e02d132
Merge branch 'main' into mkzie2-issue/55083
mkzie2 Feb 17, 2025
03a0061
fix mobile style
mkzie2 Feb 18, 2025
a37e30d
remove hard code
mkzie2 Feb 18, 2025
3f09472
update the height of reecipt preview
mkzie2 Feb 18, 2025
19eeff0
change the height of reecipt in money request view
mkzie2 Feb 18, 2025
87d1072
Merge branch 'main' into mkzie2-issue/55083
mkzie2 Feb 19, 2025
1be46df
update ERecipt in search using the transaction data from snapshot
mkzie2 Feb 19, 2025
1405ef9
Merge branch 'main' into mkzie2-issue/55083
mkzie2 Feb 20, 2025
bd3a4a0
Merge branch 'main' into mkzie2-issue/55083
mkzie2 Feb 24, 2025
f990808
fix the receipt is scrollable
mkzie2 Feb 24, 2025
549c582
Merge branch 'main' into mkzie2-issue/55083
mkzie2 Feb 26, 2025
a28e965
fix EReceipt preview style
mkzie2 Feb 26, 2025
db16a66
fix native style
mkzie2 Feb 26, 2025
e683dcc
fix prettier
mkzie2 Feb 26, 2025
deb227c
Merge branch 'main' into mkzie2-issue/55083
mkzie2 Mar 3, 2025
e7ba3d9
implement EReceiptWithSizeCalculation
mkzie2 Mar 3, 2025
13ca6bb
run prettier
mkzie2 Mar 3, 2025
3cea812
Merge branch 'main' into mkzie2-issue/55083
mkzie2 Mar 8, 2025
bc01485
fix the scale issue
mkzie2 Mar 8, 2025
7b58bc5
fix two line merchant
mkzie2 Mar 8, 2025
bd292d3
Merge branch 'main' into mkzie2-issue/55083
mkzie2 Mar 10, 2025
7ff6836
fix related bug in search
mkzie2 Mar 10, 2025
35160af
Merge branch 'main' into mkzie2-issue/55083
mkzie2 Mar 11, 2025
917e15c
update receipt padding style
mkzie2 Mar 11, 2025
1c330ac
update width of the eReceipt in MoneyRequestView
mkzie2 Mar 11, 2025
e7ad0ac
Merge branch 'main' into mkzie2-issue/55083
mkzie2 Mar 11, 2025
df411ec
Merge branch 'main' into mkzie2-issue/55083
mkzie2 Mar 15, 2025
89a78e9
fix perdiem request EReceipt
mkzie2 Mar 15, 2025
a25d34b
fix lint
mkzie2 Mar 15, 2025
4873924
fix error
mkzie2 Mar 15, 2025
93e29f5
Merge branch 'main' into mkzie2-issue/55083
mkzie2 Mar 17, 2025
23b195e
Merge branch 'main' into mkzie2-issue/55083
mkzie2 Mar 17, 2025
10a1b7c
Merge branch 'main' into mkzie2-issue/55083
mkzie2 Mar 18, 2025
42f9d50
make eReceipt preview to none select
mkzie2 Mar 18, 2025
9490ae3
Merge branch 'main' into mkzie2-issue/55083
mkzie2 Mar 18, 2025
fb723a4
add padding right for amount
mkzie2 Mar 18, 2025
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 removed assets/images/eReceiptBGs/eReceiptBG_blue.png
Binary file not shown.
435 changes: 435 additions & 0 deletions assets/images/eReceiptBGs/eReceiptBG_blue.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed assets/images/eReceiptBGs/eReceiptBG_green.png
Binary file not shown.
482 changes: 482 additions & 0 deletions assets/images/eReceiptBGs/eReceiptBG_green.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
546 changes: 546 additions & 0 deletions assets/images/eReceiptBGs/eReceiptBG_ice.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed assets/images/eReceiptBGs/eReceiptBG_navy.png
Binary file not shown.
Binary file removed assets/images/eReceiptBGs/eReceiptBG_pink.png
Binary file not shown.
620 changes: 620 additions & 0 deletions assets/images/eReceiptBGs/eReceiptBG_pink.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed assets/images/eReceiptBGs/eReceiptBG_tangerine.png
Binary file not shown.
631 changes: 631 additions & 0 deletions assets/images/eReceiptBGs/eReceiptBG_tangerine.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed assets/images/eReceiptBGs/eReceiptBG_yellow.png
Binary file not shown.
584 changes: 584 additions & 0 deletions assets/images/eReceiptBGs/eReceiptBG_yellow.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 26 additions & 0 deletions assets/images/receipt-body.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 9 additions & 2 deletions src/ROUTES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1772,8 +1772,15 @@ const ROUTES = {

TRANSACTION_RECEIPT: {
route: 'r/:reportID/transaction/:transactionID/receipt',
getRoute: (reportID: string, transactionID: string, readonly = false, isFromReviewDuplicates = false) =>
`r/${reportID}/transaction/${transactionID}/receipt?readonly=${readonly}${isFromReviewDuplicates ? '&isFromReviewDuplicates=true' : ''}` as const,
getRoute: (reportID: string | undefined, transactionID: string | undefined, readonly = false, isFromReviewDuplicates = false) => {
if (!reportID) {
Log.warn('Invalid reportID is used to build the TRANSACTION_RECEIPT route');
}
if (!transactionID) {
Log.warn('Invalid transactionID is used to build the TRANSACTION_RECEIPT route');
}
return `r/${reportID}/transaction/${transactionID}/receipt?readonly=${readonly}${isFromReviewDuplicates ? '&isFromReviewDuplicates=true' : ''}` as const;
},
},

TRANSACTION_DUPLICATE_REVIEW_PAGE: {
Expand Down
192 changes: 123 additions & 69 deletions src/components/EReceipt.tsx
Original file line number Diff line number Diff line change
@@ -1,109 +1,163 @@
import React from 'react';
import {View} from 'react-native';
import type {OnyxEntry} from 'react-native-onyx';
import {withOnyx} from 'react-native-onyx';
import {useOnyx} from 'react-native-onyx';
import useEReceipt from '@hooks/useEReceipt';
import useLocalize from '@hooks/useLocalize';
import useStyleUtils from '@hooks/useStyleUtils';
import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';
import * as CardUtils from '@libs/CardUtils';
import * as CurrencyUtils from '@libs/CurrencyUtils';
import * as ReportUtils from '@libs/ReportUtils';
import * as TransactionUtils from '@libs/TransactionUtils';
import {getCardDescription} from '@libs/CardUtils';
import {convertToDisplayString, getCurrencySymbol} from '@libs/CurrencyUtils';
import {getTransactionDetails} from '@libs/ReportUtils';
import {getCardName} from '@libs/TransactionUtils';
import variables from '@styles/variables';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import type {Transaction} from '@src/types/onyx';
import EReceiptThumbnail from './EReceiptThumbnail';
import Icon from './Icon';
import * as Expensicons from './Icon/Expensicons';
import ImageSVG from './ImageSVG';
import type {TransactionListItemType} from './SelectionList/types';
import Text from './Text';

type EReceiptOnyxProps = {
transaction: OnyxEntry<Transaction>;
};

type EReceiptProps = EReceiptOnyxProps & {
type EReceiptProps = {
/* TransactionID of the transaction this EReceipt corresponds to */
transactionID: string;
transactionID: string | undefined;

/** The transaction data in search */
transactionItem?: TransactionListItemType;

/** Where it is the preview */
isThumbnail?: boolean;
};

function EReceipt({transaction, transactionID}: EReceiptProps) {
const receiptMCCSize: number = variables.eReceiptMCCHeightWidthMedium;
const backgroundImageMinWidth: number = variables.eReceiptBackgroundImageMinWidth;
function EReceipt({transactionID, transactionItem, isThumbnail = false}: EReceiptProps) {
const styles = useThemeStyles();
const StyleUtils = useStyleUtils();
const {translate} = useLocalize();
const theme = useTheme();

const [transaction] = useOnyx(`${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`);

// Get receipt colorway, or default to Yellow.
const {backgroundColor: primaryColor, color: secondaryColor} = StyleUtils.getEReceiptColorStyles(StyleUtils.getEReceiptColorCode(transaction)) ?? {};
const {primaryColor, secondaryColor, titleColor, MCCIcon, tripIcon, backgroundImage} = useEReceipt(transactionItem ?? transaction);

const {
amount: transactionAmount,
currency: transactionCurrency,
merchant: transactionMerchant,
created: transactionDate,
cardID: transactionCardID,
} = ReportUtils.getTransactionDetails(transaction, CONST.DATE.MONTH_DAY_YEAR_FORMAT) ?? {};
const formattedAmount = CurrencyUtils.convertToDisplayString(transactionAmount, transactionCurrency);
const currency = CurrencyUtils.getCurrencySymbol(transactionCurrency ?? '');
} = getTransactionDetails(transactionItem ?? transaction, CONST.DATE.MONTH_DAY_YEAR_FORMAT) ?? {};
const formattedAmount = convertToDisplayString(transactionAmount, transactionCurrency);
const currency = getCurrencySymbol(transactionCurrency ?? '');
const amount = currency ? formattedAmount.replace(currency, '') : formattedAmount;
const cardDescription = TransactionUtils.getCardName(transaction) ?? (transactionCardID ? CardUtils.getCardDescription(transactionCardID) : '');
const cardDescription = getCardName(transaction) ?? (transactionCardID ? getCardDescription(transactionCardID) : '');

const secondaryTextColorStyle = secondaryColor ? StyleUtils.getColorStyle(secondaryColor) : undefined;
const secondaryBgcolorStyle = secondaryColor ? StyleUtils.getBackgroundColorStyle(secondaryColor) : undefined;
const primaryTextColorStyle = primaryColor ? StyleUtils.getColorStyle(primaryColor) : undefined;
const titleTextColorStyle = titleColor ? StyleUtils.getColorStyle(titleColor) : undefined;

return (
<View style={[styles.eReceiptContainer, primaryColor ? StyleUtils.getBackgroundColorStyle(primaryColor) : undefined]}>
<View style={styles.fullScreen}>
<EReceiptThumbnail
transactionID={transactionID}
centerIconV={false}
/>
</View>
<View style={[styles.alignItemsCenter, styles.ph8, styles.pb14, styles.pt8]}>
<View style={[StyleUtils.getWidthAndHeightStyle(variables.eReceiptIconWidth, variables.eReceiptIconHeight)]} />
</View>
<View style={[styles.flexColumn, styles.justifyContentBetween, styles.alignItemsCenter, styles.ph9, styles.flex1]}>
<View style={[styles.alignItemsCenter, styles.alignSelfCenter, styles.flexColumn, styles.gap2, styles.mb8]}>
<View style={[styles.flexRow, styles.justifyContentCenter, StyleUtils.getWidthStyle(variables.eReceiptTextContainerWidth)]}>
<View style={[styles.flexColumn, styles.pt1]}>
<Text style={[styles.eReceiptCurrency, secondaryTextColorStyle]}>{currency}</Text>
</View>
<Text
adjustsFontSizeToFit
style={[styles.eReceiptAmountLarge, secondaryTextColorStyle]}
>
{amount}
</Text>
</View>
<Text style={[styles.eReceiptMerchant, styles.breakWord, styles.textAlignCenter]}>{transactionMerchant}</Text>
<View
style={[
styles.eReceiptContainer,
primaryColor ? StyleUtils.getBackgroundColorStyle(primaryColor) : undefined,
isThumbnail && StyleUtils.getMinimumWidth(variables.eReceiptBGHWidth),
]}
>
<View style={[styles.flex1, primaryColor ? StyleUtils.getBackgroundColorStyle(primaryColor) : {}, styles.overflowHidden, styles.alignItemsCenter, styles.justifyContentCenter]}>
<View style={[styles.eReceiptBackgroundThumbnail, StyleUtils.getMinimumWidth(backgroundImageMinWidth)]}>
<ImageSVG src={backgroundImage} />
</View>
<View style={[styles.alignSelfStretch, styles.flexColumn, styles.mb8, styles.gap4]}>
<View style={[styles.flexColumn, styles.gap1]}>
<Text style={[styles.eReceiptWaypointTitle, secondaryTextColorStyle]}>{translate('eReceipt.transactionDate')}</Text>
<Text style={[styles.eReceiptWaypointAddress]}>{transactionDate}</Text>
</View>
<View style={[styles.flexColumn, styles.gap1]}>
<Text style={[styles.eReceiptWaypointTitle, secondaryTextColorStyle]}>{translate('common.card')}</Text>
<Text style={[styles.eReceiptWaypointAddress]}>{cardDescription}</Text>
<View style={styles.eReceiptContentContainer}>
<View>
<ImageSVG
src={Expensicons.ReceiptBody}
fill={theme.textColorfulBackground}
contentFit="fill"
/>
<View style={styles.eReceiptContentWrapper}>
<View style={[StyleUtils.getBackgroundColorStyle(theme.textColorfulBackground), styles.alignItemsCenter, styles.justifyContentCenter, styles.h100]}>
<View
style={[
StyleUtils.getWidthAndHeightStyle(variables.eReceiptEmptyIconWidth, variables.eReceiptEmptyIconWidth),
styles.alignItemsCenter,
styles.justifyContentCenter,
styles.borderRadiusComponentNormal,
secondaryBgcolorStyle,
styles.mb3,
]}
>
<View>
{MCCIcon ? (
<Icon
src={MCCIcon}
height={receiptMCCSize}
width={receiptMCCSize}
fill={primaryColor}
/>
) : null}
{!MCCIcon && tripIcon ? (
<Icon
src={tripIcon}
height={receiptMCCSize}
width={receiptMCCSize}
fill={primaryColor}
/>
) : null}
</View>
</View>
<Text style={[styles.eReceiptGuaranteed, primaryTextColorStyle]}>{translate('eReceipt.guaranteed')}</Text>
<View style={[styles.alignItemsCenter]}>
<View style={[StyleUtils.getWidthAndHeightStyle(variables.eReceiptIconWidth, variables.h40)]} />
</View>
<View style={[styles.flexColumn, styles.justifyContentBetween, styles.alignItemsCenter, styles.ph9, styles.flex1]}>
<View style={[styles.alignItemsCenter, styles.alignSelfCenter, styles.flexColumn, styles.gap2]}>
<View style={[styles.flexRow, styles.justifyContentCenter, StyleUtils.getWidthStyle(variables.eReceiptTextContainerWidth)]}>
<View style={[styles.flexColumn, styles.pt1]}>
<Text style={[styles.eReceiptCurrency, primaryTextColorStyle]}>{currency}</Text>
</View>
<Text
adjustsFontSizeToFit
style={[styles.eReceiptAmountLarge, primaryTextColorStyle, styles.pr4]}
>
{amount}
</Text>
</View>
<Text style={[styles.eReceiptMerchant, styles.breakWord, styles.textAlignCenter, primaryTextColorStyle]}>{transactionMerchant}</Text>
</View>
<View style={[styles.alignSelfStretch, styles.flexColumn, styles.gap4, styles.ph3]}>
<View style={[styles.flexColumn, styles.gap1]}>
<Text style={[styles.eReceiptWaypointTitle, titleTextColorStyle]}>{translate('eReceipt.transactionDate')}</Text>
<Text style={[styles.eReceiptWaypointAddress, primaryTextColorStyle]}>{transactionDate}</Text>
</View>
<View style={[styles.flexColumn, styles.gap1]}>
<Text style={[styles.eReceiptWaypointTitle, titleTextColorStyle]}>{translate('common.card')}</Text>
<Text style={[styles.eReceiptWaypointAddress, primaryTextColorStyle]}>{cardDescription}</Text>
</View>
</View>
<View>
<View style={[styles.alignItemsCenter, styles.alignSelfStretch, styles.flexRow, styles.w100, styles.mb8]}>
<Icon
width={variables.eReceiptWordmarkWidth}
height={variables.eReceiptWordmarkHeight}
fill={secondaryColor}
src={Expensicons.ExpensifyWordmark}
/>
</View>
</View>
</View>
</View>
</View>
</View>
</View>
<View style={[styles.justifyContentBetween, styles.alignItemsCenter, styles.alignSelfStretch, styles.flexRow, styles.mb8]}>
<Icon
width={variables.eReceiptWordmarkWidth}
height={variables.eReceiptWordmarkHeight}
fill={secondaryColor}
src={Expensicons.ExpensifyWordmark}
/>
<Text style={styles.eReceiptGuaranteed}>{translate('eReceipt.guaranteed')}</Text>
</View>
</View>
</View>
);
}

EReceipt.displayName = 'EReceipt';

export default withOnyx<EReceiptProps, EReceiptOnyxProps>({
transaction: {
key: ({transactionID}) => `${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`,
},
})(EReceipt);
export type {EReceiptProps, EReceiptOnyxProps};
export default EReceipt;
export type {EReceiptProps};
Loading