Skip to content

Commit

Permalink
Merge pull request #43537 from Krishna2323/krishna2323/issue/42939
Browse files Browse the repository at this point in the history
fix: Distance rates - Order of distance rates is not preserved after clearing cache and restarting.
  • Loading branch information
tgolen authored Jun 17, 2024
2 parents 2b8801e + 32137bb commit c61f186
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions src/pages/workspace/distanceRates/PolicyDistanceRatesPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,18 +100,20 @@ function PolicyDistanceRatesPage({policy, route}: PolicyDistanceRatesPageProps)

const distanceRatesList = useMemo<RateForList[]>(
() =>
Object.values(customUnitRates).map((value) => ({
value: value.customUnitRateID ?? '',
text: `${CurrencyUtils.convertAmountToDisplayString(value.rate, value.currency ?? CONST.CURRENCY.USD)} / ${translate(
`common.${customUnit?.attributes?.unit ?? CONST.CUSTOM_UNITS.DISTANCE_UNIT_MILES}`,
)}`,
keyForList: value.customUnitRateID ?? '',
isSelected: selectedDistanceRates.find((rate) => rate.customUnitRateID === value.customUnitRateID) !== undefined,
isDisabled: value.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE,
pendingAction: value.pendingAction ?? value.pendingFields?.rate ?? value.pendingFields?.enabled ?? value.pendingFields?.currency,
errors: value.errors ?? undefined,
rightElement: <ListItemRightCaretWithLabel labelText={value.enabled ? translate('workspace.common.enabled') : translate('workspace.common.disabled')} />,
})),
Object.values(customUnitRates)
.sort((rateA, rateB) => (rateA?.rate ?? 0) - (rateB?.rate ?? 0))
.map((value) => ({
value: value.customUnitRateID ?? '',
text: `${CurrencyUtils.convertAmountToDisplayString(value.rate, value.currency ?? CONST.CURRENCY.USD)} / ${translate(
`common.${customUnit?.attributes?.unit ?? CONST.CUSTOM_UNITS.DISTANCE_UNIT_MILES}`,
)}`,
keyForList: value.customUnitRateID ?? '',
isSelected: selectedDistanceRates.find((rate) => rate.customUnitRateID === value.customUnitRateID) !== undefined,
isDisabled: value.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE,
pendingAction: value.pendingAction ?? value.pendingFields?.rate ?? value.pendingFields?.enabled ?? value.pendingFields?.currency,
errors: value.errors ?? undefined,
rightElement: <ListItemRightCaretWithLabel labelText={value.enabled ? translate('workspace.common.enabled') : translate('workspace.common.disabled')} />,
})),
[customUnit?.attributes?.unit, customUnitRates, selectedDistanceRates, translate],
);

Expand Down

0 comments on commit c61f186

Please sign in to comment.