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

Feat: Add Billable Toggle UI #27172

Merged
merged 16 commits into from
Sep 18, 2023
Merged
14 changes: 14 additions & 0 deletions src/components/MoneyRequestConfirmationList.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {format} from 'date-fns';
import _ from 'underscore';
import {View} from 'react-native';
import lodashGet from 'lodash/get';
import Text from './Text';
import styles from '../styles/styles';
import * as ReportUtils from '../libs/ReportUtils';
import * as OptionsListUtils from '../libs/OptionsListUtils';
Expand All @@ -29,6 +30,7 @@ import Image from './Image';
import useLocalize from '../hooks/useLocalize';
import * as ReceiptUtils from '../libs/ReceiptUtils';
import categoryPropTypes from './categoryPropTypes';
import Switch from './Switch';
import ConfirmedRoute from './ConfirmedRoute';
import transactionPropTypes from './transactionPropTypes';
import DistanceRequestUtils from '../libs/DistanceRequestUtils';
Expand Down Expand Up @@ -499,6 +501,18 @@ function MoneyRequestConfirmationList(props) {
disabled={didConfirm || props.isReadOnly}
/>
)}
<View>
waterim marked this conversation as resolved.
Show resolved Hide resolved
<View style={[styles.flexRow, styles.mb4, styles.justifyContentBetween, styles.alignItemsCenter, styles.ml5, styles.mr8]}>
<Text color={!props.iouIsBillable ? themeColors.textSupporting : undefined}>{translate('common.billable')}</Text>
<Switch
accessibilityLabel={translate('common.billable')}
isOn={props.iouIsBillable}
onToggle={(val) => {
props.onToggleBillable(val);
}}
waterim marked this conversation as resolved.
Show resolved Hide resolved
/>
</View>
</View>
</>
)}
</OptionsSelector>
Expand Down
1 change: 1 addition & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ export default {
showMore: 'Show more',
merchant: 'Merchant',
category: 'Category',
billable: 'Billable',
receipt: 'Receipt',
replace: 'Replace',
distance: 'Distance',
Expand Down
1 change: 1 addition & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ export default {
showMore: 'Mostrar más',
merchant: 'Comerciante',
category: 'Categoría',
billable: 'Facturable',
receipt: 'Recibo',
replace: 'Sustituir',
distance: 'Distancia',
Expand Down
1 change: 1 addition & 0 deletions src/libs/actions/IOU.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ function resetMoneyRequestInfo(id = '') {
receiptPath: '',
receiptSource: '',
transactionID: '',
isBillable: false,
});
}

Expand Down
5 changes: 4 additions & 1 deletion src/pages/iou/steps/MoneyRequestConfirmPage.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, {useCallback, useEffect, useMemo, useRef} from 'react';
import React, {useCallback, useEffect, useMemo, useRef, useState} from 'react';
import {ScrollView, View} from 'react-native';
import PropTypes from 'prop-types';
import {withOnyx} from 'react-native-onyx';
Expand Down Expand Up @@ -59,6 +59,7 @@ const defaultProps = {
};

function MoneyRequestConfirmPage(props) {
const [isBillable, setIsBillable] = useState(true);
const {windowHeight} = useWindowDimensions();
const prevMoneyRequestId = useRef(props.iou.id);
const iouType = useRef(lodashGet(props.route, 'params.iouType', ''));
Expand Down Expand Up @@ -283,6 +284,8 @@ function MoneyRequestConfirmPage(props) {
iouAmount={props.iou.amount}
iouComment={props.iou.comment}
iouCurrencyCode={props.iou.currency}
iouIsBillable={isBillable}
onToggleBillable={(newValue) => setIsBillable(newValue)}
iouCategory={props.iou.category}
waterim marked this conversation as resolved.
Show resolved Hide resolved
onConfirm={createTransaction}
onSendMoney={sendMoney}
Expand Down
Loading