Skip to content

Commit

Permalink
Moved CountrySelectorUtils to searchCountryOptions
Browse files Browse the repository at this point in the history
  • Loading branch information
huzaifa-99 committed Aug 7, 2023
1 parent 3873f13 commit 28e5f9c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/components/CountryPicker/CountrySelectorModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import useLocalize from '../../hooks/useLocalize';
import HeaderWithBackButton from '../HeaderWithBackButton';
import SelectionListRadio from '../SelectionListRadio';
import Modal from '../Modal';
import searchOptions from '../../libs/CountrySelectorUtils';
import searchOptions from '../../libs/searchCountryOptions';

const propTypes = {
/** Whether the modal is visible */
Expand Down
2 changes: 1 addition & 1 deletion src/components/StatePicker/StateSelectorModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Modal from '../Modal';
import HeaderWithBackButton from '../HeaderWithBackButton';
import SelectionListRadio from '../SelectionListRadio';
import useLocalize from '../../hooks/useLocalize';
import searchOptions from '../../libs/CountrySelectorUtils';
import searchOptions from '../../libs/searchCountryOptions';

const propTypes = {
/** Whether the modal is visible */
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import _ from 'underscore';
import CONST from '../../CONST';
import CONST from '../CONST';

/**
* Searches the countriesData and returns sorted results based on country code
* Searches the countries/states data and returns sorted results based on the search query
* @param {String} searchValue
* @param {Object[]} countriesData - An array of country data objects
* @returns {Object[]} An array of sorted country data based on country code
* @returns {Object[]} An array of countries/states sorted based on the search query
*/
function searchOptions(searchValue, countriesData) {
function searchCountryOptions(searchValue, countriesData) {
const trimmedSearchValue = searchValue.toLowerCase().replaceAll(CONST.REGEX.NON_ALPHABETIC_AND_NON_LATIN_CHARS, '');
if (trimmedSearchValue.length === 0) {
return [];
Expand All @@ -19,4 +19,4 @@ function searchOptions(searchValue, countriesData) {
return _.sortBy(filteredData, (country) => (country.value.toLowerCase() === trimmedSearchValue ? -1 : 1));
}

export default searchOptions;
export default searchCountryOptions;

0 comments on commit 28e5f9c

Please sign in to comment.