Skip to content

Commit 5ed0a75

Browse files
JakubKorytkoKicu
authored andcommitted
Add TransactionItemRowRBR (#211)
1 parent 8c054c2 commit 5ed0a75

File tree

4 files changed

+53
-2
lines changed

4 files changed

+53
-2
lines changed

src/components/MoneyRequestReportView/MoneyRequestReportTransactionList.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ function MoneyRequestReportTransactionList({report, transactions}: MoneyRequestR
3232
<View style={[styles.pv2, styles.ph5]}>
3333
{transactions.map((transaction) => {
3434
return (
35-
<View style={[styles.flex1, styles.mb2]}>
35+
<View style={[styles.mb2]}>
3636
<TransactionItemRow
3737
transactionItem={transaction}
3838
isSelected={false}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import React from 'react';
2+
import {View} from 'react-native';
3+
import Icon from '@components/Icon';
4+
import {DotIndicator} from '@components/Icon/Expensicons';
5+
import Text from '@components/Text';
6+
import useLocalize from '@hooks/useLocalize';
7+
import useTheme from '@hooks/useTheme';
8+
import useThemeStyles from '@hooks/useThemeStyles';
9+
import useTransactionViolations from '@hooks/useTransactionViolations';
10+
import ViolationsUtils from '@libs/Violations/ViolationsUtils';
11+
import variables from '@styles/variables';
12+
import type Transaction from '@src/types/onyx/Transaction';
13+
14+
function TransactionItemRowRBR({transaction}: {transaction: Transaction}) {
15+
const styles = useThemeStyles();
16+
const transactionViolations = useTransactionViolations(transaction?.transactionID);
17+
const {translate} = useLocalize();
18+
const theme = useTheme();
19+
20+
const RBRmessages = transactionViolations
21+
.map((violation, index) => {
22+
const translation = ViolationsUtils.getViolationTranslation(violation, translate);
23+
return index > 0 ? translation.charAt(0).toLowerCase() + translation.slice(1) : translation;
24+
})
25+
.join(', ');
26+
27+
return (
28+
transactionViolations.length > 0 && (
29+
<View style={[styles.flexRow, styles.alignItemsCenter, styles.gap1]}>
30+
<Icon
31+
src={DotIndicator}
32+
fill={theme.danger}
33+
height={variables.iconSizeExtraSmall}
34+
width={variables.iconSizeExtraSmall}
35+
/>
36+
<Text
37+
numberOfLines={1}
38+
style={[styles.textMicroSupporting, styles.pre, styles.flexShrink1, {color: theme.danger}]}
39+
>
40+
{RBRmessages}
41+
</Text>
42+
</View>
43+
)
44+
);
45+
}
46+
47+
export default TransactionItemRowRBR;

src/components/TransactionItemRow/index.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import ReceiptCell from './DataCells/ReceiptCell';
1313
import TagCell from './DataCells/TagCell';
1414
import TotalCell from './DataCells/TotalCell';
1515
import TypeCell from './DataCells/TypeCell';
16+
import TransactionItemRowRBR from './TransactionItemRowRBR';
1617

1718
function TransactionItemRow({
1819
transactionItem,
@@ -83,13 +84,14 @@ function TransactionItemRow({
8384
shouldUseNarrowLayout={shouldUseNarrowLayout}
8485
/>
8586
</View>
87+
<TransactionItemRowRBR transaction={transactionItem} />
8688
</View>
8789
)}
8890
</Hoverable>
8991
) : (
9092
<Hoverable>
9193
{(hovered) => (
92-
<View style={[hovered ? styles.hoveredComponentBG : backgroundColor, styles.p2, styles.expenseWidgetRadius]}>
94+
<View style={[hovered ? styles.hoveredComponentBG : backgroundColor, styles.p2, styles.expenseWidgetRadius, styles.gap2]}>
9395
<View style={[styles.flex1, styles.flexRow, styles.alignItemsCenter, styles.gap3]}>
9496
<View style={[StyleUtils.getReportTableColumnStyles(CONST.SEARCH.TABLE_COLUMNS.RECEIPT)]}>
9597
<ReceiptCell
@@ -140,6 +142,7 @@ function TransactionItemRow({
140142
/>
141143
</View>
142144
</View>
145+
<TransactionItemRowRBR transaction={transactionItem} />
143146
</View>
144147
)}
145148
</Hoverable>

src/pages/Search/SearchMoneyRequestReportPage.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ function SearchMoneyRequestReportPage({route}: SearchPageProps) {
8282
Navigation.goBack();
8383
}}
8484
/>
85+
<MoneyRequestReportView report={report} />
8586
</ScreenWrapper>
8687
);
8788
}

0 commit comments

Comments
 (0)