forked from Expensify/App
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathReceiptAudit.tsx
69 lines (62 loc) · 2.32 KB
/
ReceiptAudit.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import React from 'react';
import {View} from 'react-native';
import useLocalize from '@hooks/useLocalize';
import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';
import Icon from './Icon';
import * as Expensicons from './Icon/Expensicons';
import Text from './Text';
type ReceiptAuditProps = {
/** List of audit notes */
notes: string[];
/** Whether to show audit result or not (e.g.`Verified`, `Issue Found`) */
shouldShowAuditResult: boolean;
};
function ReceiptAudit({notes, shouldShowAuditResult}: ReceiptAuditProps) {
const styles = useThemeStyles();
const theme = useTheme();
const {translate} = useLocalize();
let auditText = '';
if (notes.length > 0 && shouldShowAuditResult) {
auditText = translate('iou.receiptIssuesFound', {count: notes.length});
} else if (!notes.length && shouldShowAuditResult) {
auditText = translate('common.verified');
}
return (
<View style={[styles.ph5, styles.mbn1]}>
<View style={[styles.flexRow, styles.alignItemsCenter]}>
<Text style={[styles.textLabelSupporting]}>{translate('common.receipt')}</Text>
{!!auditText && (
<>
<Text style={[styles.textLabelSupporting]}>{` • ${auditText}`}</Text>
<Icon
width={12}
height={12}
src={notes.length ? Expensicons.DotIndicator : Expensicons.Checkmark}
fill={notes.length ? theme.danger : theme.success}
additionalStyles={styles.ml1}
/>
</>
)}
</View>
</View>
);
}
function ReceiptAuditMessages({notes = []}: {notes?: string[]}) {
const styles = useThemeStyles();
return (
<View style={[styles.mtn1, styles.mb2, styles.ph5, styles.gap1]}>
{notes.length > 0 &&
notes.map((message) => (
<Text
style={[styles.textLabelError]}
key={message}
>
{message}
</Text>
))}
</View>
);
}
export {ReceiptAuditMessages};
export default ReceiptAudit;