Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds Violations Requirements to MoneyRequestConfirmationList #31380

6 changes: 6 additions & 0 deletions src/components/MenuItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ const defaultProps = {
shouldGreyOutWhenDisabled: true,
error: '',
shouldRenderAsHTML: false,
rightLabel: '',
rightComponent: undefined,
shouldShowRightComponent: false,
titleWithTooltips: [],
Expand Down Expand Up @@ -364,6 +365,11 @@ const MenuItem = React.forwardRef((props, ref) => {
/>
</View>
)}
{Boolean(props.rightLabel) && (
<View style={styles.justifyContentCenter}>
<Text style={styles.rightLabelMenuItem}>{props.rightLabel}</Text>
</View>
)}
{Boolean(props.shouldShowRightIcon) && (
<View style={[styles.popoverMenuIcon, styles.pointerEventsAuto, props.disabled && styles.cursorDisabled]}>
<Icon
Expand Down
5 changes: 4 additions & 1 deletion src/components/MoneyRequestConfirmationList.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {View} from 'react-native';
import {withOnyx} from 'react-native-onyx';
import _ from 'underscore';
import useLocalize from '@hooks/useLocalize';
import usePermissions from '@hooks/usePermissions';
import compose from '@libs/compose';
import * as CurrencyUtils from '@libs/CurrencyUtils';
import DistanceRequestUtils from '@libs/DistanceRequestUtils';
Expand Down Expand Up @@ -210,6 +211,7 @@ function MoneyRequestConfirmationList(props) {
const {onSendMoney, onConfirm, onSelectParticipant} = props;
const {translate, toLocaleDigit} = useLocalize();
const transaction = props.isEditingSplitBill ? props.draftTransaction || props.transaction : props.transaction;
const {canUseViolations} = usePermissions();

const isTypeRequest = props.iouType === CONST.IOU.TYPE.REQUEST;
const isSplitBill = props.iouType === CONST.IOU.TYPE.SPLIT;
Expand All @@ -223,7 +225,6 @@ function MoneyRequestConfirmationList(props) {

// A flag for showing the categories field
const shouldShowCategories = props.isPolicyExpenseChat && (props.iouCategory || OptionsListUtils.hasEnabledOptions(_.values(props.policyCategories)));

// A flag and a toggler for showing the rest of the form fields
const [shouldExpandFields, toggleShouldExpandFields] = useReducer((state) => !state, false);

Expand Down Expand Up @@ -715,6 +716,7 @@ function MoneyRequestConfirmationList(props) {
titleStyle={styles.flex1}
disabled={didConfirm}
interactive={!props.isReadOnly}
rightLabel={canUseViolations && Boolean(props.policy.requiresCategory) ? translate('common.required') : ''}
/>
)}
{shouldShowTags && (
Expand All @@ -727,6 +729,7 @@ function MoneyRequestConfirmationList(props) {
style={[styles.moneyRequestMenuItem]}
disabled={didConfirm}
interactive={!props.isReadOnly}
rightLabel={canUseViolations && Boolean(props.policy.requiresTag) ? translate('common.required') : ''}
/>
)}

Expand Down
3 changes: 3 additions & 0 deletions src/components/menuItemPropTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,9 @@ const propTypes = {
/** Should render the content in HTML format */
shouldRenderAsHTML: PropTypes.bool,

/** Label to be displayed on the right */
rightLabel: PropTypes.string,

/** Component to be displayed on the right */
rightComponent: PropTypes.node,

Expand Down
1 change: 1 addition & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ export default {
tbd: 'TBD',
selectCurrency: 'Select a currency',
card: 'Card',
required: 'Required',
},
location: {
useCurrent: 'Use current location',
Expand Down
1 change: 1 addition & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ export default {
tbd: 'Por determinar',
selectCurrency: 'Selecciona una moneda',
card: 'Tarjeta',
required: 'Obligatorio',
},
location: {
useCurrent: 'Usar ubicación actual',
Expand Down
5 changes: 5 additions & 0 deletions src/styles/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1441,6 +1441,11 @@ const styles = (theme: ThemeColors) =>
alignItems: 'center',
},

rightLabelMenuItem: {
fontSize: variables.fontSizeLabel,
color: theme.textSupporting,
},

popoverMenuText: {
fontSize: variables.fontSizeNormal,
color: theme.heading,
Expand Down
Loading