Skip to content

Commit 8d9bba7

Browse files
author
Nabi
committed
add full duplicate row header
1 parent 8ce0f24 commit 8d9bba7

1 file changed

Lines changed: 24 additions & 3 deletions

File tree

src/pages/TransactionDuplicate/DuplicateTransactionItem.tsx

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ import React from 'react';
22
import type {OnyxEntry} from 'react-native-onyx';
33
import {getButtonRole} from '@components/Button/utils';
44
import OfflineWithFeedback from '@components/OfflineWithFeedback';
5+
import {usePersonalDetails} from '@components/OnyxListItemProvider';
56
import {PressableWithFeedback} from '@components/Pressable';
6-
import type {TransactionListItemType} from '@components/Search/SearchList/ListItem/types';
7+
import type {ExpenseReportListItemType, TransactionListItemType} from '@components/Search/SearchList/ListItem/types';
8+
import UserInfoAndActionButtonRow from '@components/Search/SearchList/ListItem/UserInfoAndActionButtonRow';
79
import TransactionItemRow from '@components/TransactionItemRow';
810
import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails';
911
import useOnyx from '@hooks/useOnyx';
@@ -26,6 +28,7 @@ type DuplicateTransactionItemProps = {
2628

2729
function DuplicateTransactionItem({transaction, isLastItem, isSelected, shouldShowSelection = true, onSelectTransaction, onPreviewPressed}: DuplicateTransactionItemProps) {
2830
const styles = useThemeStyles();
31+
const personalDetails = usePersonalDetails();
2932
const currentUserPersonalDetails = useCurrentUserPersonalDetails();
3033
const [report] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${transaction?.reportID}`);
3134
const [reportActions] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report?.reportID}`);
@@ -37,6 +40,15 @@ function DuplicateTransactionItem({transaction, isLastItem, isSelected, shouldSh
3740
const iouTransactionID = isMoneyRequestAction(reportAction) ? getOriginalMessage(reportAction)?.IOUTransactionID : CONST.DEFAULT_NUMBER_ID;
3841
return iouTransactionID === transaction?.transactionID;
3942
});
43+
const ownerPersonalDetails = report?.ownerAccountID ? personalDetails?.[report.ownerAccountID] : undefined;
44+
const reportStatusItem = ownerPersonalDetails
45+
? ({
46+
...report,
47+
from: ownerPersonalDetails,
48+
to: ownerPersonalDetails,
49+
formattedFrom: ownerPersonalDetails.displayName ?? '',
50+
} as ExpenseReportListItemType)
51+
: undefined;
4052

4153
const handlePreviewPress = () => {
4254
if (!action || !report) {
@@ -77,8 +89,17 @@ function DuplicateTransactionItem({transaction, isLastItem, isSelected, shouldSh
7789
role={getButtonRole(true)}
7890
isNested
7991
hoverStyle={styles.hoveredComponentBG}
80-
style={!isLastItem && styles.borderBottom}
92+
style={[!isLastItem && styles.borderBottom, styles.pt4, styles.pb4, styles.pl4, shouldShowSelection ? styles.pr0 : styles.pr4]}
8193
>
94+
{!!reportStatusItem && (
95+
<UserInfoAndActionButtonRow
96+
item={reportStatusItem}
97+
shouldShowUserInfo
98+
stateNum={report?.stateNum}
99+
statusNum={report?.statusNum}
100+
containerStyles={[styles.mb3, shouldShowSelection && styles.pr4]}
101+
/>
102+
)}
82103
<TransactionItemRow
83104
transactionItem={transaction as TransactionListItemType}
84105
report={report}
@@ -91,7 +112,7 @@ function DuplicateTransactionItem({transaction, isLastItem, isSelected, shouldSh
91112
taxAmountColumnSize={CONST.SEARCH.TABLE_COLUMN_SIZES.NORMAL}
92113
shouldHighlightItemWhenSelected={false}
93114
shouldShowErrors={false}
94-
style={[styles.p4, shouldShowSelection ? styles.pr0 : styles.pr4]}
115+
style={shouldShowSelection ? [styles.pr0] : [styles.pv2]}
95116
shouldShowRadioButton={shouldShowSelection}
96117
shouldStopRadioButtonMouseDownPropagation
97118
radioButtonContainerStyle={styles.ml0}

0 commit comments

Comments
 (0)