Skip to content

Commit

Permalink
Add error property
Browse files Browse the repository at this point in the history
  • Loading branch information
Gonals committed Sep 18, 2023
1 parent c36ac0c commit a50b87d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
8 changes: 7 additions & 1 deletion src/components/MenuItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ const defaultProps = {
title: '',
numberOfLinesTitle: 1,
shouldGreyOutWhenDisabled: true,
error: '',
};

const MenuItem = React.forwardRef((props, ref) => {
Expand Down Expand Up @@ -245,6 +246,11 @@ const MenuItem = React.forwardRef((props, ref) => {
{props.description}
</Text>
)}
{props.error && (
<View style={[styles.mt1]}>
<Text style={[styles.textLabelError]}>{props.error}</Text>
</View>
)}
{Boolean(props.furtherDetails) && (
<View style={[styles.flexRow, styles.mt1, styles.alignItemsCenter]}>
<Icon
Expand Down Expand Up @@ -278,7 +284,7 @@ const MenuItem = React.forwardRef((props, ref) => {
{/* Since subtitle can be of type number, we should allow 0 to be shown */}
{(props.subtitle || props.subtitle === 0) && (
<View style={[styles.justifyContentCenter, styles.mr1]}>
<Text style={[props.subtitleTextStyle || styles.textLabelSupporting, props.style]}>{props.subtitle}</Text>
<Text style={[styles.textLabelSupporting, props.style]}>{props.subtitle}</Text>
</View>
)}
{!_.isEmpty(props.floatRightAvatars) && (
Expand Down
3 changes: 1 addition & 2 deletions src/components/ReportActionItem/MoneyRequestView.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,7 @@ function MoneyRequestView({report, parentReport, shouldShowHorizontalRule, trans
titleStyle={styles.flex1}
onPress={() => Navigation.navigate(ROUTES.getEditRequestRoute(report.reportID, CONST.EDIT_REQUEST_FIELD.MERCHANT))}
brickRoadIndicator={hasErrors && isEmptyMerchant ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : ''}
subtitle={hasErrors && isEmptyMerchant ? translate('common.error.enterMerchant') : ''}
subtitleTextStyle={styles.textLabelError}
error={hasErrors && isEmptyMerchant ? translate('common.error.enterMerchant') : ''}
/>
</OfflineWithFeedback>
{shouldShowHorizontalRule && <View style={styles.reportHorizontalRule} />}
Expand Down
3 changes: 3 additions & 0 deletions src/components/menuItemPropTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@ const propTypes = {

/** Should we grey out the menu item when it is disabled? */
shouldGreyOutWhenDisabled: PropTypes.bool,

/** Error to display below the title */
error: PropTypes.string,
};

export default propTypes;

0 comments on commit a50b87d

Please sign in to comment.