Skip to content

Commit 9f643fd

Browse files
refactor: OptionRow.ErrorBadge owns its own translation
1 parent dfe7f59 commit 9f643fd

2 files changed

Lines changed: 14 additions & 8 deletions

File tree

src/components/LHNOptionsList/OptionRowLHN/OptionRowErrorBadge.tsx renamed to src/components/LHNOptionsList/OptionRowLHN/OptionRow/ErrorBadge.tsx

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,32 @@ import React from 'react';
22
import {View} from 'react-native';
33
import Badge from '@components/Badge';
44
import Icon from '@components/Icon';
5+
import useEnvironment from '@hooks/useEnvironment';
56
import {useMemoizedLazyExpensifyIcons} from '@hooks/useLazyAsset';
7+
import useLocalize from '@hooks/useLocalize';
68
import useTheme from '@hooks/useTheme';
79
import useThemeStyles from '@hooks/useThemeStyles';
810
import type {OptionData} from '@libs/ReportUtils';
911
import CONST from '@src/CONST';
1012

11-
type OptionRowErrorBadgeProps = {
13+
type ErrorBadgeProps = {
1214
brickRoadIndicator: OptionData['brickRoadIndicator'];
13-
actionBadgeText: string;
15+
actionBadge: OptionData['actionBadge'];
1416
};
1517

16-
function OptionRowErrorBadge({brickRoadIndicator, actionBadgeText}: OptionRowErrorBadgeProps) {
18+
function ErrorBadge({brickRoadIndicator, actionBadge}: ErrorBadgeProps) {
1719
const theme = useTheme();
1820
const styles = useThemeStyles();
21+
const {translate} = useLocalize();
22+
const {isProduction} = useEnvironment();
1923
const {DotIndicator} = useMemoizedLazyExpensifyIcons(['DotIndicator']);
2024

2125
if (brickRoadIndicator !== CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR) {
2226
return null;
2327
}
2428

29+
const actionBadgeText = !isProduction && actionBadge ? translate(`common.actionBadge.${actionBadge}`) : '';
30+
2531
return (
2632
<View style={[styles.alignItemsCenter, styles.justifyContentCenter]}>
2733
{actionBadgeText ? (
@@ -41,6 +47,6 @@ function OptionRowErrorBadge({brickRoadIndicator, actionBadgeText}: OptionRowErr
4147
);
4248
}
4349

44-
OptionRowErrorBadge.displayName = 'OptionRowErrorBadge';
50+
ErrorBadge.displayName = 'OptionRow.ErrorBadge';
4551

46-
export default OptionRowErrorBadge;
52+
export default ErrorBadge;

src/components/LHNOptionsList/OptionRowLHN/OptionRowLHNCore.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ import variables from '@styles/variables';
2626
import CONST from '@src/CONST';
2727
import ONYXKEYS from '@src/ONYXKEYS';
2828
import {isEmptyObject} from '@src/types/utils/EmptyObject';
29+
import ErrorBadge from './OptionRow/ErrorBadge';
2930
import OptionRowAlternateText from './OptionRowAlternateText';
3031
import OptionRowAvatar from './OptionRowAvatar';
31-
import OptionRowErrorBadge from './OptionRowErrorBadge';
3232
import OptionRowInfoBadge from './OptionRowInfoBadge';
3333
import OptionRowPressable from './OptionRowPressable';
3434
import OptionRowTooltipLayer from './OptionRowTooltipLayer';
@@ -193,9 +193,9 @@ function OptionRowLHN({
193193
<Text style={[styles.textLabel]}>{optionItem.descriptiveText}</Text>
194194
</View>
195195
) : null}
196-
<OptionRowErrorBadge
196+
<ErrorBadge
197197
brickRoadIndicator={brickRoadIndicator}
198-
actionBadgeText={actionBadgeText}
198+
actionBadge={optionItem.actionBadge}
199199
/>
200200
</View>
201201
</View>

0 commit comments

Comments
 (0)