11import type { OnyxEntry } from 'react-native-onyx' ;
2+ import type { LocaleContextProps } from '@components/LocaleContextProvider' ;
23import CONST from '@src/CONST' ;
34import type { Policy , TaxRate , TaxRates , Transaction } from '@src/types/onyx' ;
45import type * as OnyxCommon from '@src/types/onyx/OnyxCommon' ;
5- import localeCompare from './LocaleCompare' ;
66import tokenizedSearch from './tokenizedSearch' ;
77import { transformedTaxRates } from './TransactionUtils' ;
88
@@ -32,7 +32,7 @@ type TaxSection = {
3232/**
3333 * Sorts tax rates alphabetically by name.
3434 */
35- function sortTaxRates ( taxRates : TaxRates ) : TaxRate [ ] {
35+ function sortTaxRates ( taxRates : TaxRates , localeCompare : LocaleContextProps [ 'localeCompare' ] ) : TaxRate [ ] {
3636 const sortedTaxRates = Object . values ( taxRates ) . sort ( ( a , b ) => localeCompare ( a . name , b . name ) ) ;
3737 return sortedTaxRates ;
3838}
@@ -59,19 +59,21 @@ function getTaxRatesOptions(taxRates: Array<Partial<TaxRate>>): TaxRatesOption[]
5959function getTaxRatesSection ( {
6060 policy,
6161 searchValue,
62+ localeCompare,
6263 selectedOptions = [ ] ,
6364 transaction,
6465} : {
6566 policy : OnyxEntry < Policy > | undefined ;
6667 searchValue : string ;
68+ localeCompare : LocaleContextProps [ 'localeCompare' ] ;
6769 selectedOptions ?: Tax [ ] ;
6870 transaction ?: OnyxEntry < Transaction > ;
6971} ) : TaxSection [ ] {
7072 const policyRatesSections = [ ] ;
7173
7274 const taxes = transformedTaxRates ( policy , transaction ) ;
7375
74- const sortedTaxRates = sortTaxRates ( taxes ) ;
76+ const sortedTaxRates = sortTaxRates ( taxes , localeCompare ) ;
7577 const selectedOptionNames = selectedOptions . map ( ( selectedOption ) => selectedOption . modifiedName ) ;
7678 const enabledTaxRates = sortedTaxRates . filter ( ( taxRate ) => ! taxRate . isDisabled ) ;
7779 const enabledTaxRatesNames = enabledTaxRates . map ( ( tax ) => tax . modifiedName ) ;
0 commit comments