Skip to content

Commit

Permalink
add review suggested changes
Browse files Browse the repository at this point in the history
  • Loading branch information
cdOut committed Dec 13, 2023
1 parent 5bd899f commit b68dae0
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions src/pages/workspace/reimburse/WorkspaceRateAndUnitPage.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import lodashGet from 'lodash/get';
import React, {useCallback, useEffect} from 'react';
import React, {useEffect} from 'react';
import {Keyboard, View} from 'react-native';
import {withOnyx} from 'react-native-onyx';
import _ from 'underscore';
Expand Down Expand Up @@ -37,7 +37,7 @@ const defaultProps = {
};

function WorkspaceRateAndUnitPage(props) {
const fetchData = useCallback(() => {
useEffect(() => {
if (lodashGet(props, 'policy.customUnits', []).length !== 0) {
return;
}
Expand All @@ -46,17 +46,13 @@ function WorkspaceRateAndUnitPage(props) {
Policy.openWorkspaceReimburseView(props.policy.id);
}, [props]);

useEffect(() => {
fetchData();
}, [fetchData]);

const getUnitItems = () => [
const unitItems = [
{label: props.translate('common.kilometers'), value: CONST.CUSTOM_UNITS.DISTANCE_UNIT_KILOMETERS},
{label: props.translate('common.miles'), value: CONST.CUSTOM_UNITS.DISTANCE_UNIT_MILES},
];

const saveUnitAndRate = (unit, rate) => {
const distanceCustomUnit = _.find(lodashGet(props, 'policy.customUnits', {}), (u) => u.name === CONST.CUSTOM_UNITS.NAME_DISTANCE);
const distanceCustomUnit = _.find(lodashGet(props, 'policy.customUnits', {}), (customUnit) => customUnit.name === CONST.CUSTOM_UNITS.NAME_DISTANCE);
if (!distanceCustomUnit) {
return;
}
Expand Down Expand Up @@ -148,7 +144,7 @@ function WorkspaceRateAndUnitPage(props) {
InputComponent={Picker}
inputID="unit"
label={props.translate('workspace.reimburse.trackDistanceUnit')}
items={getUnitItems()}
items={unitItems}
defaultValue={lodashGet(distanceCustomUnit, 'attributes.unit', CONST.CUSTOM_UNITS.DISTANCE_UNIT_MILES)}
/>
</View>
Expand Down

0 comments on commit b68dae0

Please sign in to comment.