Skip to content

Commit

Permalink
Merge pull request #19748 from Expensify/cmartins-fixUnitRates
Browse files Browse the repository at this point in the history
Fix unit rates

(cherry picked from commit 6bebb33)
  • Loading branch information
luacmartins authored and OSBotify committed May 29, 2023
1 parent 862cce7 commit c7bee90
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/libs/actions/Policy.js
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,7 @@ function updateWorkspaceCustomUnitAndRate(policyID, currentCustomUnit, newCustom
value: {
customUnits: {
[currentCustomUnit.customUnitID]: {
...currentCustomUnit.customUnitID,
customUnitID: currentCustomUnit.customUnitID,
rates: {
[currentCustomUnit.rates.customUnitRateID]: {
...currentCustomUnit.rates,
Expand Down
5 changes: 2 additions & 3 deletions src/pages/workspace/reimburse/WorkspaceRateAndUnitPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ class WorkspaceRateAndUnitPage extends React.Component {
const distanceCustomRate = _.find(lodashGet(distanceCustomUnit, 'rates', {}), (rate) => rate.name === 'Default Rate');
return (
<WorkspacePageWithSections
shouldUseScrollView
headerText={this.props.translate('workspace.reimburse.trackDistance')}
route={this.props.route}
guidesCallTaskID={CONST.GUIDES_CALL_TASK_IDS.WORKSPACE_REIMBURSE}
Expand All @@ -125,9 +124,9 @@ class WorkspaceRateAndUnitPage extends React.Component {
<OfflineWithFeedback
errors={{
...lodashGet(distanceCustomUnit, 'errors', {}),
...lodashGet(distanceCustomRate.errors, 'errors', {}),
...lodashGet(distanceCustomRate, 'errors', {}),
}}
pendingAction={distanceCustomUnit.pendingAction || distanceCustomRate.pendingAction}
pendingAction={lodashGet(distanceCustomUnit, 'pendingAction') || lodashGet(distanceCustomRate, 'pendingAction')}
onClose={() =>
Policy.clearCustomUnitErrors(this.props.policy.id, lodashGet(distanceCustomUnit, 'customUnitID', ''), lodashGet(distanceCustomRate, 'customUnitRateID', ''))
}
Expand Down
23 changes: 16 additions & 7 deletions src/pages/workspace/reimburse/WorkspaceReimburseView.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {withNetwork} from '../../../components/OnyxProvider';
import networkPropTypes from '../../../components/networkPropTypes';
import WorkspaceReimburseSection from './WorkspaceReimburseSection';
import * as BankAccounts from '../../../libs/actions/BankAccounts';
import OfflineWithFeedback from '../../../components/OfflineWithFeedback';

const propTypes = {
/** Policy values needed in the component */
Expand Down Expand Up @@ -131,6 +132,8 @@ class WorkspaceReimburseView extends React.Component {

render() {
const viewAllReceiptsUrl = `expenses?policyIDList=${this.props.policy.id}&billableReimbursable=reimbursable&submitterEmail=%2B%2B`;
const distanceCustomUnit = _.find(lodashGet(this.props, 'policy.customUnits', {}), (unit) => unit.name === 'Distance');
const distanceCustomRate = _.find(lodashGet(distanceCustomUnit, 'rates', {}), (rate) => rate.name === 'Default Rate');
return (
<>
<Section
Expand Down Expand Up @@ -167,13 +170,19 @@ class WorkspaceReimburseView extends React.Component {
<View style={[styles.mv3]}>
<Text>{this.props.translate('workspace.reimburse.trackDistanceCopy')}</Text>
</View>
<MenuItemWithTopDescription
title={this.state.currentRatePerUnit}
description={this.props.translate('workspace.reimburse.trackDistanceRate')}
shouldShowRightIcon
onPress={() => Navigation.navigate(ROUTES.getWorkspaceRateAndUnitRoute(this.props.policy.id))}
wrapperStyle={[styles.mhn5, styles.wAuto]}
/>
<OfflineWithFeedback
pendingAction={lodashGet(distanceCustomUnit, 'pendingAction') || lodashGet(distanceCustomRate, 'pendingAction')}
shouldShowErrorMessages={false}
>
<MenuItemWithTopDescription
title={this.state.currentRatePerUnit}
description={this.props.translate('workspace.reimburse.trackDistanceRate')}
shouldShowRightIcon
onPress={() => Navigation.navigate(ROUTES.getWorkspaceRateAndUnitRoute(this.props.policy.id))}
wrapperStyle={[styles.mhn5, styles.wAuto]}
brickRoadIndicator={(lodashGet(distanceCustomUnit, 'errors') || lodashGet(distanceCustomRate, 'errors')) && CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR}
/>
</OfflineWithFeedback>
</Section>

<WorkspaceReimburseSection
Expand Down

0 comments on commit c7bee90

Please sign in to comment.