-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for displaying ECard Transaction in ReportPreviews
- Loading branch information
Showing
14 changed files
with
209 additions
and
20 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
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
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
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
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 |
---|---|---|
|
@@ -6,6 +6,8 @@ import ReceiptHTML from '../../assets/images/receipt-html.png'; | |
import ReceiptDoc from '../../assets/images/receipt-doc.png'; | ||
import ReceiptGeneric from '../../assets/images/receipt-generic.png'; | ||
import ReceiptSVG from '../../assets/images/receipt-svg.png'; | ||
import { Transaction } from '../types/onyx'; | ||
import ROUTES from '../ROUTES'; | ||
|
||
type ThumbnailAndImageURI = { | ||
image: ImageSourcePropType | string; | ||
|
@@ -20,12 +22,21 @@ type FileNameAndExtension = { | |
/** | ||
* Grab the appropriate receipt image and thumbnail URIs based on file type | ||
* | ||
* @param path URI to image, i.e. blob:new.expensify.com/9ef3a018-4067-47c6-b29f-5f1bd35f213d or expensify.com/receipts/w_e616108497ef940b7210ec6beb5a462d01a878f4.jpg | ||
* @param filename of uploaded image or last part of remote URI | ||
* @param transaction | ||
*/ | ||
function getThumbnailAndImageURIs(path: string, filename: string): ThumbnailAndImageURI { | ||
function getThumbnailAndImageURIs(transaction: Transaction): ThumbnailAndImageURI { | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
grgia
Author
Contributor
|
||
// URI to image, i.e. blob:new.expensify.com/9ef3a018-4067-47c6-b29f-5f1bd35f213d or expensify.com/receipts/w_e616108497ef940b7210ec6beb5a462d01a878f4.jpg | ||
const path = transaction?.receipt?.source ?? 'https://hips.hearstapps.com/hmg-prod/images/dog-puppy-on-garden-royalty-free-image-1586966191.jpg?crop=0.752xw:1.00xh;0.175xw,0&resize=1200:*'; | ||
// filename of uploaded image or last part of remote URI | ||
const filename = transaction?.filename ?? ''; | ||
const isReceiptImage = Str.isImage(filename); | ||
|
||
const hasEReceipt = transaction?.hasEReceipt; | ||
|
||
if(hasEReceipt){ | ||
return {thumbnail: null, image: ROUTES.ERECEIPT.getRoute(transaction.transactionID)}; | ||
} | ||
|
||
// For local files, we won't have a thumbnail yet | ||
if (isReceiptImage && (path.startsWith('blob:') || path.startsWith('file:'))) { | ||
return {thumbnail: null, image: path}; | ||
|
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,149 @@ | ||
import React from 'react'; | ||
import ReportActionItemImages from '../components/ReportActionItem/ReportActionItemImages'; | ||
import PressableWithoutFeedback from '../components/Pressable/PressableWithoutFeedback'; | ||
|
||
/** | ||
* We use the Component Story Format for writing stories. Follow the docs here: | ||
* | ||
* https://storybook.js.org/docs/react/writing-stories/introduction#component-story-format | ||
*/ | ||
const story = { | ||
title: 'Components/ReportActionItemImages', | ||
component: ReportActionItemImages, | ||
}; | ||
|
||
function Template(args) { | ||
return ( | ||
<PressableWithoutFeedback | ||
accessibilityLabel="ReportActionItemImages Story" | ||
style={{flex: 1}} | ||
> | ||
{({hovered}) => ( | ||
<ReportActionItemImages | ||
// eslint-disable-next-line react/jsx-props-no-spreading | ||
{...args} | ||
isHovered={hovered} | ||
/> | ||
)} | ||
</PressableWithoutFeedback> | ||
); | ||
} | ||
|
||
// Arguments can be passed to the component by binding | ||
// See: https://storybook.js.org/docs/react/writing-stories/introduction#using-args | ||
const Default = Template.bind({}); | ||
Default.args = { | ||
images: [{image: 'https://c02.purpledshub.com/uploads/sites/41/2021/05/sleeping-cat-27126ee.jpg', thumbnail: ''}], | ||
size: 1, | ||
total: 1, | ||
}; | ||
|
||
const DisplayJSX = Template.bind({}); | ||
DisplayJSX.args = { | ||
images: [{image: 'eReceipt/FAKE_3', thumbnail: ''}], | ||
size: 1, | ||
total: 1, | ||
}; | ||
|
||
const TwoImages = Template.bind({}); | ||
TwoImages.args = { | ||
images: [ | ||
{ | ||
image: 'https://c02.purpledshub.com/uploads/sites/41/2021/05/sleeping-cat-27126ee.jpg', | ||
thumbnail: '', | ||
}, | ||
{ | ||
image: 'https://i.guim.co.uk/img/media/7d04c4cb7510a4bd9a8bec449f53425aeccee895/298_266_1150_690/master/1150.jpg?width=1200&quality=85&auto=format&fit=max&s=4ae508ecb99c15ec04610b617efb3fa7', | ||
thumbnail: '', | ||
}, | ||
], | ||
size: 2, | ||
total: 2, | ||
}; | ||
|
||
const ThreeImages = Template.bind({}); | ||
ThreeImages.args = { | ||
images: [ | ||
{ | ||
image: 'https://c02.purpledshub.com/uploads/sites/41/2021/05/sleeping-cat-27126ee.jpg', | ||
thumbnail: '', | ||
}, | ||
{ | ||
image: 'https://i.guim.co.uk/img/media/7d04c4cb7510a4bd9a8bec449f53425aeccee895/298_266_1150_690/master/1150.jpg?width=1200&quality=85&auto=format&fit=max&s=4ae508ecb99c15ec04610b617efb3fa7', | ||
thumbnail: '', | ||
}, | ||
{ | ||
image: 'https://cdn.theatlantic.com/thumbor/d8lh_KAZuOgBYslMOP4T0iu9Fks=/0x62:2000x1187/1600x900/media/img/mt/2018/03/AP_325360162607/original.jpg', | ||
thumbnail: '', | ||
}, | ||
], | ||
size: 3, | ||
total: 3, | ||
}; | ||
|
||
const FourImages = Template.bind({}); | ||
FourImages.args = { | ||
images: [ | ||
{ | ||
image: 'https://c02.purpledshub.com/uploads/sites/41/2021/05/sleeping-cat-27126ee.jpg', | ||
thumbnail: '', | ||
}, | ||
{ | ||
image: 'https://i.guim.co.uk/img/media/7d04c4cb7510a4bd9a8bec449f53425aeccee895/298_266_1150_690/master/1150.jpg?width=1200&quality=85&auto=format&fit=max&s=4ae508ecb99c15ec04610b617efb3fa7', | ||
thumbnail: '', | ||
}, | ||
{ | ||
image: 'https://cdn.theatlantic.com/thumbor/d8lh_KAZuOgBYslMOP4T0iu9Fks=/0x62:2000x1187/1600x900/media/img/mt/2018/03/AP_325360162607/original.jpg', | ||
thumbnail: '', | ||
}, | ||
{ | ||
image: 'https://www.alleycat.org/wp-content/uploads/2019/03/FELV-cat.jpg', | ||
thumbnail: '', | ||
}, | ||
], | ||
size: 4, | ||
total: 4, | ||
}; | ||
|
||
const ThreePlusTwoImages = Template.bind({}); | ||
ThreePlusTwoImages.args = { | ||
images: [ | ||
{ | ||
image: 'https://c02.purpledshub.com/uploads/sites/41/2021/05/sleeping-cat-27126ee.jpg', | ||
thumbnail: '', | ||
}, | ||
{ | ||
image: 'https://i.guim.co.uk/img/media/7d04c4cb7510a4bd9a8bec449f53425aeccee895/298_266_1150_690/master/1150.jpg?width=1200&quality=85&auto=format&fit=max&s=4ae508ecb99c15ec04610b617efb3fa7', | ||
thumbnail: '', | ||
}, | ||
{ | ||
image: 'https://cdn.theatlantic.com/thumbor/d8lh_KAZuOgBYslMOP4T0iu9Fks=/0x62:2000x1187/1600x900/media/img/mt/2018/03/AP_325360162607/original.jpg', | ||
thumbnail: '', | ||
}, | ||
], | ||
size: 3, | ||
total: 5, | ||
}; | ||
|
||
const ThreePlusTenImages = Template.bind({}); | ||
ThreePlusTenImages.args = { | ||
images: [ | ||
{ | ||
image: 'https://c02.purpledshub.com/uploads/sites/41/2021/05/sleeping-cat-27126ee.jpg', | ||
thumbnail: '', | ||
}, | ||
{ | ||
image: 'https://i.guim.co.uk/img/media/7d04c4cb7510a4bd9a8bec449f53425aeccee895/298_266_1150_690/master/1150.jpg?width=1200&quality=85&auto=format&fit=max&s=4ae508ecb99c15ec04610b617efb3fa7', | ||
thumbnail: '', | ||
}, | ||
{ | ||
image: 'https://cdn.theatlantic.com/thumbor/d8lh_KAZuOgBYslMOP4T0iu9Fks=/0x62:2000x1187/1600x900/media/img/mt/2018/03/AP_325360162607/original.jpg', | ||
thumbnail: '', | ||
}, | ||
], | ||
size: 3, | ||
total: 13, | ||
}; | ||
|
||
export default story; | ||
export {Default, TwoImages, ThreeImages, FourImages, ThreePlusTwoImages, ThreePlusTenImages, DisplayJSX}; |
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
Hey @grgia, when you updated the params of this function you broke the receipt image for distance eReceipts, because you didn't update all uses of the function. Please be sure to follow the PR checklist item for this next time. I discovered the problem while working on this other issue.
Also this looks like a huge commit. I think keeping your commits smaller makes it easier to catch mistakes like this.