Skip to content

Commit

Permalink
fix: always enable the default first rate entry
Browse files Browse the repository at this point in the history
  • Loading branch information
dominictb committed Jun 20, 2024
1 parent d92bbdb commit 0bbe021
Showing 1 changed file with 1 addition and 10 deletions.
11 changes: 1 addition & 10 deletions src/libs/actions/Policy/DistanceRate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,16 +133,7 @@ function enablePolicyDistanceRates(policyID: string, enabled: boolean) {

const rateEntries = Object.entries(customUnit?.rates ?? {});
// find the rate to be enabled after disabling the distance rate feature
// first check the default rate
let rateEntryToBeEnabled = rateEntries.find((rate) => rate[1]?.name === 'Default Rate');
// if the default rate is not enabled/doesn't exist, we'll switch to the first enabled rate
if (!rateEntryToBeEnabled?.[1] || !rateEntryToBeEnabled[1].enabled) {
rateEntryToBeEnabled = rateEntries.find((rate) => !!rate[1]?.enabled);
}
// if no rate is enabled, we'll switch to the first rate
if (!rateEntryToBeEnabled?.[1]) {
rateEntryToBeEnabled = rateEntries[0];
}
const rateEntryToBeEnabled = rateEntries[0];

onyxData.optimisticData?.push({
onyxMethod: Onyx.METHOD.MERGE,
Expand Down

0 comments on commit 0bbe021

Please sign in to comment.