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 new input fields for tax tracking #32550

Merged
merged 90 commits into from
Jan 3, 2024
Merged
Show file tree
Hide file tree
Changes from 73 commits
Commits
Show all changes
90 commits
Select commit Hold shift + click to select a range
3d85737
initial input screens
teneeto Dec 6, 2023
20efbfc
fix lint
teneeto Dec 6, 2023
71b49b9
check policy expense chat: a flag for showing tax rate
teneeto Dec 7, 2023
50e1a81
add policy tax rates in tax rate page
teneeto Dec 7, 2023
c683500
add tax rates list threshold
teneeto Dec 8, 2023
c14bbe3
add tax rates sections in options utils
teneeto Dec 8, 2023
88d352d
add tax propTypes
teneeto Dec 8, 2023
8b26228
add tax pickerPropTypes
teneeto Dec 8, 2023
e4be96d
add tax picker
teneeto Dec 8, 2023
11a4691
use TaxPicker in tax rates page
teneeto Dec 8, 2023
df81cf5
fix lint
teneeto Dec 8, 2023
c34095e
remove whitespace
teneeto Dec 8, 2023
2f78afd
add default amount to avoid Nan
teneeto Dec 10, 2023
8098ae1
add default title for tax rate and format amount
teneeto Dec 10, 2023
11ab530
set tax rate and tax amount to onyx
teneeto Dec 10, 2023
bebace8
add defaulttax title
teneeto Dec 13, 2023
0675e22
update tax rate section
teneeto Dec 13, 2023
2abfc7c
update tax Amount based on tax rate
teneeto Dec 13, 2023
ce50e7c
should show search input if threshold is more than 8
teneeto Dec 13, 2023
9e12ece
should show error if current amount is greater than iou amount
teneeto Dec 13, 2023
e5f6e17
update comment
teneeto Dec 13, 2023
d9fa49d
set taxAmount in Onyx
teneeto Dec 13, 2023
98db78b
add tax translation strings
teneeto Dec 13, 2023
e28ae1b
format tax amount and use translation for invalid tax amount
teneeto Dec 13, 2023
781952a
translate titles
teneeto Dec 13, 2023
6fe318c
Merge branch 'main' of github.com:teneeto/App into feat/31672/add-new…
teneeto Dec 13, 2023
7f80963
update merge conflict
teneeto Dec 13, 2023
62e98c1
translate tax amount and rate
teneeto Dec 13, 2023
5b11998
Merge branch 'main' of github.com:teneeto/App into feat/31672/add-new…
teneeto Dec 14, 2023
ff9ca23
refactor tax amount and rate pages
teneeto Dec 14, 2023
b692144
refactor tax amount and rate routes and navigation
teneeto Dec 14, 2023
0f4fb66
update tax picker
teneeto Dec 14, 2023
4341e90
refactor invalid tax amount error
teneeto Dec 14, 2023
c6d902c
sync Temp refactor request confirmation list with tax rate and amount…
teneeto Dec 14, 2023
ac4092e
fix lint
teneeto Dec 14, 2023
353345a
Merge branch 'main' of github.com:teneeto/App into feat/31672/add-new…
teneeto Dec 14, 2023
f0f8ca6
update tax proptypes
teneeto Dec 15, 2023
3ca564a
add proptypes for transactions draft
teneeto Dec 15, 2023
9383f8a
transform taxes to a new object with code
teneeto Dec 15, 2023
6a0d3a8
use proptypes
teneeto Dec 15, 2023
5db26b7
fix lint
teneeto Dec 15, 2023
9112347
update translations
teneeto Dec 16, 2023
88c001e
transform tax rates
teneeto Dec 16, 2023
b4d6055
update invalid tax amount error
teneeto Dec 16, 2023
86edc81
update amount defaults
teneeto Dec 16, 2023
b59dcae
add JSDOC and comments
teneeto Dec 16, 2023
8ed66c7
send taxCode and taxAmount to RequestMoney API
teneeto Dec 17, 2023
a2696d3
use transactions from onyx instead of transactionsDraft
teneeto Dec 17, 2023
25e128c
Update src/pages/iou/request/step/IOURequestStepTaxAmountPage.js
teneeto Dec 18, 2023
42f7fcf
Update src/libs/OptionsListUtils.js
teneeto Dec 18, 2023
15b45af
Update src/libs/OptionsListUtils.js
teneeto Dec 18, 2023
bd72c6c
Update src/components/TaxPicker/taxPickerPropTypes.js
teneeto Dec 18, 2023
8a1e906
Update src/components/taxPropTypes.js
teneeto Dec 18, 2023
bedc6ef
Update src/pages/iou/request/step/IOURequestStepTaxAmountPage.js
teneeto Dec 18, 2023
a456030
fix lint
teneeto Dec 18, 2023
15a7954
Update src/components/MoneyRequestConfirmationList.js
teneeto Dec 20, 2023
41edcb8
Update src/components/taxPropTypes.js
teneeto Dec 20, 2023
8e78e34
Update src/components/taxPropTypes.js
teneeto Dec 20, 2023
8dfb843
Update src/components/taxPropTypes.js
teneeto Dec 20, 2023
0f52c39
Update src/components/taxPropTypes.js
teneeto Dec 20, 2023
16319b9
Update src/libs/OptionsListUtils.js
teneeto Dec 20, 2023
a7be0dc
Update src/libs/OptionsListUtils.js
teneeto Dec 20, 2023
1404d7c
Update src/libs/OptionsListUtils.js
teneeto Dec 20, 2023
4e0a034
test getFilteredOptions for taxRate
teneeto Dec 20, 2023
3afed39
Merge branch 'feat/31672/add-new-input-fields-for-tax-tracking' of gi…
teneeto Dec 20, 2023
c168e74
Update tests/unit/OptionsListUtilsTest.js
teneeto Dec 21, 2023
5ec8788
Update src/pages/iou/request/step/IOURequestStepTaxRatePage.js
teneeto Dec 21, 2023
a3ac0b6
Update src/pages/iou/request/step/IOURequestStepTaxRatePage.js
teneeto Dec 21, 2023
bea71c4
Update src/pages/iou/request/step/IOURequestStepTaxRatePage.js
teneeto Dec 21, 2023
70fe7a1
it should be calculateTaxAmount
teneeto Dec 21, 2023
679193c
define policyTaxRates
teneeto Dec 21, 2023
2d6f3a6
Merge branch 'feat/31672/add-new-input-fields-for-tax-tracking' of gi…
teneeto Dec 21, 2023
b07509d
fix lint
teneeto Dec 21, 2023
80a876a
Merge branch 'main' of github.com:teneeto/App into feat/31672/add-new…
teneeto Dec 26, 2023
3135939
fix review comments
teneeto Dec 27, 2023
e7f0f16
fix test
teneeto Dec 27, 2023
4dadd3b
calculate default tax on amount request
teneeto Dec 28, 2023
bd78b48
Merge branch 'main' of github.com:teneeto/App into feat/31672/add-new…
teneeto Dec 28, 2023
29c3c64
calculate tax amount on request page if only isTaxTrackingEnabled is …
teneeto Dec 29, 2023
33def32
Merge branch 'main' of github.com:teneeto/App into feat/31672/add-new…
teneeto Dec 29, 2023
3b30476
fix app crash on request money
teneeto Dec 29, 2023
6ac4eb9
Update src/components/MoneyRequestConfirmationList.js
teneeto Dec 29, 2023
7a1345b
fix typo
teneeto Dec 29, 2023
e64a73e
fix typo
teneeto Dec 29, 2023
0d69fac
fix prop types
teneeto Dec 29, 2023
40cd5a3
use default tax amount to check invalidTaxAmont
teneeto Dec 30, 2023
21d6849
Merge branch 'main' of github.com:teneeto/App into feat/31672/add-new…
teneeto Dec 30, 2023
f1644e9
Merge branch 'main' of github.com:teneeto/App into feat/31672/add-new…
teneeto Jan 1, 2024
844fdd4
Merge branch 'main' of github.com:teneeto/App into feat/31672/add-new…
teneeto Jan 2, 2024
70f3b99
Merge branch 'main' of github.com:teneeto/App into feat/31672/add-new…
teneeto Jan 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2912,6 +2912,7 @@ const CONST = {
PARENT_CHILD_SEPARATOR: ': ',
CATEGORY_LIST_THRESHOLD: 8,
TAG_LIST_THRESHOLD: 8,
TAX_RATES_LIST_THRESHOLD: 8,
DEMO_PAGES: {
SAASTR: 'SaaStrDemoSetup',
SBE: 'SbeDemoSetup',
Expand Down
1 change: 1 addition & 0 deletions src/ONYXKEYS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ const ONYXKEYS = {
POLICY_CATEGORIES: 'policyCategories_',
POLICY_RECENTLY_USED_CATEGORIES: 'policyRecentlyUsedCategories_',
POLICY_TAGS: 'policyTags_',
POLICY_TAX_RATE: 'policyTaxRates_',
POLICY_RECENTLY_USED_TAGS: 'policyRecentlyUsedTags_',
WORKSPACE_INVITE_MEMBERS_DRAFT: 'workspaceInviteMembersDraft_',
WORKSPACE_INVITE_MESSAGE_DRAFT: 'workspaceInviteMessageDraft_',
Expand Down
10 changes: 10 additions & 0 deletions src/ROUTES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,16 @@ const ROUTES = {
getRoute: (iouType: ValueOf<typeof CONST.IOU.TYPE>, transactionID: string, reportID: string, backTo = '') =>
getUrlWithBackToParam(`create/${iouType}/amount/${transactionID}/${reportID}/`, backTo),
},
MONEY_REQUEST_STEP_TAX_RATE: {
route: 'create/:iouType/taxRate/:transactionID/:reportID?',
getRoute: (iouType: ValueOf<typeof CONST.IOU.TYPE>, transactionID: string, reportID: string, backTo: string) =>
getUrlWithBackToParam(`create/${iouType}/taxRate/${transactionID}/${reportID}`, backTo),
},
MONEY_REQUEST_STEP_TAX_AMOUNT: {
route: 'create/:iouType/taxAmount/:transactionID/:reportID?',
getRoute: (iouType: ValueOf<typeof CONST.IOU.TYPE>, transactionID: string, reportID: string, backTo: string) =>
getUrlWithBackToParam(`create/${iouType}/taxAmount/${transactionID}/${reportID}`, backTo),
},
MONEY_REQUEST_STEP_CATEGORY: {
route: 'create/:iouType/category/:transactionID/:reportID/',
getRoute: (iouType: ValueOf<typeof CONST.IOU.TYPE>, transactionID: string, reportID: string, backTo = '') =>
Expand Down
2 changes: 2 additions & 0 deletions src/SCREENS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ const SCREENS = {
STEP_SCAN: 'Money_Request_Step_Scan',
STEP_TAG: 'Money_Request_Step_Tag',
STEP_WAYPOINT: 'Money_Request_Step_Waypoint',
STEP_TAX_AMOUNT: 'Money_Request_Step_Tax_Amount',
STEP_TAX_RATE: 'Money_Request_Step_Tax_Rate',
ROOT: 'Money_Request',
AMOUNT: 'Money_Request_Amount',
PARTICIPANTS: 'Money_Request_Participants',
Expand Down
51 changes: 50 additions & 1 deletion src/components/MoneyRequestConfirmationList.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import SettlementButton from './SettlementButton';
import ShowMoreButton from './ShowMoreButton';
import Switch from './Switch';
import tagPropTypes from './tagPropTypes';
import taxPropTypes from './taxPropTypes';
import Text from './Text';
import transactionPropTypes from './transactionPropTypes';
import withCurrentUserPersonalDetails, {withCurrentUserPersonalDetailsDefaultProps, withCurrentUserPersonalDetailsPropTypes} from './withCurrentUserPersonalDetails';
Expand Down Expand Up @@ -164,6 +165,10 @@ const propTypes = {
/** Collection of tags attached to a policy */
policyTags: tagPropTypes,

/* Onyx Props */
/** Collection of tax rates attached to a policy */
policyTaxRates: taxPropTypes,

/** Holds data related to Money Request view state, rather than the underlying Money Request data. */
iou: iouPropTypes,
};
Expand Down Expand Up @@ -200,6 +205,7 @@ const defaultProps = {
shouldShowSmartScanFields: true,
isPolicyExpenseChat: false,
iou: iouDefaultProps,
policyTaxRates: {},
};

function MoneyRequestConfirmationList(props) {
Expand Down Expand Up @@ -241,6 +247,9 @@ function MoneyRequestConfirmationList(props) {
// A flag for showing the tags field
const shouldShowTags = props.isPolicyExpenseChat && (props.iouTag || OptionsListUtils.hasEnabledOptions(_.values(policyTagList)));

// A flag for showing tax fields - tax rate and tax amount
const shouldShowTax = props.isPolicyExpenseChat && props.policy.isTaxTrackingEnabled;

// A flag for showing the billable field
const shouldShowBillable = !lodashGet(props.policy, 'disabledFields.defaultBillable', true);

Expand All @@ -252,6 +261,7 @@ function MoneyRequestConfirmationList(props) {
shouldCalculateDistanceAmount ? DistanceRequestUtils.getDistanceRequestAmount(distance, unit, rate) : props.iouAmount,
props.isDistanceRequest ? currency : props.iouCurrencyCode,
);
const formattedTaxAmount = CurrencyUtils.convertToDisplayString(props.transaction.taxAmount, props.iouCurrencyCode);

const isFocused = useIsFocused();
const [formError, setFormError] = useState('');
Expand Down Expand Up @@ -336,6 +346,8 @@ function MoneyRequestConfirmationList(props) {
const canModifyParticipants = !props.isReadOnly && props.canModifyParticipants && props.hasMultipleParticipants;
const shouldDisablePaidBySection = canModifyParticipants;

const defaultTaxName = `${props.policyTaxRates.name} • ${translate('common.default')}`;

const optionSelectorSections = useMemo(() => {
const sections = [];
const unselectedParticipants = _.filter(props.selectedParticipants, (participant) => !participant.selected);
Expand Down Expand Up @@ -738,6 +750,40 @@ function MoneyRequestConfirmationList(props) {
/>
)}

{shouldShowTax && (
<MenuItemWithTopDescription
shouldShowRightIcon={!props.isReadOnly}
title={(props.transaction.taxRate && props.transaction.taxRate.text) || defaultTaxName}
description={translate('iou.taxRate')}
style={[styles.moneyRequestMenuItem]}
titleStyle={styles.flex1}
onPress={() =>
Navigation.navigate(
ROUTES.MONEY_REQUEST_STEP_TAX_RATE.getRoute(props.iouType, props.transaction.transactionID, props.reportID, Navigation.getActiveRouteWithoutParams()),
)
}
disabled={didConfirm}
interactive={!props.isReadOnly}
/>
)}

{shouldShowTax && (
<MenuItemWithTopDescription
shouldShowRightIcon={!props.isReadOnly}
title={formattedTaxAmount}
description={translate('iou.taxAmount')}
style={[styles.moneyRequestMenuItem]}
titleStyle={styles.flex1}
onPress={() =>
Navigation.navigate(
ROUTES.MONEY_REQUEST_STEP_TAX_AMOUNT.getRoute(props.iouType, props.transaction.transactionID, props.reportID, Navigation.getActiveRouteWithoutParams()),
)
}
disabled={didConfirm}
interactive={!props.isReadOnly}
/>
)}

{shouldShowBillable && (
<View style={[styles.flexRow, styles.justifyContentBetween, styles.alignItemsCenter, styles.ml5, styles.mr8, styles.optionRow]}>
<Text color={!props.iouIsBillable ? theme.textSupporting : undefined}>{translate('common.billable')}</Text>
Expand Down Expand Up @@ -774,12 +820,15 @@ export default compose(
key: ({policyID}) => `${ONYXKEYS.COLLECTION.POLICY}${policyID}`,
selector: DistanceRequestUtils.getDefaultMileageRate,
},
draftTransaction: {
splitTransactionDraft: {
Copy link
Contributor

@MonilBhavsar MonilBhavsar Jan 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NAB, this seems unused and can be removed in a follow up PR as it is unrelated to this change

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

O will see to it.

key: ({transactionID}) => `${ONYXKEYS.COLLECTION.SPLIT_TRANSACTION_DRAFT}${transactionID}`,
},
policy: {
key: ({policyID}) => `${ONYXKEYS.COLLECTION.POLICY}${policyID}`,
},
policyTaxRates: {
key: ({policyID}) => `${ONYXKEYS.COLLECTION.POLICY_TAX_RATE}${policyID}`,
},
iou: {
key: ONYXKEYS.IOU,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import OptionsSelector from './OptionsSelector';
import SettlementButton from './SettlementButton';
import Switch from './Switch';
import tagPropTypes from './tagPropTypes';
import taxPropTypes from './taxPropTypes';
import Text from './Text';
import transactionPropTypes from './transactionPropTypes';
import withCurrentUserPersonalDetails, {withCurrentUserPersonalDetailsDefaultProps, withCurrentUserPersonalDetailsPropTypes} from './withCurrentUserPersonalDetails';
Expand Down Expand Up @@ -159,6 +160,10 @@ const propTypes = {
/** Collection of tags attached to a policy */
policyTags: tagPropTypes,

/* Onyx Props */
/** Collection of tax rates attached to a policy */
policyTaxRates: taxPropTypes,

/** Transaction that represents the money request */
transaction: transactionPropTypes,
};
Expand Down Expand Up @@ -194,6 +199,7 @@ const defaultProps = {
isScanRequest: false,
shouldShowSmartScanFields: true,
isPolicyExpenseChat: false,
policyTaxRates: {},
};

function MoneyTemporaryForRefactorRequestConfirmationList({
Expand Down Expand Up @@ -235,6 +241,7 @@ function MoneyTemporaryForRefactorRequestConfirmationList({
session: {accountID},
shouldShowSmartScanFields,
transaction,
policyTaxRates,
}) {
const theme = useTheme();
const styles = useThemeStyles();
Expand Down Expand Up @@ -271,6 +278,9 @@ function MoneyTemporaryForRefactorRequestConfirmationList({
// A flag for showing the tags field
const shouldShowTags = isPolicyExpenseChat && OptionsListUtils.hasEnabledOptions(_.values(policyTagList));

// A flag for showing tax rate
const shouldShowTax = isPolicyExpenseChat && policy.isTaxTrackingEnabled;

// A flag for showing the billable field
const shouldShowBillable = !lodashGet(policy, 'disabledFields.defaultBillable', true);

Expand All @@ -282,7 +292,7 @@ function MoneyTemporaryForRefactorRequestConfirmationList({
shouldCalculateDistanceAmount ? DistanceRequestUtils.getDistanceRequestAmount(distance, unit, rate) : iouAmount,
isDistanceRequest ? currency : iouCurrencyCode,
);

const formattedTaxAmount = CurrencyUtils.convertToDisplayString(transaction.taxAmount, iouCurrencyCode);
const isFocused = useIsFocused();
const [formError, setFormError] = useState('');

Expand Down Expand Up @@ -366,6 +376,8 @@ function MoneyTemporaryForRefactorRequestConfirmationList({
}, [isReadOnly, canModifyParticipants, hasMultipleParticipants]);
const shouldDisablePaidBySection = userCanModifyParticipants.current;

const defaultTaxName = `${policyTaxRates.name} • ${translate('common.default')}`;
teneeto marked this conversation as resolved.
Show resolved Hide resolved

const optionSelectorSections = useMemo(() => {
const sections = [];
const unselectedParticipants = _.filter(pickedParticipants, (participant) => !participant.selected);
Expand Down Expand Up @@ -738,6 +750,35 @@ function MoneyTemporaryForRefactorRequestConfirmationList({
interactive={!isReadOnly}
/>
)}
{shouldShowTax && (
<MenuItemWithTopDescription
shouldShowRightIcon={!isReadOnly}
title={(transaction.taxRate && transaction.taxRate.text) || defaultTaxName}
description={translate('iou.taxRate')}
teneeto marked this conversation as resolved.
Show resolved Hide resolved
style={[styles.moneyRequestMenuItem]}
titleStyle={styles.flex1}
onPress={() =>
Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_TAX_RATE.getRoute(iouType, transaction.transactionID, reportID, Navigation.getActiveRouteWithoutParams()))
}
disabled={didConfirm}
interactive={!isReadOnly}
/>
)}

{shouldShowTax && (
<MenuItemWithTopDescription
shouldShowRightIcon={!isReadOnly}
title={formattedTaxAmount}
description={translate('iou.taxAmount')}
style={[styles.moneyRequestMenuItem]}
titleStyle={styles.flex1}
onPress={() =>
Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_TAX_AMOUNT.getRoute(iouType, transaction.transactionID, reportID, Navigation.getActiveRouteWithoutParams()))
}
disabled={didConfirm}
interactive={!isReadOnly}
/>
)}
{shouldShowBillable && (
<View style={[styles.flexRow, styles.justifyContentBetween, styles.alignItemsCenter, styles.ml5, styles.mr8, styles.optionRow]}>
<Text color={!iouIsBillable ? theme.textSupporting : undefined}>{translate('common.billable')}</Text>
Expand Down Expand Up @@ -777,5 +818,8 @@ export default compose(
policy: {
key: ({policyID}) => `${ONYXKEYS.COLLECTION.POLICY}${policyID}`,
},
policyTaxRates: {
key: ({policyID}) => `${ONYXKEYS.COLLECTION.POLICY_TAX_RATE}${policyID}`,
},
}),
)(MoneyTemporaryForRefactorRequestConfirmationList);
89 changes: 89 additions & 0 deletions src/components/TaxPicker/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
import lodashGet from 'lodash/get';
import React, {useMemo, useState} from 'react';
import _ from 'underscore';
import OptionsSelector from '@components/OptionsSelector';
import useLocalize from '@hooks/useLocalize';
import useStyleUtils from '@hooks/useStyleUtils';
import useThemeStyles from '@hooks/useThemeStyles';
import * as OptionsListUtils from '@libs/OptionsListUtils';
import CONST from '@src/CONST';
import {defaultProps, propTypes} from './taxPickerPropTypes';

function TaxPicker({selectedTaxRate, policyTaxRates, insets, onSubmit}) {
const styles = useThemeStyles();
const StyleUtils = useStyleUtils();
const {translate} = useLocalize();
const [searchValue, setSearchValue] = useState('');

const policyTaxRatesCount = OptionsListUtils.getEnabledTaxRateCount(policyTaxRates.taxes);
const isTaxRatesCountBelowThreshold = policyTaxRatesCount < CONST.TAX_RATES_LIST_THRESHOLD;

const shouldShowTextInput = !isTaxRatesCountBelowThreshold;

const selectedOptions = useMemo(() => {
if (!selectedTaxRate) {
return [];
}

return [
{
name: selectedTaxRate,
enabled: true,
accountID: null,
},
];
}, [selectedTaxRate]);

const sections = useMemo(() => {
const {policyTaxRatesOptions} = OptionsListUtils.getFilteredOptions(
{},
{},
[],
searchValue,
selectedOptions,
[],
false,
false,
false,
{},
[],
false,
{},
[],
false,
false,
true,
policyTaxRates,
);
return policyTaxRatesOptions;
}, [policyTaxRates, searchValue, selectedOptions]);

const selectedOptionKey = lodashGet(_.filter(lodashGet(sections, '[0].data', []), (taxRate) => taxRate.searchText === selectedTaxRate)[0], 'keyForList');

return (
<OptionsSelector
contentContainerStyles={[{paddingBottom: StyleUtils.getSafeAreaMargins(insets).marginBottom}]}
optionHoveredStyle={styles.hoveredComponentBG}
sectionHeaderStyle={styles.mt5}
sections={sections}
selectedOptions={selectedOptions}
value={searchValue}
// Focus the first option when searching
focusedIndex={0}
initiallyFocusedOptionKey={selectedOptionKey}
textInputLabel={translate('common.search')}
boldStyle
highlightSelectedOptions
isRowMultilineSupported
shouldShowTextInput={shouldShowTextInput}
onChangeText={setSearchValue}
onSelectRow={onSubmit}
/>
);
}

TaxPicker.displayName = 'TaxPicker';
TaxPicker.propTypes = propTypes;
TaxPicker.defaultProps = defaultProps;

export default TaxPicker;
21 changes: 21 additions & 0 deletions src/components/TaxPicker/taxPickerPropTypes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import PropTypes from 'prop-types';
import taxPropTypes from '@components/taxPropTypes';

const propTypes = {
/** The selected tax rate of an expense */
selectedTaxRate: PropTypes.string,

/** Callback to fire when a tax is pressed */
onSubmit: PropTypes.func.isRequired,

/* Onyx Props */
/** Collection of tax rates attached to a policy */
policyTaxRates: taxPropTypes,
};

const defaultProps = {
selectedTaxRate: '',
policyTaxRates: {},
};

export {propTypes, defaultProps};
Loading
Loading