Skip to content

Commit

Permalink
Merge pull request #10974 from Expensify/jasper-removeOnyxRates
Browse files Browse the repository at this point in the history
Remove usages of `onyxRates`
  • Loading branch information
jasperhuangg authored Sep 15, 2022
2 parents 2e13fbe + f841732 commit 05f41cb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions src/libs/actions/Policy.js
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ function clearCustomUnitErrors(policyID, customUnitID, customUnitRateID) {
[customUnitID]: {
errors: null,
pendingAction: null,
onyxRates: {
rates: {
[customUnitRateID]: {
errors: null,
pendingAction: null,
Expand Down Expand Up @@ -626,7 +626,7 @@ function updateCustomUnitRate(policyID, currentCustomUnitRate, customUnitID, new
value: {
customUnits: {
[customUnitID]: {
onyxRates: {
rates: {
[newCustomUnitRate.customUnitRateID]: {
...newCustomUnitRate,
errors: null,
Expand All @@ -646,7 +646,7 @@ function updateCustomUnitRate(policyID, currentCustomUnitRate, customUnitID, new
value: {
customUnits: {
[customUnitID]: {
onyxRates: {
rates: {
[newCustomUnitRate.customUnitRateID]: {
pendingAction: null,
},
Expand All @@ -664,7 +664,7 @@ function updateCustomUnitRate(policyID, currentCustomUnitRate, customUnitID, new
value: {
customUnits: {
[customUnitID]: {
onyxRates: {
rates: {
[currentCustomUnitRate.customUnitRateID]: {
...currentCustomUnitRate,
errors: {
Expand Down
12 changes: 6 additions & 6 deletions src/pages/workspace/reimburse/WorkspaceReimburseView.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const propTypes = {
attributes: PropTypes.shape({
unit: PropTypes.string,
}),
onyxRates: PropTypes.objectOf(
rates: PropTypes.objectOf(
PropTypes.shape({
customUnitRateID: PropTypes.string,
name: PropTypes.string,
Expand All @@ -64,7 +64,7 @@ class WorkspaceReimburseView extends React.Component {
constructor(props) {
super(props);
const distanceCustomUnit = _.find(lodashGet(props, 'policy.customUnits', {}), unit => unit.name === 'Distance');
const customUnitRate = _.find(lodashGet(distanceCustomUnit, 'onyxRates', {}), rate => rate.name === 'Default Rate');
const customUnitRate = _.find(lodashGet(distanceCustomUnit, 'rates', {}), rate => rate.name === 'Default Rate');

this.state = {
unitID: lodashGet(distanceCustomUnit, 'customUnitID', ''),
Expand Down Expand Up @@ -100,7 +100,7 @@ class WorkspaceReimburseView extends React.Component {
.values()
.findWhere({name: CONST.CUSTOM_UNITS.NAME_DISTANCE})
.value();
const customUnitRate = _.find(lodashGet(distanceCustomUnit, 'onyxRates', {}), rate => rate.name === 'Default Rate');
const customUnitRate = _.find(lodashGet(distanceCustomUnit, 'rates', {}), rate => rate.name === 'Default Rate');
this.setState({
unitID: lodashGet(distanceCustomUnit, 'customUnitID', ''),
unitName: lodashGet(distanceCustomUnit, 'name', ''),
Expand Down Expand Up @@ -184,7 +184,7 @@ class WorkspaceReimburseView extends React.Component {
}

const distanceCustomUnit = _.find(lodashGet(this.props, 'policy.customUnits', {}), unit => unit.name === 'Distance');
const currentCustomUnitRate = lodashGet(distanceCustomUnit, ['onyxRates', this.state.unitRateID], {});
const currentCustomUnitRate = lodashGet(distanceCustomUnit, ['rates', this.state.unitRateID], {});
Policy.updateCustomUnitRate(this.props.policyID, currentCustomUnitRate, this.state.unitID, {
...currentCustomUnitRate,
rate: numValue * CONST.POLICY.CUSTOM_UNIT_RATE_BASE_OFFSET,
Expand Down Expand Up @@ -230,10 +230,10 @@ class WorkspaceReimburseView extends React.Component {
<OfflineWithFeedback
errors={{
...lodashGet(this.props, ['policy', 'customUnits', this.state.unitID, 'errors'], {}),
...lodashGet(this.props, ['policy', 'customUnits', this.state.unitID, 'onyxRates', this.state.unitRateID, 'errors'], {}),
...lodashGet(this.props, ['policy', 'customUnits', this.state.unitID, 'rates', this.state.unitRateID, 'errors'], {}),
}}
pendingAction={lodashGet(this.props, ['policy', 'customUnits', this.state.unitID, 'pendingAction'])
|| lodashGet(this.props, ['policy', 'customUnits', this.state.unitID, 'onyxRates', this.state.unitRateID, 'pendingAction'])}
|| lodashGet(this.props, ['policy', 'customUnits', this.state.unitID, 'rates', this.state.unitRateID, 'pendingAction'])}
onClose={() => Policy.clearCustomUnitErrors(this.props.policyID, this.state.unitID, this.state.unitRateID)}
>
<View style={[styles.flexRow, styles.alignItemsCenter, styles.mv2]}>
Expand Down

0 comments on commit 05f41cb

Please sign in to comment.