From 605dd88703b2e992dfb73db5731de3e00fdd958d Mon Sep 17 00:00:00 2001 From: sumo_slonik Date: Fri, 16 May 2025 16:07:15 +0200 Subject: [PATCH 01/15] mae transaction component a little bit mor elastic --- src/CONST.ts | 16 +++ .../MoneyRequestReportTransactionList.tsx | 10 ++ .../MoneyRequestReportPreview/index.tsx | 4 +- src/components/TransactionItemRow/index.tsx | 131 +++++++++++------- 4 files changed, 108 insertions(+), 53 deletions(-) diff --git a/src/CONST.ts b/src/CONST.ts index 3b0c98b37d37..31ecf9fb0d9e 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -1408,6 +1408,22 @@ const CONST = { TRANSACTION_LIST: { COLUMNS: { COMMENTS: 'comments', + RECEIPT: 'receipt', + DATE: 'date', + MERCHANT: 'merchant', + DESCRIPTION: 'description', + FROM: 'from', + TO: 'to', + CATEGORY: 'category', + TAG: 'tag', + TOTAL_AMOUNT: 'amount', + TYPE: 'type', + ACTION: 'action', + TAX_AMOUNT: 'taxAmount', + TITLE: 'title', + ASSIGNEE: 'assignee', + CREATED_BY: 'createdBy', + IN: 'in', }, }, CANCEL_PAYMENT_REASONS: { diff --git a/src/components/MoneyRequestReportView/MoneyRequestReportTransactionList.tsx b/src/components/MoneyRequestReportView/MoneyRequestReportTransactionList.tsx index 9bf9b1886cb0..7234317e3580 100644 --- a/src/components/MoneyRequestReportView/MoneyRequestReportTransactionList.tsx +++ b/src/components/MoneyRequestReportView/MoneyRequestReportTransactionList.tsx @@ -260,6 +260,16 @@ function MoneyRequestReportTransactionList({report, transactions, reportActions, shouldUseNarrowLayout={shouldUseNarrowLayout || isMediumScreenWidth} shouldShowCheckbox={!!selectionMode?.isEnabled || isMediumScreenWidth} onCheckboxPress={toggleTransaction} + columns={[ + CONST.REPORT.TRANSACTION_LIST.COLUMNS.RECEIPT, + CONST.REPORT.TRANSACTION_LIST.COLUMNS.TYPE, + CONST.REPORT.TRANSACTION_LIST.COLUMNS.DATE, + CONST.REPORT.TRANSACTION_LIST.COLUMNS.MERCHANT, + CONST.REPORT.TRANSACTION_LIST.COLUMNS.CATEGORY, + CONST.REPORT.TRANSACTION_LIST.COLUMNS.TAG, + CONST.REPORT.TRANSACTION_LIST.COLUMNS.COMMENTS, + CONST.REPORT.TRANSACTION_LIST.COLUMNS.TOTAL_AMOUNT, + ]} /> ); diff --git a/src/components/ReportActionItem/MoneyRequestReportPreview/index.tsx b/src/components/ReportActionItem/MoneyRequestReportPreview/index.tsx index dc8a7f984d0b..fc58a9ce0ae0 100644 --- a/src/components/ReportActionItem/MoneyRequestReportPreview/index.tsx +++ b/src/components/ReportActionItem/MoneyRequestReportPreview/index.tsx @@ -58,8 +58,8 @@ function MoneyRequestReportPreview({ const {isDelegateAccessRestricted} = useDelegateUserDetails(); const isTrackExpenseAction = isTrackExpenseActionReportActionsUtils(action); const isSplitBillAction = isSplitBillActionReportActionsUtils(action); - const [currentWidth, setCurrentWidth] = useState(256); - const [currentWrapperWidth, setCurrentWrapperWidth] = useState(256); + const [currentWidth, setCurrentWidth] = useState(1000); + const [currentWrapperWidth, setCurrentWrapperWidth] = useState(1000); const reportPreviewStyles = useMemo( () => StyleUtils.getMoneyRequestReportPreviewStyle(shouldUseNarrowLayout, currentWidth, currentWrapperWidth, transactions.length === 1), [StyleUtils, currentWidth, currentWrapperWidth, shouldUseNarrowLayout, transactions.length], diff --git a/src/components/TransactionItemRow/index.tsx b/src/components/TransactionItemRow/index.tsx index aaca88fbac54..d3752a8e609c 100644 --- a/src/components/TransactionItemRow/index.tsx +++ b/src/components/TransactionItemRow/index.tsx @@ -1,6 +1,7 @@ import React, {useMemo} from 'react'; import {View} from 'react-native'; import Animated from 'react-native-reanimated'; +import type {ValueOf} from 'type-fest'; import Checkbox from '@components/Checkbox'; import type {TransactionWithOptionalHighlight} from '@components/MoneyRequestReportView/MoneyRequestReportTransactionList'; import type {TableColumnSize} from '@components/Search/types'; @@ -23,6 +24,10 @@ import TotalCell from './DataCells/TotalCell'; import TypeCell from './DataCells/TypeCell'; import TransactionItemRowRBR from './TransactionItemRowRBR'; +type ColumnComponents = { + [key in ValueOf]: React.ReactElement; +}; + function TransactionItemRow({ transactionItem, shouldUseNarrowLayout, @@ -31,6 +36,7 @@ function TransactionItemRow({ dateColumnSize, onCheckboxPress, shouldShowCheckbox = false, + columns, }: { transactionItem: TransactionWithOptionalHighlight; shouldUseNarrowLayout: boolean; @@ -39,6 +45,7 @@ function TransactionItemRow({ dateColumnSize: TableColumnSize; onCheckboxPress: (transactionID: string) => void; shouldShowCheckbox: boolean; + columns: Array>; }) { const styles = useThemeStyles(); const StyleUtils = useStyleUtils(); @@ -70,6 +77,78 @@ function TransactionItemRow({ const merchantName = getMerchant(transactionItem); const isMerchantEmpty = isPartialMerchant(merchantName); + const columnComponent: ColumnComponents = { + [CONST.REPORT.TRANSACTION_LIST.COLUMNS.TYPE]: ( + + + + ), + [CONST.REPORT.TRANSACTION_LIST.COLUMNS.RECEIPT]: ( + + + + ), + + [CONST.REPORT.TRANSACTION_LIST.COLUMNS.TAG]: ( + + + + ), + [CONST.REPORT.TRANSACTION_LIST.COLUMNS.DATE]: ( + + + + ), + [CONST.REPORT.TRANSACTION_LIST.COLUMNS.CATEGORY]: ( + + + + ), + [CONST.REPORT.TRANSACTION_LIST.COLUMNS.ACTION]: , + [CONST.REPORT.TRANSACTION_LIST.COLUMNS.ASSIGNEE]: , + [CONST.REPORT.TRANSACTION_LIST.COLUMNS.CREATED_BY]: , + [CONST.REPORT.TRANSACTION_LIST.COLUMNS.DESCRIPTION]: , + [CONST.REPORT.TRANSACTION_LIST.COLUMNS.FROM]: , + [CONST.REPORT.TRANSACTION_LIST.COLUMNS.IN]: , + [CONST.REPORT.TRANSACTION_LIST.COLUMNS.MERCHANT]: ( + + + + ), + [CONST.REPORT.TRANSACTION_LIST.COLUMNS.TAX_AMOUNT]: , + [CONST.REPORT.TRANSACTION_LIST.COLUMNS.TITLE]: , + [CONST.REPORT.TRANSACTION_LIST.COLUMNS.TO]: , + [CONST.REPORT.TRANSACTION_LIST.COLUMNS.COMMENTS]: ( + + + + ), + amount: undefined, + }; + return ( - - - - - - - - - - - - - - - - - - - - - - - - + {columns.map((column) => columnComponent[column])} From ca4bc3cb204da10a77a9671c43549c3c90ea8e96 Mon Sep 17 00:00:00 2001 From: sumo_slonik Date: Mon, 19 May 2025 12:33:47 +0200 Subject: [PATCH 02/15] working mapping columns with correct spacing --- .../MoneyRequestReportTransactionList.tsx | 16 ++++- .../SelectionList/Search/ReportListItem.tsx | 71 ++++++++++++++----- .../DataCells/MerchantCell.tsx | 4 +- src/components/TransactionItemRow/index.tsx | 66 ++++++++++++++--- 4 files changed, 127 insertions(+), 30 deletions(-) diff --git a/src/components/MoneyRequestReportView/MoneyRequestReportTransactionList.tsx b/src/components/MoneyRequestReportView/MoneyRequestReportTransactionList.tsx index 7234317e3580..fc8899de40af 100644 --- a/src/components/MoneyRequestReportView/MoneyRequestReportTransactionList.tsx +++ b/src/components/MoneyRequestReportView/MoneyRequestReportTransactionList.tsx @@ -36,6 +36,7 @@ import CONST from '@src/CONST'; import NAVIGATORS from '@src/NAVIGATORS'; import ROUTES from '@src/ROUTES'; import type * as OnyxTypes from '@src/types/onyx'; +import type {SearchPersonalDetails, SearchTransactionAction} from '@src/types/onyx/SearchResults'; import {useMoneyRequestReportContext} from './MoneyRequestReportContext'; import MoneyRequestReportTableHeader from './MoneyRequestReportTableHeader'; import SearchMoneyRequestReportEmptyState from './SearchMoneyRequestReportEmptyState'; @@ -59,6 +60,19 @@ type TransactionWithOptionalHighlight = OnyxTypes.Transaction & { shouldBeHighlighted?: boolean; }; +type TransactionWithOptionalSearchFields = TransactionWithOptionalHighlight & { + /** The action that can be performed for the transaction */ + action?: SearchTransactionAction; + + onButtonPress?: () => void; + + /** The personal details of the user requesting money */ + from: SearchPersonalDetails; + + /** The personal details of the user paying the request */ + to: SearchPersonalDetails; +}; + const sortableColumnNames = [ CONST.SEARCH.TABLE_COLUMNS.DATE, CONST.SEARCH.TABLE_COLUMNS.MERCHANT, @@ -335,4 +349,4 @@ function MoneyRequestReportTransactionList({report, transactions, reportActions, MoneyRequestReportTransactionList.displayName = 'MoneyRequestReportTransactionList'; export default memo(MoneyRequestReportTransactionList); -export type {TransactionWithOptionalHighlight}; +export type {TransactionWithOptionalHighlight, TransactionWithOptionalSearchFields}; diff --git a/src/components/SelectionList/Search/ReportListItem.tsx b/src/components/SelectionList/Search/ReportListItem.tsx index d6ade86c5c06..99d404db467b 100644 --- a/src/components/SelectionList/Search/ReportListItem.tsx +++ b/src/components/SelectionList/Search/ReportListItem.tsx @@ -1,15 +1,18 @@ -import React from 'react'; +import React, {useMemo} from 'react'; import {View} from 'react-native'; import {useOnyx} from 'react-native-onyx'; import BaseListItem from '@components/SelectionList/BaseListItem'; import type {ListItem, ReportListItemProps, ReportListItemType, TransactionListItemType} from '@components/SelectionList/types'; import Text from '@components/Text'; +import TransactionItemRow from '@components/TransactionItemRow'; import useAnimatedHighlightStyle from '@hooks/useAnimatedHighlightStyle'; import useLocalize from '@hooks/useLocalize'; import usePermissions from '@hooks/usePermissions'; +import useResponsiveLayout from '@hooks/useResponsiveLayout'; import useTheme from '@hooks/useTheme'; import useThemeStyles from '@hooks/useThemeStyles'; import Navigation from '@libs/Navigation/Navigation'; +import shouldShowTransactionYear from '@libs/TransactionUtils/shouldShowTransactionYear'; import variables from '@styles/variables'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; @@ -38,6 +41,12 @@ function ReportListItem({ const policy = policies?.[`${ONYXKEYS.COLLECTION.POLICY}${reportItem?.policyID}`]; const isEmptyReport = reportItem.transactions.length === 0; const isDisabledOrEmpty = isEmptyReport || isDisabled; + const {isLargeScreenWidth} = useResponsiveLayout(); + + const dateColumnSize = useMemo(() => { + const shouldShowYearForSomeTransaction = reportItem.transactions.some((transaction) => shouldShowTransactionYear(transaction)); + return shouldShowYearForSomeTransaction ? CONST.SEARCH.TABLE_COLUMN_SIZES.WIDE : CONST.SEARCH.TABLE_COLUMN_SIZES.NORMAL; + }, [reportItem.transactions]); const animatedHighlightStyle = useAnimatedHighlightStyle({ borderRadius: variables.componentBorderRadius, @@ -119,23 +128,49 @@ function ReportListItem({ ) : ( reportItem.transactions.map((transaction) => ( - { - openReportInRHP(transaction); - }} - onCheckboxPress={() => onCheckboxPress?.(transaction as unknown as TItem)} - showItemHeaderOnNarrowLayout={false} - containerStyle={[transaction.isSelected && styles.activeComponentBG, styles.ph3, styles.pv1half]} - isChildListItem - isDisabled={!!isDisabled} - canSelectMultiple={!!canSelectMultiple} - isButtonSelected={transaction.isSelected} - shouldShowTransactionCheckbox - /> + + { + openReportInRHP(transaction); + }} + onCheckboxPress={() => onCheckboxPress?.(transaction as unknown as TItem)} + showItemHeaderOnNarrowLayout={false} + containerStyle={[transaction.isSelected && styles.activeComponentBG, styles.ph3, styles.pv1half]} + isChildListItem + isDisabled={!!isDisabled} + canSelectMultiple={!!canSelectMultiple} + isButtonSelected={transaction.isSelected} + shouldShowTransactionCheckbox + /> + onCheckboxPress?.(transaction as unknown as TItem)} + containerStyle={[transaction.isSelected && styles.activeComponentBG, styles.ph3, styles.pv1half]} + columns={[ + CONST.REPORT.TRANSACTION_LIST.COLUMNS.RECEIPT, + CONST.REPORT.TRANSACTION_LIST.COLUMNS.TYPE, + CONST.REPORT.TRANSACTION_LIST.COLUMNS.DATE, + CONST.REPORT.TRANSACTION_LIST.COLUMNS.MERCHANT, + CONST.REPORT.TRANSACTION_LIST.COLUMNS.FROM, + CONST.REPORT.TRANSACTION_LIST.COLUMNS.TO, + CONST.REPORT.TRANSACTION_LIST.COLUMNS.CATEGORY, + CONST.REPORT.TRANSACTION_LIST.COLUMNS.TOTAL_AMOUNT, + CONST.REPORT.TRANSACTION_LIST.COLUMNS.ACTION, + ]} + onButtonPress={() => { + openReportInRHP(transaction); + }} + /> + )) )} diff --git a/src/components/TransactionItemRow/DataCells/MerchantCell.tsx b/src/components/TransactionItemRow/DataCells/MerchantCell.tsx index 65dcd9e96177..092c8a84e83d 100644 --- a/src/components/TransactionItemRow/DataCells/MerchantCell.tsx +++ b/src/components/TransactionItemRow/DataCells/MerchantCell.tsx @@ -5,7 +5,7 @@ import {getMerchant} from '@libs/TransactionUtils'; import CONST from '@src/CONST'; import type TransactionDataCellProps from './TransactionDataCellProps'; -function MerchantCell({transactionItem, shouldShowTooltip}: TransactionDataCellProps) { +function MerchantCell({transactionItem, shouldShowTooltip, shouldUseNarrowLayout}: TransactionDataCellProps) { const styles = useThemeStyles(); const merchantName = getMerchant(transactionItem); @@ -15,7 +15,7 @@ function MerchantCell({transactionItem, shouldShowTooltip}: TransactionDataCellP ); } diff --git a/src/components/TransactionItemRow/index.tsx b/src/components/TransactionItemRow/index.tsx index d3752a8e609c..b8f711bd2016 100644 --- a/src/components/TransactionItemRow/index.tsx +++ b/src/components/TransactionItemRow/index.tsx @@ -1,11 +1,14 @@ import React, {useMemo} from 'react'; import {View} from 'react-native'; +import type {StyleProp, ViewStyle} from 'react-native'; import Animated from 'react-native-reanimated'; import type {ValueOf} from 'type-fest'; import Checkbox from '@components/Checkbox'; -import type {TransactionWithOptionalHighlight} from '@components/MoneyRequestReportView/MoneyRequestReportTransactionList'; +import type {TransactionWithOptionalSearchFields} from '@components/MoneyRequestReportView/MoneyRequestReportTransactionList'; import type {TableColumnSize} from '@components/Search/types'; +import ActionCell from '@components/SelectionList/Search/ActionCell'; import DateCell from '@components/SelectionList/Search/DateCell'; +import UserInfoCell from '@components/SelectionList/Search/UserInfoCell'; import Text from '@components/Text'; import useAnimatedHighlightStyle from '@hooks/useAnimatedHighlightStyle'; import useHover from '@hooks/useHover'; @@ -37,15 +40,19 @@ function TransactionItemRow({ onCheckboxPress, shouldShowCheckbox = false, columns, + containerStyle, + onButtonPress, }: { - transactionItem: TransactionWithOptionalHighlight; + transactionItem: TransactionWithOptionalSearchFields; shouldUseNarrowLayout: boolean; isSelected: boolean; shouldShowTooltip: boolean; dateColumnSize: TableColumnSize; onCheckboxPress: (transactionID: string) => void; shouldShowCheckbox: boolean; - columns: Array>; + columns?: Array>; + containerStyle?: StyleProp; + onButtonPress: () => void; }) { const styles = useThemeStyles(); const StyleUtils = useStyleUtils(); @@ -123,30 +130,71 @@ function TransactionItemRow({ /> ), - [CONST.REPORT.TRANSACTION_LIST.COLUMNS.ACTION]: , + [CONST.REPORT.TRANSACTION_LIST.COLUMNS.ACTION]: ( + + {!!transactionItem.action && ( + + )} + + ), [CONST.REPORT.TRANSACTION_LIST.COLUMNS.ASSIGNEE]: , [CONST.REPORT.TRANSACTION_LIST.COLUMNS.CREATED_BY]: , [CONST.REPORT.TRANSACTION_LIST.COLUMNS.DESCRIPTION]: , - [CONST.REPORT.TRANSACTION_LIST.COLUMNS.FROM]: , [CONST.REPORT.TRANSACTION_LIST.COLUMNS.IN]: , [CONST.REPORT.TRANSACTION_LIST.COLUMNS.MERCHANT]: ( ), [CONST.REPORT.TRANSACTION_LIST.COLUMNS.TAX_AMOUNT]: , [CONST.REPORT.TRANSACTION_LIST.COLUMNS.TITLE]: , - [CONST.REPORT.TRANSACTION_LIST.COLUMNS.TO]: , + [CONST.REPORT.TRANSACTION_LIST.COLUMNS.TO]: ( + + {!!transactionItem.to && ( + + )} + + ), + [CONST.REPORT.TRANSACTION_LIST.COLUMNS.FROM]: ( + + {!!transactionItem.from && ( + + )} + + ), [CONST.REPORT.TRANSACTION_LIST.COLUMNS.COMMENTS]: ( ), - amount: undefined, + [CONST.REPORT.TRANSACTION_LIST.COLUMNS.TOTAL_AMOUNT]: ( + + + + ), }; return ( @@ -256,7 +304,7 @@ function TransactionItemRow({ isChecked={isSelected} /> - {columns.map((column) => columnComponent[column])} + {columns?.map((column) => columnComponent[column])} From 851862f7567add2b9d393b4edda4ac2b7592ae5f Mon Sep 17 00:00:00 2001 From: sumo_slonik Date: Mon, 19 May 2025 14:21:31 +0200 Subject: [PATCH 03/15] working highlighting and fixed types problems --- src/CONST.ts | 6 - .../MoneyRequestReportTransactionList.tsx | 4 +- .../SelectionList/Search/ReportListItem.tsx | 117 ++++++++---------- src/components/TransactionItemRow/index.tsx | 19 +-- 4 files changed, 59 insertions(+), 87 deletions(-) diff --git a/src/CONST.ts b/src/CONST.ts index 31ecf9fb0d9e..da069ccc4d1b 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -1411,7 +1411,6 @@ const CONST = { RECEIPT: 'receipt', DATE: 'date', MERCHANT: 'merchant', - DESCRIPTION: 'description', FROM: 'from', TO: 'to', CATEGORY: 'category', @@ -1419,11 +1418,6 @@ const CONST = { TOTAL_AMOUNT: 'amount', TYPE: 'type', ACTION: 'action', - TAX_AMOUNT: 'taxAmount', - TITLE: 'title', - ASSIGNEE: 'assignee', - CREATED_BY: 'createdBy', - IN: 'in', }, }, CANCEL_PAYMENT_REASONS: { diff --git a/src/components/MoneyRequestReportView/MoneyRequestReportTransactionList.tsx b/src/components/MoneyRequestReportView/MoneyRequestReportTransactionList.tsx index fc8899de40af..2fa6f309d554 100644 --- a/src/components/MoneyRequestReportView/MoneyRequestReportTransactionList.tsx +++ b/src/components/MoneyRequestReportView/MoneyRequestReportTransactionList.tsx @@ -67,10 +67,10 @@ type TransactionWithOptionalSearchFields = TransactionWithOptionalHighlight & { onButtonPress?: () => void; /** The personal details of the user requesting money */ - from: SearchPersonalDetails; + from?: SearchPersonalDetails; /** The personal details of the user paying the request */ - to: SearchPersonalDetails; + to?: SearchPersonalDetails; }; const sortableColumnNames = [ diff --git a/src/components/SelectionList/Search/ReportListItem.tsx b/src/components/SelectionList/Search/ReportListItem.tsx index 99d404db467b..ebfdb3231ee3 100644 --- a/src/components/SelectionList/Search/ReportListItem.tsx +++ b/src/components/SelectionList/Search/ReportListItem.tsx @@ -107,73 +107,58 @@ function ReportListItem({ hoverStyle={item.isSelected && styles.activeComponentBG} pressableWrapperStyle={[styles.mh5, animatedHighlightStyle]} > - - - {isEmptyReport ? ( - - - {translate('search.moneyRequestReport.emptyStateTitle')} - - - ) : ( - reportItem.transactions.map((transaction) => ( - - { - openReportInRHP(transaction); - }} - onCheckboxPress={() => onCheckboxPress?.(transaction as unknown as TItem)} - showItemHeaderOnNarrowLayout={false} - containerStyle={[transaction.isSelected && styles.activeComponentBG, styles.ph3, styles.pv1half]} - isChildListItem - isDisabled={!!isDisabled} - canSelectMultiple={!!canSelectMultiple} - isButtonSelected={transaction.isSelected} - shouldShowTransactionCheckbox - /> - onCheckboxPress?.(transaction as unknown as TItem)} - containerStyle={[transaction.isSelected && styles.activeComponentBG, styles.ph3, styles.pv1half]} - columns={[ - CONST.REPORT.TRANSACTION_LIST.COLUMNS.RECEIPT, - CONST.REPORT.TRANSACTION_LIST.COLUMNS.TYPE, - CONST.REPORT.TRANSACTION_LIST.COLUMNS.DATE, - CONST.REPORT.TRANSACTION_LIST.COLUMNS.MERCHANT, - CONST.REPORT.TRANSACTION_LIST.COLUMNS.FROM, - CONST.REPORT.TRANSACTION_LIST.COLUMNS.TO, - CONST.REPORT.TRANSACTION_LIST.COLUMNS.CATEGORY, - CONST.REPORT.TRANSACTION_LIST.COLUMNS.TOTAL_AMOUNT, - CONST.REPORT.TRANSACTION_LIST.COLUMNS.ACTION, - ]} - onButtonPress={() => { - openReportInRHP(transaction); - }} - /> + {(hovered) => ( + + + {isEmptyReport ? ( + + + {translate('search.moneyRequestReport.emptyStateTitle')} + - )) - )} - + ) : ( + reportItem.transactions.map((transaction) => ( + + onCheckboxPress?.(transaction as unknown as TItem)} + columns={[ + CONST.REPORT.TRANSACTION_LIST.COLUMNS.RECEIPT, + CONST.REPORT.TRANSACTION_LIST.COLUMNS.TYPE, + CONST.REPORT.TRANSACTION_LIST.COLUMNS.DATE, + CONST.REPORT.TRANSACTION_LIST.COLUMNS.MERCHANT, + CONST.REPORT.TRANSACTION_LIST.COLUMNS.FROM, + CONST.REPORT.TRANSACTION_LIST.COLUMNS.TO, + CONST.REPORT.TRANSACTION_LIST.COLUMNS.CATEGORY, + CONST.REPORT.TRANSACTION_LIST.COLUMNS.TOTAL_AMOUNT, + CONST.REPORT.TRANSACTION_LIST.COLUMNS.ACTION, + ]} + onButtonPress={() => { + openReportInRHP(transaction); + }} + isParentHovered={hovered} + /> + + )) + )} + + )} ); } diff --git a/src/components/TransactionItemRow/index.tsx b/src/components/TransactionItemRow/index.tsx index b8f711bd2016..11368dad1bb5 100644 --- a/src/components/TransactionItemRow/index.tsx +++ b/src/components/TransactionItemRow/index.tsx @@ -1,6 +1,5 @@ import React, {useMemo} from 'react'; import {View} from 'react-native'; -import type {StyleProp, ViewStyle} from 'react-native'; import Animated from 'react-native-reanimated'; import type {ValueOf} from 'type-fest'; import Checkbox from '@components/Checkbox'; @@ -40,8 +39,8 @@ function TransactionItemRow({ onCheckboxPress, shouldShowCheckbox = false, columns, - containerStyle, - onButtonPress, + onButtonPress = () => {}, + isParentHovered, }: { transactionItem: TransactionWithOptionalSearchFields; shouldUseNarrowLayout: boolean; @@ -51,8 +50,8 @@ function TransactionItemRow({ onCheckboxPress: (transactionID: string) => void; shouldShowCheckbox: boolean; columns?: Array>; - containerStyle?: StyleProp; - onButtonPress: () => void; + onButtonPress?: () => void; + isParentHovered?: boolean; }) { const styles = useThemeStyles(); const StyleUtils = useStyleUtils(); @@ -76,10 +75,10 @@ function TransactionItemRow({ return styles.activeComponentBG; } - if (hovered) { + if (hovered || isParentHovered) { return styles.hoveredComponentBG; } - }, [hovered, isSelected, styles.activeComponentBG, styles.hoveredComponentBG]); + }, [hovered, isParentHovered, isSelected, styles.activeComponentBG, styles.hoveredComponentBG]); const merchantName = getMerchant(transactionItem); const isMerchantEmpty = isPartialMerchant(merchantName); @@ -144,10 +143,6 @@ function TransactionItemRow({ )} ), - [CONST.REPORT.TRANSACTION_LIST.COLUMNS.ASSIGNEE]: , - [CONST.REPORT.TRANSACTION_LIST.COLUMNS.CREATED_BY]: , - [CONST.REPORT.TRANSACTION_LIST.COLUMNS.DESCRIPTION]: , - [CONST.REPORT.TRANSACTION_LIST.COLUMNS.IN]: , [CONST.REPORT.TRANSACTION_LIST.COLUMNS.MERCHANT]: ( ), - [CONST.REPORT.TRANSACTION_LIST.COLUMNS.TAX_AMOUNT]: , - [CONST.REPORT.TRANSACTION_LIST.COLUMNS.TITLE]: , [CONST.REPORT.TRANSACTION_LIST.COLUMNS.TO]: ( {!!transactionItem.to && ( From 928ca30cc7333db824149b7e799078e858517c18 Mon Sep 17 00:00:00 2001 From: sumo_slonik Date: Mon, 19 May 2025 15:56:39 +0200 Subject: [PATCH 04/15] update storybook --- src/stories/TransactionItemRow.stories.tsx | 37 ++++++++++++++++++++-- src/stories/objects/Transaction.ts | 20 ++++++++++++ 2 files changed, 54 insertions(+), 3 deletions(-) diff --git a/src/stories/TransactionItemRow.stories.tsx b/src/stories/TransactionItemRow.stories.tsx index 460d89573776..058936db578f 100644 --- a/src/stories/TransactionItemRow.stories.tsx +++ b/src/stories/TransactionItemRow.stories.tsx @@ -1,32 +1,50 @@ import type {Meta, StoryFn} from '@storybook/react'; import React from 'react'; +import type {ValueOf} from 'type-fest'; import ScreenWrapper from '@components/ScreenWrapper'; import ThemeProvider from '@components/ThemeProvider'; import ThemeStylesProvider from '@components/ThemeStylesProvider'; import TransactionItemRow from '@components/TransactionItemRow'; import CONST from '@src/CONST'; import type Transaction from '@src/types/onyx/Transaction'; -import transaction from './objects/Transaction'; +import {transactionWithOptionalSearchFields} from './objects/Transaction'; type TransactionItemRowStory = StoryFn; +const allAvailableColumns = [ + CONST.REPORT.TRANSACTION_LIST.COLUMNS.RECEIPT, + CONST.REPORT.TRANSACTION_LIST.COLUMNS.TYPE, + CONST.REPORT.TRANSACTION_LIST.COLUMNS.DATE, + CONST.REPORT.TRANSACTION_LIST.COLUMNS.MERCHANT, + CONST.REPORT.TRANSACTION_LIST.COLUMNS.FROM, + CONST.REPORT.TRANSACTION_LIST.COLUMNS.TO, + CONST.REPORT.TRANSACTION_LIST.COLUMNS.MERCHANT, + CONST.REPORT.TRANSACTION_LIST.COLUMNS.CATEGORY, + CONST.REPORT.TRANSACTION_LIST.COLUMNS.TAG, + CONST.REPORT.TRANSACTION_LIST.COLUMNS.TOTAL_AMOUNT, + CONST.REPORT.TRANSACTION_LIST.COLUMNS.ACTION, +]; + type TransactionItemRowProps = { transactionItem: Transaction; shouldUseNarrowLayout: boolean; isSelected: boolean; shouldShowTooltip: boolean; shouldShowCheckbox: boolean; + columns?: Array>; + isParentHovered?: boolean; }; const story: Meta = { title: 'Components/TransactionItemRow', component: TransactionItemRow, args: { - transactionItem: transaction, + transactionItem: transactionWithOptionalSearchFields, shouldUseNarrowLayout: false, isSelected: false, shouldShowTooltip: true, shouldShowCheckbox: true, + columns: allAvailableColumns, }, argTypes: { transactionItem: { @@ -44,6 +62,16 @@ const story: Meta = { shouldShowCheckbox: { control: 'boolean', }, + isParentHovered: { + control: 'boolean', + }, + + columns: { + control: { + type: 'check', + }, + options: allAvailableColumns, + }, }, parameters: { useLightTheme: true, @@ -51,7 +79,7 @@ const story: Meta = { }; function Template( - {transactionItem, shouldUseNarrowLayout, isSelected, shouldShowTooltip, shouldShowCheckbox}: TransactionItemRowProps, + {transactionItem, shouldUseNarrowLayout, isSelected, shouldShowTooltip, shouldShowCheckbox, columns, isParentHovered}: TransactionItemRowProps, {parameters}: {parameters: {useLightTheme?: boolean}}, ) { const theme = parameters.useLightTheme ? CONST.THEME.LIGHT : CONST.THEME.DARK; @@ -68,6 +96,9 @@ function Template( dateColumnSize={CONST.SEARCH.TABLE_COLUMN_SIZES.NORMAL} onCheckboxPress={() => {}} shouldShowCheckbox={shouldShowCheckbox} + columns={columns} + isParentHovered={isParentHovered} + onButtonPress={() => {}} /> diff --git a/src/stories/objects/Transaction.ts b/src/stories/objects/Transaction.ts index 177b97eed1bc..775d9a162b66 100644 --- a/src/stories/objects/Transaction.ts +++ b/src/stories/objects/Transaction.ts @@ -1,3 +1,5 @@ +import type {TransactionWithOptionalSearchFields} from '@components/MoneyRequestReportView/MoneyRequestReportTransactionList'; +import CONST from '@src/CONST'; import type Transaction from '@src/types/onyx/Transaction'; const transaction: Transaction & {mcc: string; modifiedMCC: string} = { @@ -36,4 +38,22 @@ const transaction: Transaction & {mcc: string; modifiedMCC: string} = { transactionID: '1564303948126109676', }; +const transactionWithOptionalSearchFields: TransactionWithOptionalSearchFields = { + ...transaction, + from: { + accountID: 1, + avatar: 'https://d2k5nsl2zxldvw.cloudfront.net/images/avatars/avatar_7.png', + displayName: 'johnDoe@example.com User', + login: 'johnDoe@example.com', + }, + to: { + accountID: 1, + avatar: 'https://d2k5nsl2zxldvw.cloudfront.net/images/avatars/avatar_7.png', + displayName: 'johnDoe@example.com User', + login: 'johnDoe@example.com', + }, + action: CONST.SEARCH.ACTION_TYPES.VIEW, +}; + export default transaction; +export {transactionWithOptionalSearchFields}; From 39656488470f9f517415506c8c7c7b7f31a0868a Mon Sep 17 00:00:00 2001 From: sumo_slonik Date: Mon, 19 May 2025 16:06:25 +0200 Subject: [PATCH 05/15] wrap in useMemo --- .../MoneyRequestReportPreview/index.tsx | 4 +- src/components/TransactionItemRow/index.tsx | 208 +++++++++--------- 2 files changed, 107 insertions(+), 105 deletions(-) diff --git a/src/components/ReportActionItem/MoneyRequestReportPreview/index.tsx b/src/components/ReportActionItem/MoneyRequestReportPreview/index.tsx index fc58a9ce0ae0..dc8a7f984d0b 100644 --- a/src/components/ReportActionItem/MoneyRequestReportPreview/index.tsx +++ b/src/components/ReportActionItem/MoneyRequestReportPreview/index.tsx @@ -58,8 +58,8 @@ function MoneyRequestReportPreview({ const {isDelegateAccessRestricted} = useDelegateUserDetails(); const isTrackExpenseAction = isTrackExpenseActionReportActionsUtils(action); const isSplitBillAction = isSplitBillActionReportActionsUtils(action); - const [currentWidth, setCurrentWidth] = useState(1000); - const [currentWrapperWidth, setCurrentWrapperWidth] = useState(1000); + const [currentWidth, setCurrentWidth] = useState(256); + const [currentWrapperWidth, setCurrentWrapperWidth] = useState(256); const reportPreviewStyles = useMemo( () => StyleUtils.getMoneyRequestReportPreviewStyle(shouldUseNarrowLayout, currentWidth, currentWrapperWidth, transactions.length === 1), [StyleUtils, currentWidth, currentWrapperWidth, shouldUseNarrowLayout, transactions.length], diff --git a/src/components/TransactionItemRow/index.tsx b/src/components/TransactionItemRow/index.tsx index 11368dad1bb5..2f77631ecb4e 100644 --- a/src/components/TransactionItemRow/index.tsx +++ b/src/components/TransactionItemRow/index.tsx @@ -82,113 +82,115 @@ function TransactionItemRow({ const merchantName = getMerchant(transactionItem); const isMerchantEmpty = isPartialMerchant(merchantName); + const columnComponent: ColumnComponents = useMemo( + () => ({ + [CONST.REPORT.TRANSACTION_LIST.COLUMNS.TYPE]: ( + + + + ), + [CONST.REPORT.TRANSACTION_LIST.COLUMNS.RECEIPT]: ( + + + + ), - const columnComponent: ColumnComponents = { - [CONST.REPORT.TRANSACTION_LIST.COLUMNS.TYPE]: ( - - - - ), - [CONST.REPORT.TRANSACTION_LIST.COLUMNS.RECEIPT]: ( - - - - ), - - [CONST.REPORT.TRANSACTION_LIST.COLUMNS.TAG]: ( - - - - ), - [CONST.REPORT.TRANSACTION_LIST.COLUMNS.DATE]: ( - - - - ), - [CONST.REPORT.TRANSACTION_LIST.COLUMNS.CATEGORY]: ( - - - - ), - [CONST.REPORT.TRANSACTION_LIST.COLUMNS.ACTION]: ( - - {!!transactionItem.action && ( - + - )} - - ), - [CONST.REPORT.TRANSACTION_LIST.COLUMNS.MERCHANT]: ( - - - - ), - [CONST.REPORT.TRANSACTION_LIST.COLUMNS.TO]: ( - - {!!transactionItem.to && ( - + ), + [CONST.REPORT.TRANSACTION_LIST.COLUMNS.DATE]: ( + + - )} - - ), - [CONST.REPORT.TRANSACTION_LIST.COLUMNS.FROM]: ( - - {!!transactionItem.from && ( - + ), + [CONST.REPORT.TRANSACTION_LIST.COLUMNS.CATEGORY]: ( + + - )} - - ), - [CONST.REPORT.TRANSACTION_LIST.COLUMNS.COMMENTS]: ( - - - - ), - [CONST.REPORT.TRANSACTION_LIST.COLUMNS.TOTAL_AMOUNT]: ( - - - - ), - }; + + ), + [CONST.REPORT.TRANSACTION_LIST.COLUMNS.ACTION]: ( + + {!!transactionItem.action && ( + + )} + + ), + [CONST.REPORT.TRANSACTION_LIST.COLUMNS.MERCHANT]: ( + + + + ), + [CONST.REPORT.TRANSACTION_LIST.COLUMNS.TO]: ( + + {!!transactionItem.to && ( + + )} + + ), + [CONST.REPORT.TRANSACTION_LIST.COLUMNS.FROM]: ( + + {!!transactionItem.from && ( + + )} + + ), + [CONST.REPORT.TRANSACTION_LIST.COLUMNS.COMMENTS]: ( + + + + ), + [CONST.REPORT.TRANSACTION_LIST.COLUMNS.TOTAL_AMOUNT]: ( + + + + ), + }), + [StyleUtils, createdAt, isDateColumnWide, isSelected, onButtonPress, shouldShowTooltip, shouldUseNarrowLayout, transactionItem], + ); return ( Date: Mon, 19 May 2025 16:12:22 +0200 Subject: [PATCH 06/15] remove unused import --- src/components/SelectionList/Search/ReportListItem.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/SelectionList/Search/ReportListItem.tsx b/src/components/SelectionList/Search/ReportListItem.tsx index ebfdb3231ee3..7bcccd76ff86 100644 --- a/src/components/SelectionList/Search/ReportListItem.tsx +++ b/src/components/SelectionList/Search/ReportListItem.tsx @@ -18,7 +18,6 @@ import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; import ReportListItemHeader from './ReportListItemHeader'; -import TransactionListItemRow from './TransactionListItemRow'; function ReportListItem({ item, From a82a5e60dbfec455bb3ccde7d57fc302a215e479 Mon Sep 17 00:00:00 2001 From: sumo_slonik Date: Mon, 19 May 2025 17:15:56 +0200 Subject: [PATCH 07/15] add comment --- .../MoneyRequestReportView/MoneyRequestReportTransactionList.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/MoneyRequestReportView/MoneyRequestReportTransactionList.tsx b/src/components/MoneyRequestReportView/MoneyRequestReportTransactionList.tsx index 2fa6f309d554..f67d7b30c1e2 100644 --- a/src/components/MoneyRequestReportView/MoneyRequestReportTransactionList.tsx +++ b/src/components/MoneyRequestReportView/MoneyRequestReportTransactionList.tsx @@ -64,6 +64,7 @@ type TransactionWithOptionalSearchFields = TransactionWithOptionalHighlight & { /** The action that can be performed for the transaction */ action?: SearchTransactionAction; + /** Function passed to the action button, triggered when the button is pressed */ onButtonPress?: () => void; /** The personal details of the user requesting money */ From 7b421549c4526ccd9fa55d64675ce86daa5f4e8a Mon Sep 17 00:00:00 2001 From: sumo_slonik Date: Tue, 20 May 2025 11:36:56 +0200 Subject: [PATCH 08/15] fix spacing --- src/components/SelectionList/Search/ReportListItem.tsx | 1 + src/components/TransactionItemRow/index.tsx | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/components/SelectionList/Search/ReportListItem.tsx b/src/components/SelectionList/Search/ReportListItem.tsx index 7bcccd76ff86..809648f74b0c 100644 --- a/src/components/SelectionList/Search/ReportListItem.tsx +++ b/src/components/SelectionList/Search/ReportListItem.tsx @@ -152,6 +152,7 @@ function ReportListItem({ openReportInRHP(transaction); }} isParentHovered={hovered} + columnWrapperStyles={[styles.ph3, styles.pv1half]} /> )) diff --git a/src/components/TransactionItemRow/index.tsx b/src/components/TransactionItemRow/index.tsx index 2f77631ecb4e..242fd4550b52 100644 --- a/src/components/TransactionItemRow/index.tsx +++ b/src/components/TransactionItemRow/index.tsx @@ -1,5 +1,6 @@ import React, {useMemo} from 'react'; import {View} from 'react-native'; +import type {ViewStyle} from 'react-native'; import Animated from 'react-native-reanimated'; import type {ValueOf} from 'type-fest'; import Checkbox from '@components/Checkbox'; @@ -41,6 +42,7 @@ function TransactionItemRow({ columns, onButtonPress = () => {}, isParentHovered, + columnWrapperStyles, }: { transactionItem: TransactionWithOptionalSearchFields; shouldUseNarrowLayout: boolean; @@ -52,6 +54,7 @@ function TransactionItemRow({ columns?: Array>; onButtonPress?: () => void; isParentHovered?: boolean; + columnWrapperStyles?: ViewStyle[]; }) { const styles = useThemeStyles(); const StyleUtils = useStyleUtils(); @@ -192,6 +195,7 @@ function TransactionItemRow({ [StyleUtils, createdAt, isDateColumnWide, isSelected, onButtonPress, shouldShowTooltip, shouldUseNarrowLayout, transactionItem], ); + const safeColumnWrapperStyle = columnWrapperStyles ?? [styles.p3]; return ( ) : ( - + Date: Tue, 20 May 2025 13:57:25 +0200 Subject: [PATCH 09/15] add custom configuration of columns --- src/CONST.ts | 1 + .../SelectionList/Search/ReportListItem.tsx | 30 ++++++++++++------- .../TransactionItemRow/DataCells/TaxCell.tsx | 22 ++++++++++++++ src/components/TransactionItemRow/index.tsx | 10 ++++++- 4 files changed, 51 insertions(+), 12 deletions(-) create mode 100644 src/components/TransactionItemRow/DataCells/TaxCell.tsx diff --git a/src/CONST.ts b/src/CONST.ts index 87d9d5b9c784..07038c41b853 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -1420,6 +1420,7 @@ const CONST = { TOTAL_AMOUNT: 'amount', TYPE: 'type', ACTION: 'action', + TAX: 'tax', }, }, CANCEL_PAYMENT_REASONS: { diff --git a/src/components/SelectionList/Search/ReportListItem.tsx b/src/components/SelectionList/Search/ReportListItem.tsx index 809648f74b0c..889dfb83e63c 100644 --- a/src/components/SelectionList/Search/ReportListItem.tsx +++ b/src/components/SelectionList/Search/ReportListItem.tsx @@ -1,6 +1,7 @@ import React, {useMemo} from 'react'; import {View} from 'react-native'; import {useOnyx} from 'react-native-onyx'; +import type {ValueOf} from 'type-fest'; import BaseListItem from '@components/SelectionList/BaseListItem'; import type {ListItem, ReportListItemProps, ReportListItemType, TransactionListItemType} from '@components/SelectionList/types'; import Text from '@components/Text'; @@ -86,6 +87,23 @@ function ReportListItem({ return null; } + const sampleTransaction = reportItem.transactions.at(0); + const {COLUMNS} = CONST.REPORT.TRANSACTION_LIST; + + const columns = [ + COLUMNS.RECEIPT, + COLUMNS.TYPE, + COLUMNS.DATE, + COLUMNS.MERCHANT, + COLUMNS.FROM, + COLUMNS.TO, + ...(sampleTransaction?.shouldShowCategory ? [COLUMNS.CATEGORY] : []), + ...(sampleTransaction?.shouldShowTag ? [COLUMNS.TAG] : []), + ...(sampleTransaction?.shouldShowTax ? [COLUMNS.TAX] : []), + COLUMNS.TOTAL_AMOUNT, + COLUMNS.ACTION, + ] as Array>; + return ( ({ shouldUseNarrowLayout={!isLargeScreenWidth} shouldShowCheckbox={!!canSelectMultiple} onCheckboxPress={() => onCheckboxPress?.(transaction as unknown as TItem)} - columns={[ - CONST.REPORT.TRANSACTION_LIST.COLUMNS.RECEIPT, - CONST.REPORT.TRANSACTION_LIST.COLUMNS.TYPE, - CONST.REPORT.TRANSACTION_LIST.COLUMNS.DATE, - CONST.REPORT.TRANSACTION_LIST.COLUMNS.MERCHANT, - CONST.REPORT.TRANSACTION_LIST.COLUMNS.FROM, - CONST.REPORT.TRANSACTION_LIST.COLUMNS.TO, - CONST.REPORT.TRANSACTION_LIST.COLUMNS.CATEGORY, - CONST.REPORT.TRANSACTION_LIST.COLUMNS.TOTAL_AMOUNT, - CONST.REPORT.TRANSACTION_LIST.COLUMNS.ACTION, - ]} + columns={columns} onButtonPress={() => { openReportInRHP(transaction); }} diff --git a/src/components/TransactionItemRow/DataCells/TaxCell.tsx b/src/components/TransactionItemRow/DataCells/TaxCell.tsx new file mode 100644 index 000000000000..777e7bb76996 --- /dev/null +++ b/src/components/TransactionItemRow/DataCells/TaxCell.tsx @@ -0,0 +1,22 @@ +import TextWithTooltip from '@components/TextWithTooltip'; +import useThemeStyles from '@hooks/useThemeStyles'; +import {convertToDisplayString} from '@libs/CurrencyUtils'; +import {getTaxAmount, getCurrency as getTransactionCurrency} from '@libs/TransactionUtils'; +import type TransactionDataCellProps from './TransactionDataCellProps'; + +function TaxCell({transactionItem, shouldShowTooltip}: TransactionDataCellProps) { + const styles = useThemeStyles(); + + const taxAmount = getTaxAmount(transactionItem, true); + const currency = getTransactionCurrency(transactionItem); + + return ( + + ); +} + +export default TaxCell; diff --git a/src/components/TransactionItemRow/index.tsx b/src/components/TransactionItemRow/index.tsx index 242fd4550b52..cce6f6c28d7a 100644 --- a/src/components/TransactionItemRow/index.tsx +++ b/src/components/TransactionItemRow/index.tsx @@ -23,6 +23,7 @@ import ChatBubbleCell from './DataCells/ChatBubbleCell'; import MerchantCell from './DataCells/MerchantCell'; import ReceiptCell from './DataCells/ReceiptCell'; import TagCell from './DataCells/TagCell'; +import TaxCell from './DataCells/TaxCell'; import TotalCell from './DataCells/TotalCell'; import TypeCell from './DataCells/TypeCell'; import TransactionItemRowRBR from './TransactionItemRowRBR'; @@ -191,10 +192,17 @@ function TransactionItemRow({ /> ), + [CONST.REPORT.TRANSACTION_LIST.COLUMNS.TAX]: ( + + + + ), }), [StyleUtils, createdAt, isDateColumnWide, isSelected, onButtonPress, shouldShowTooltip, shouldUseNarrowLayout, transactionItem], ); - const safeColumnWrapperStyle = columnWrapperStyles ?? [styles.p3]; return ( Date: Tue, 20 May 2025 14:02:42 +0200 Subject: [PATCH 10/15] move column to const --- .../MoneyRequestReportTransactionList.tsx | 22 ++++++++++--------- .../SelectionList/Search/ReportListItem.tsx | 2 +- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/components/MoneyRequestReportView/MoneyRequestReportTransactionList.tsx b/src/components/MoneyRequestReportView/MoneyRequestReportTransactionList.tsx index f67d7b30c1e2..87b55c2f3a09 100644 --- a/src/components/MoneyRequestReportView/MoneyRequestReportTransactionList.tsx +++ b/src/components/MoneyRequestReportView/MoneyRequestReportTransactionList.tsx @@ -82,6 +82,17 @@ const sortableColumnNames = [ CONST.SEARCH.TABLE_COLUMNS.TOTAL_AMOUNT, ]; +const allReportColumns = [ + CONST.REPORT.TRANSACTION_LIST.COLUMNS.RECEIPT, + CONST.REPORT.TRANSACTION_LIST.COLUMNS.TYPE, + CONST.REPORT.TRANSACTION_LIST.COLUMNS.DATE, + CONST.REPORT.TRANSACTION_LIST.COLUMNS.MERCHANT, + CONST.REPORT.TRANSACTION_LIST.COLUMNS.CATEGORY, + CONST.REPORT.TRANSACTION_LIST.COLUMNS.TAG, + CONST.REPORT.TRANSACTION_LIST.COLUMNS.COMMENTS, + CONST.REPORT.TRANSACTION_LIST.COLUMNS.TOTAL_AMOUNT, +]; + type SortableColumnName = TupleToUnion; type SortedTransactions = { @@ -275,16 +286,7 @@ function MoneyRequestReportTransactionList({report, transactions, reportActions, shouldUseNarrowLayout={shouldUseNarrowLayout || isMediumScreenWidth} shouldShowCheckbox={!!selectionMode?.isEnabled || isMediumScreenWidth} onCheckboxPress={toggleTransaction} - columns={[ - CONST.REPORT.TRANSACTION_LIST.COLUMNS.RECEIPT, - CONST.REPORT.TRANSACTION_LIST.COLUMNS.TYPE, - CONST.REPORT.TRANSACTION_LIST.COLUMNS.DATE, - CONST.REPORT.TRANSACTION_LIST.COLUMNS.MERCHANT, - CONST.REPORT.TRANSACTION_LIST.COLUMNS.CATEGORY, - CONST.REPORT.TRANSACTION_LIST.COLUMNS.TAG, - CONST.REPORT.TRANSACTION_LIST.COLUMNS.COMMENTS, - CONST.REPORT.TRANSACTION_LIST.COLUMNS.TOTAL_AMOUNT, - ]} + columns={allReportColumns} /> ); diff --git a/src/components/SelectionList/Search/ReportListItem.tsx b/src/components/SelectionList/Search/ReportListItem.tsx index 889dfb83e63c..9daed60629bc 100644 --- a/src/components/SelectionList/Search/ReportListItem.tsx +++ b/src/components/SelectionList/Search/ReportListItem.tsx @@ -151,7 +151,7 @@ function ReportListItem({ transactionItem={transaction} isSelected={!!transaction.isSelected} dateColumnSize={dateColumnSize} - shouldShowTooltip + shouldShowTooltip={showTooltip} shouldUseNarrowLayout={!isLargeScreenWidth} shouldShowCheckbox={!!canSelectMultiple} onCheckboxPress={() => onCheckboxPress?.(transaction as unknown as TItem)} From 6ce96b5b12f44a3661041023cfe058b9513fcd91 Mon Sep 17 00:00:00 2001 From: sumo_slonik Date: Tue, 20 May 2025 14:16:47 +0200 Subject: [PATCH 11/15] fixed rounded corners --- src/components/TransactionItemRow/index.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/TransactionItemRow/index.tsx b/src/components/TransactionItemRow/index.tsx index cce6f6c28d7a..c1c7b27cb818 100644 --- a/src/components/TransactionItemRow/index.tsx +++ b/src/components/TransactionItemRow/index.tsx @@ -203,7 +203,7 @@ function TransactionItemRow({ }), [StyleUtils, createdAt, isDateColumnWide, isSelected, onButtonPress, shouldShowTooltip, shouldUseNarrowLayout, transactionItem], ); - const safeColumnWrapperStyle = columnWrapperStyles ?? [styles.p3]; + const safeColumnWrapperStyle = columnWrapperStyles ?? [styles.p3, styles.expenseWidgetRadius]; return ( ) : ( - + Date: Tue, 20 May 2025 16:51:53 +0200 Subject: [PATCH 12/15] fixed type cell --- .../MoneyRequestReportTransactionList.tsx | 5 ++++- .../DataCells/TransactionDataCellProps.ts | 4 ++-- src/components/TransactionItemRow/DataCells/TypeCell.tsx | 6 +++++- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/components/MoneyRequestReportView/MoneyRequestReportTransactionList.tsx b/src/components/MoneyRequestReportView/MoneyRequestReportTransactionList.tsx index 2494ee07bef0..e4de83b7dc8f 100644 --- a/src/components/MoneyRequestReportView/MoneyRequestReportTransactionList.tsx +++ b/src/components/MoneyRequestReportView/MoneyRequestReportTransactionList.tsx @@ -2,7 +2,7 @@ import {useFocusEffect} from '@react-navigation/native'; import isEmpty from 'lodash/isEmpty'; import React, {memo, useCallback, useMemo, useState} from 'react'; import {View} from 'react-native'; -import type {TupleToUnion} from 'type-fest'; +import type {TupleToUnion, ValueOf} from 'type-fest'; import {getButtonRole} from '@components/Button/utils'; import Checkbox from '@components/Checkbox'; import * as Expensicons from '@components/Icon/Expensicons'; @@ -72,6 +72,9 @@ type TransactionWithOptionalSearchFields = TransactionWithOptionalHighlight & { /** The personal details of the user paying the request */ to?: SearchPersonalDetails; + + /** Type of transaction */ + transactionType?: ValueOf; }; const sortableColumnNames = [ diff --git a/src/components/TransactionItemRow/DataCells/TransactionDataCellProps.ts b/src/components/TransactionItemRow/DataCells/TransactionDataCellProps.ts index df905ea34fc2..c3312beb31da 100644 --- a/src/components/TransactionItemRow/DataCells/TransactionDataCellProps.ts +++ b/src/components/TransactionItemRow/DataCells/TransactionDataCellProps.ts @@ -1,7 +1,7 @@ -import type Transaction from '@src/types/onyx/Transaction'; +import type {TransactionWithOptionalSearchFields} from '@components/MoneyRequestReportView/MoneyRequestReportTransactionList'; type TransactionDataCellProps = { - transactionItem: Transaction; + transactionItem: TransactionWithOptionalSearchFields; shouldShowTooltip: boolean; shouldUseNarrowLayout?: boolean; }; diff --git a/src/components/TransactionItemRow/DataCells/TypeCell.tsx b/src/components/TransactionItemRow/DataCells/TypeCell.tsx index dafaf4c3763f..2a9996b7d7a5 100644 --- a/src/components/TransactionItemRow/DataCells/TypeCell.tsx +++ b/src/components/TransactionItemRow/DataCells/TypeCell.tsx @@ -24,6 +24,8 @@ const getTypeIcon = (type?: string) => { switch (type) { case CONST.SEARCH.TRANSACTION_TYPE.CARD: return Expensicons.CreditCard; + case CONST.SEARCH.TRANSACTION_TYPE.DISTANCE: + return Expensicons.Car; case CONST.SEARCH.TRANSACTION_TYPE.CASH: default: return Expensicons.Cash; @@ -32,6 +34,8 @@ const getTypeIcon = (type?: string) => { const getTypeText = (type?: string): TranslationPaths => { switch (type) { + case CONST.SEARCH.TRANSACTION_TYPE.DISTANCE: + return 'common.distance'; case CONST.SEARCH.TRANSACTION_TYPE.CARD: return 'iou.card'; case CONST.SEARCH.TRANSACTION_TYPE.CASH: @@ -43,7 +47,7 @@ const getTypeText = (type?: string): TranslationPaths => { function TypeCell({transactionItem, shouldUseNarrowLayout, shouldShowTooltip}: TransactionDataCellProps) { const {translate} = useLocalize(); const theme = useTheme(); - const type = getType(transactionItem.cardName); + const type = transactionItem.transactionType ?? getType(transactionItem.cardName); const typeIcon = getTypeIcon(type); const typeText = getTypeText(type); const styles = useThemeStyles(); From 4cfbfe1bcff3771a21a95984f00ee9392b114292 Mon Sep 17 00:00:00 2001 From: sumo_slonik Date: Wed, 21 May 2025 10:54:49 +0200 Subject: [PATCH 13/15] move type --- .../MoneyRequestReportTransactionList.tsx | 19 +---------------- .../DataCells/TransactionDataCellProps.ts | 2 +- src/components/TransactionItemRow/index.tsx | 21 ++++++++++++++++++- src/stories/objects/Transaction.ts | 2 +- 4 files changed, 23 insertions(+), 21 deletions(-) diff --git a/src/components/MoneyRequestReportView/MoneyRequestReportTransactionList.tsx b/src/components/MoneyRequestReportView/MoneyRequestReportTransactionList.tsx index e4de83b7dc8f..4bf7732d74d4 100644 --- a/src/components/MoneyRequestReportView/MoneyRequestReportTransactionList.tsx +++ b/src/components/MoneyRequestReportView/MoneyRequestReportTransactionList.tsx @@ -60,23 +60,6 @@ type TransactionWithOptionalHighlight = OnyxTypes.Transaction & { shouldBeHighlighted?: boolean; }; -type TransactionWithOptionalSearchFields = TransactionWithOptionalHighlight & { - /** The action that can be performed for the transaction */ - action?: SearchTransactionAction; - - /** Function passed to the action button, triggered when the button is pressed */ - onButtonPress?: () => void; - - /** The personal details of the user requesting money */ - from?: SearchPersonalDetails; - - /** The personal details of the user paying the request */ - to?: SearchPersonalDetails; - - /** Type of transaction */ - transactionType?: ValueOf; -}; - const sortableColumnNames = [ CONST.SEARCH.TABLE_COLUMNS.DATE, CONST.SEARCH.TABLE_COLUMNS.MERCHANT, @@ -354,4 +337,4 @@ function MoneyRequestReportTransactionList({report, transactions, reportActions, MoneyRequestReportTransactionList.displayName = 'MoneyRequestReportTransactionList'; export default memo(MoneyRequestReportTransactionList); -export type {TransactionWithOptionalHighlight, TransactionWithOptionalSearchFields}; +export type {TransactionWithOptionalHighlight}; diff --git a/src/components/TransactionItemRow/DataCells/TransactionDataCellProps.ts b/src/components/TransactionItemRow/DataCells/TransactionDataCellProps.ts index c3312beb31da..05191346ac48 100644 --- a/src/components/TransactionItemRow/DataCells/TransactionDataCellProps.ts +++ b/src/components/TransactionItemRow/DataCells/TransactionDataCellProps.ts @@ -1,4 +1,4 @@ -import type {TransactionWithOptionalSearchFields} from '@components/MoneyRequestReportView/MoneyRequestReportTransactionList'; +import type {TransactionWithOptionalSearchFields} from '..'; type TransactionDataCellProps = { transactionItem: TransactionWithOptionalSearchFields; diff --git a/src/components/TransactionItemRow/index.tsx b/src/components/TransactionItemRow/index.tsx index c1c7b27cb818..e16ce35eadd9 100644 --- a/src/components/TransactionItemRow/index.tsx +++ b/src/components/TransactionItemRow/index.tsx @@ -4,7 +4,7 @@ import type {ViewStyle} from 'react-native'; import Animated from 'react-native-reanimated'; import type {ValueOf} from 'type-fest'; import Checkbox from '@components/Checkbox'; -import type {TransactionWithOptionalSearchFields} from '@components/MoneyRequestReportView/MoneyRequestReportTransactionList'; +import type {TransactionWithOptionalHighlight} from '@components/MoneyRequestReportView/MoneyRequestReportTransactionList'; import type {TableColumnSize} from '@components/Search/types'; import ActionCell from '@components/SelectionList/Search/ActionCell'; import DateCell from '@components/SelectionList/Search/DateCell'; @@ -18,6 +18,7 @@ import useThemeStyles from '@hooks/useThemeStyles'; import {getMerchant, getCreated as getTransactionCreated, isPartialMerchant} from '@libs/TransactionUtils'; import variables from '@styles/variables'; import CONST from '@src/CONST'; +import type {SearchPersonalDetails, SearchTransactionAction} from '@src/types/onyx/SearchResults'; import CategoryCell from './DataCells/CategoryCell'; import ChatBubbleCell from './DataCells/ChatBubbleCell'; import MerchantCell from './DataCells/MerchantCell'; @@ -32,6 +33,23 @@ type ColumnComponents = { [key in ValueOf]: React.ReactElement; }; +type TransactionWithOptionalSearchFields = TransactionWithOptionalHighlight & { + /** The action that can be performed for the transaction */ + action?: SearchTransactionAction; + + /** Function passed to the action button, triggered when the button is pressed */ + onButtonPress?: () => void; + + /** The personal details of the user requesting money */ + from?: SearchPersonalDetails; + + /** The personal details of the user paying the request */ + to?: SearchPersonalDetails; + + /** Type of transaction */ + transactionType?: ValueOf; +}; + function TransactionItemRow({ transactionItem, shouldUseNarrowLayout, @@ -324,3 +342,4 @@ function TransactionItemRow({ TransactionItemRow.displayName = 'TransactionItemRow'; export default TransactionItemRow; +export type {TransactionWithOptionalSearchFields}; diff --git a/src/stories/objects/Transaction.ts b/src/stories/objects/Transaction.ts index 775d9a162b66..ffc3d71a4f5f 100644 --- a/src/stories/objects/Transaction.ts +++ b/src/stories/objects/Transaction.ts @@ -1,4 +1,4 @@ -import type {TransactionWithOptionalSearchFields} from '@components/MoneyRequestReportView/MoneyRequestReportTransactionList'; +import type {TransactionWithOptionalSearchFields} from '@components/TransactionItemRow'; import CONST from '@src/CONST'; import type Transaction from '@src/types/onyx/Transaction'; From 81b9e8a0917fa9101bb279fac54a031f347cbb1c Mon Sep 17 00:00:00 2001 From: sumo_slonik Date: Wed, 21 May 2025 11:32:46 +0200 Subject: [PATCH 14/15] fix eslint --- .../MoneyRequestReportTransactionList.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/components/MoneyRequestReportView/MoneyRequestReportTransactionList.tsx b/src/components/MoneyRequestReportView/MoneyRequestReportTransactionList.tsx index 513ae098a55c..bfc4d36cb078 100644 --- a/src/components/MoneyRequestReportView/MoneyRequestReportTransactionList.tsx +++ b/src/components/MoneyRequestReportView/MoneyRequestReportTransactionList.tsx @@ -2,7 +2,7 @@ import {useFocusEffect} from '@react-navigation/native'; import isEmpty from 'lodash/isEmpty'; import React, {memo, useCallback, useMemo, useState} from 'react'; import {View} from 'react-native'; -import type {TupleToUnion, ValueOf} from 'type-fest'; +import type {TupleToUnion} from 'type-fest'; import {getButtonRole} from '@components/Button/utils'; import Checkbox from '@components/Checkbox'; import * as Expensicons from '@components/Icon/Expensicons'; @@ -36,7 +36,6 @@ import CONST from '@src/CONST'; import NAVIGATORS from '@src/NAVIGATORS'; import ROUTES from '@src/ROUTES'; import type * as OnyxTypes from '@src/types/onyx'; -import type {SearchPersonalDetails, SearchTransactionAction} from '@src/types/onyx/SearchResults'; import {useMoneyRequestReportContext} from './MoneyRequestReportContext'; import MoneyRequestReportTableHeader from './MoneyRequestReportTableHeader'; import SearchMoneyRequestReportEmptyState from './SearchMoneyRequestReportEmptyState'; From cf9c95f5cf0fa842317916675124008d4a07f99d Mon Sep 17 00:00:00 2001 From: sumo_slonik Date: Wed, 21 May 2025 11:45:57 +0200 Subject: [PATCH 15/15] add display name --- src/components/TransactionItemRow/DataCells/TaxCell.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/TransactionItemRow/DataCells/TaxCell.tsx b/src/components/TransactionItemRow/DataCells/TaxCell.tsx index 777e7bb76996..80e819ea5f0e 100644 --- a/src/components/TransactionItemRow/DataCells/TaxCell.tsx +++ b/src/components/TransactionItemRow/DataCells/TaxCell.tsx @@ -19,4 +19,5 @@ function TaxCell({transactionItem, shouldShowTooltip}: TransactionDataCellProps) ); } +TaxCell.displayName = 'TaxCell'; export default TaxCell;