From 7260fa1f8d0512a44e031bde8bcad91a3aec8f6a Mon Sep 17 00:00:00 2001 From: Huzaifa Rasheed Date: Fri, 4 Aug 2023 02:33:15 +0500 Subject: [PATCH 01/10] Update country search to work with leading/trailing spaces and non-alphabet chars from country name --- src/CONST.js | 1 + src/components/CountryPicker/CountrySelectorModal.js | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/CONST.js b/src/CONST.js index 362e53fb0a1a..5d2311dc47fa 100755 --- a/src/CONST.js +++ b/src/CONST.js @@ -1165,6 +1165,7 @@ const CONST = { CARD_EXPIRATION_DATE: /^(0[1-9]|1[0-2])([^0-9])?([0-9]{4}|([0-9]{2}))$/, PAYPAL_ME_USERNAME: /^[a-zA-Z0-9]{1,20}$/, ROOM_NAME: /^#[a-z0-9à-ÿ-]{1,80}$/, + COUNTRY_NAME_WITH_ONLY_ALPHABETS: /[-'().&\s]/g, // eslint-disable-next-line max-len, no-misleading-character-class EMOJIS: /[\p{Extended_Pictographic}\u200d\u{1f1e6}-\u{1f1ff}\u{1f3fb}-\u{1f3ff}\u{e0020}-\u{e007f}\u20E3\uFE0F]|[#*0-9]\uFE0F?\u20E3/gu, diff --git a/src/components/CountryPicker/CountrySelectorModal.js b/src/components/CountryPicker/CountrySelectorModal.js index d16d97741d7c..b3df80988d74 100644 --- a/src/components/CountryPicker/CountrySelectorModal.js +++ b/src/components/CountryPicker/CountrySelectorModal.js @@ -34,12 +34,12 @@ const defaultProps = { }; function filterOptions(searchValue, data) { - const trimmedSearchValue = searchValue.trim(); - if (trimmedSearchValue.length === 0) { + const searchValueWithOnlyAlphabets = searchValue.toLowerCase().replaceAll(CONST.REGEX.COUNTRY_NAME_WITH_ONLY_ALPHABETS, ''); + if (searchValueWithOnlyAlphabets.length === 0) { return []; } - return _.filter(data, (country) => country.text.toLowerCase().includes(searchValue.toLowerCase())); + return _.filter(data, (country) => country.searchValue.includes(searchValueWithOnlyAlphabets)); } function CountrySelectorModal({currentCountry, isVisible, onClose, onCountrySelected, setSearchValue, searchValue}) { @@ -52,6 +52,7 @@ function CountrySelectorModal({currentCountry, isVisible, onClose, onCountrySele keyForList: countryISO, text: countryName, isSelected: currentCountry === countryISO, + searchValue: countryName.toLowerCase().replaceAll(CONST.REGEX.COUNTRY_NAME_WITH_ONLY_ALPHABETS, ''), })), [translate, currentCountry], ); From 3d5d105f4d9c00f93c065a7a723627bf7b9fd7e3 Mon Sep 17 00:00:00 2001 From: Huzaifa Rasheed Date: Fri, 4 Aug 2023 02:34:25 +0500 Subject: [PATCH 02/10] Allow countries to be searched by country code --- src/components/CountryPicker/CountrySelectorModal.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/CountryPicker/CountrySelectorModal.js b/src/components/CountryPicker/CountrySelectorModal.js index b3df80988d74..e0daf5f9213a 100644 --- a/src/components/CountryPicker/CountrySelectorModal.js +++ b/src/components/CountryPicker/CountrySelectorModal.js @@ -39,7 +39,7 @@ function filterOptions(searchValue, data) { return []; } - return _.filter(data, (country) => country.searchValue.includes(searchValueWithOnlyAlphabets)); + return _.filter(data, (country) => country.searchValue.includes(searchValueWithOnlyAlphabets) || country.value.toLowerCase().includes(searchValueWithOnlyAlphabets)); } function CountrySelectorModal({currentCountry, isVisible, onClose, onCountrySelected, setSearchValue, searchValue}) { From 75e5d78e4aa4212bc8d095d28116aa80b4f19688 Mon Sep 17 00:00:00 2001 From: Huzaifa Rasheed Date: Fri, 4 Aug 2023 02:51:14 +0500 Subject: [PATCH 03/10] Update state search to work with leading/trailing spaces --- src/components/StatePicker/StateSelectorModal.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/components/StatePicker/StateSelectorModal.js b/src/components/StatePicker/StateSelectorModal.js index 5bbd2363c4b3..dbb87a9f6e09 100644 --- a/src/components/StatePicker/StateSelectorModal.js +++ b/src/components/StatePicker/StateSelectorModal.js @@ -38,12 +38,12 @@ const defaultProps = { }; function filterOptions(searchValue, data) { - const trimmedSearchValue = searchValue.trim(); - if (trimmedSearchValue.length === 0) { + const searchValueWithOnlyAlphabets = searchValue.toLowerCase().replaceAll(' ', ''); + if (searchValueWithOnlyAlphabets.length === 0) { return []; } - return _.filter(data, (country) => country.text.toLowerCase().includes(searchValue.toLowerCase())); + return _.filter(data, (country) => country.searchValue.includes(searchValueWithOnlyAlphabets)); } function StateSelectorModal({currentState, isVisible, onClose, onStateSelected, searchValue, setSearchValue, label}) { @@ -56,6 +56,7 @@ function StateSelectorModal({currentState, isVisible, onClose, onStateSelected, keyForList: state.stateISO, text: state.stateName, isSelected: currentState === state.stateISO, + searchValue: state.stateName.toLowerCase().replaceAll(' ', ''), })), [translate, currentState], ); From 1a37a3ec4fc8ed42faae2b2cedb4c91d079b3579 Mon Sep 17 00:00:00 2001 From: Huzaifa Rasheed Date: Fri, 4 Aug 2023 02:52:19 +0500 Subject: [PATCH 04/10] Allow country states to be searched by state code --- src/components/StatePicker/StateSelectorModal.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/StatePicker/StateSelectorModal.js b/src/components/StatePicker/StateSelectorModal.js index dbb87a9f6e09..69d39ad7009e 100644 --- a/src/components/StatePicker/StateSelectorModal.js +++ b/src/components/StatePicker/StateSelectorModal.js @@ -43,7 +43,7 @@ function filterOptions(searchValue, data) { return []; } - return _.filter(data, (country) => country.searchValue.includes(searchValueWithOnlyAlphabets)); + return _.filter(data, (countryState) => countryState.searchValue.includes(searchValueWithOnlyAlphabets) || countryState.value.toLowerCase().includes(searchValueWithOnlyAlphabets)); } function StateSelectorModal({currentState, isVisible, onClose, onStateSelected, searchValue, setSearchValue, label}) { From 536048ac24182954ccc2f88ec3e037754459e34d Mon Sep 17 00:00:00 2001 From: Huzaifa Rasheed Date: Tue, 8 Aug 2023 01:16:23 +0500 Subject: [PATCH 05/10] Update state+country search to prioritize state code --- src/CONST.js | 2 +- .../CountryPicker/CountrySelectorModal.js | 17 ++++++++++------- .../StatePicker/StateSelectorModal.js | 17 ++++++++++------- 3 files changed, 21 insertions(+), 15 deletions(-) diff --git a/src/CONST.js b/src/CONST.js index 5d2311dc47fa..cc0ebd4f7bab 100755 --- a/src/CONST.js +++ b/src/CONST.js @@ -1152,6 +1152,7 @@ const CONST = { SPECIAL_CHARS_WITHOUT_NEWLINE: /((?!\n)[()-\s\t])/g, DIGITS_AND_PLUS: /^\+?[0-9]*$/, ALPHABETIC_AND_LATIN_CHARS: /^[a-zA-ZÀ-ÿ ]*$/, + NON_ALPHABETIC_AND_NON_LATIN_CHARS: /[^a-zA-ZÀ-ÿ]/g, POSITIVE_INTEGER: /^\d+$/, PO_BOX: /\b[P|p]?(OST|ost)?\.?\s*[O|o|0]?(ffice|FFICE)?\.?\s*[B|b][O|o|0]?[X|x]?\.?\s+[#]?(\d+)\b/, ANY_VALUE: /^.+$/, @@ -1165,7 +1166,6 @@ const CONST = { CARD_EXPIRATION_DATE: /^(0[1-9]|1[0-2])([^0-9])?([0-9]{4}|([0-9]{2}))$/, PAYPAL_ME_USERNAME: /^[a-zA-Z0-9]{1,20}$/, ROOM_NAME: /^#[a-z0-9à-ÿ-]{1,80}$/, - COUNTRY_NAME_WITH_ONLY_ALPHABETS: /[-'().&\s]/g, // eslint-disable-next-line max-len, no-misleading-character-class EMOJIS: /[\p{Extended_Pictographic}\u200d\u{1f1e6}-\u{1f1ff}\u{1f3fb}-\u{1f3ff}\u{e0020}-\u{e007f}\u20E3\uFE0F]|[#*0-9]\uFE0F?\u20E3/gu, diff --git a/src/components/CountryPicker/CountrySelectorModal.js b/src/components/CountryPicker/CountrySelectorModal.js index e0daf5f9213a..aaf468c63b27 100644 --- a/src/components/CountryPicker/CountrySelectorModal.js +++ b/src/components/CountryPicker/CountrySelectorModal.js @@ -33,13 +33,16 @@ const defaultProps = { onCountrySelected: () => {}, }; -function filterOptions(searchValue, data) { - const searchValueWithOnlyAlphabets = searchValue.toLowerCase().replaceAll(CONST.REGEX.COUNTRY_NAME_WITH_ONLY_ALPHABETS, ''); +function searchOptions(searchValue, data) { + const searchValueWithOnlyAlphabets = searchValue.toLowerCase().replaceAll(CONST.REGEX.NON_ALPHABETIC_AND_NON_LATIN_CHARS, ''); if (searchValueWithOnlyAlphabets.length === 0) { return []; } - return _.filter(data, (country) => country.searchValue.includes(searchValueWithOnlyAlphabets) || country.value.toLowerCase().includes(searchValueWithOnlyAlphabets)); + const filteredData = _.filter(data, (country) => country.searchValue.includes(searchValueWithOnlyAlphabets)); + + // sort by country code + return _.sortBy(filteredData, (country) => (country.value.toLowerCase() === searchValueWithOnlyAlphabets ? -1 : 1)); } function CountrySelectorModal({currentCountry, isVisible, onClose, onCountrySelected, setSearchValue, searchValue}) { @@ -52,13 +55,13 @@ function CountrySelectorModal({currentCountry, isVisible, onClose, onCountrySele keyForList: countryISO, text: countryName, isSelected: currentCountry === countryISO, - searchValue: countryName.toLowerCase().replaceAll(CONST.REGEX.COUNTRY_NAME_WITH_ONLY_ALPHABETS, ''), + searchValue: `${countryISO}${countryName}`.toLowerCase().replaceAll(CONST.REGEX.NON_ALPHABETIC_AND_NON_LATIN_CHARS, ''), })), [translate, currentCountry], ); - const filteredData = filterOptions(searchValue, countries); - const headerMessage = searchValue.trim() && !filteredData.length ? translate('common.noResultsFound') : ''; + const searchResults = searchOptions(searchValue, countries); + const headerMessage = searchValue.trim() && !searchResults.length ? translate('common.noResultsFound') : ''; return ( countryState.searchValue.includes(searchValueWithOnlyAlphabets) || countryState.value.toLowerCase().includes(searchValueWithOnlyAlphabets)); + const filteredData = _.filter(data, (countryState) => countryState.searchValue.includes(searchValueWithOnlyAlphabets)); + + // sort by state code + return _.sortBy(filteredData, (countryState) => (countryState.value.toLowerCase() === searchValueWithOnlyAlphabets ? -1 : 1)); } function StateSelectorModal({currentState, isVisible, onClose, onStateSelected, searchValue, setSearchValue, label}) { @@ -56,13 +59,13 @@ function StateSelectorModal({currentState, isVisible, onClose, onStateSelected, keyForList: state.stateISO, text: state.stateName, isSelected: currentState === state.stateISO, - searchValue: state.stateName.toLowerCase().replaceAll(' ', ''), + searchValue: `${state.stateISO}${state.stateName}`.toLowerCase().replaceAll(CONST.REGEX.NON_ALPHABETIC_AND_NON_LATIN_CHARS, ''), })), [translate, currentState], ); - const filteredData = filterOptions(searchValue, countryStates); - const headerMessage = searchValue.trim() && !filteredData.length ? translate('common.noResultsFound') : ''; + const searchResults = searchOptions(searchValue, countryStates); + const headerMessage = searchValue.trim() && !searchResults.length ? translate('common.noResultsFound') : ''; return ( Date: Tue, 8 Aug 2023 01:43:37 +0500 Subject: [PATCH 06/10] Updated variable name --- src/components/CountryPicker/CountrySelectorModal.js | 8 ++++---- src/components/StatePicker/StateSelectorModal.js | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/components/CountryPicker/CountrySelectorModal.js b/src/components/CountryPicker/CountrySelectorModal.js index aaf468c63b27..f7315ebb91ba 100644 --- a/src/components/CountryPicker/CountrySelectorModal.js +++ b/src/components/CountryPicker/CountrySelectorModal.js @@ -34,15 +34,15 @@ const defaultProps = { }; function searchOptions(searchValue, data) { - const searchValueWithOnlyAlphabets = searchValue.toLowerCase().replaceAll(CONST.REGEX.NON_ALPHABETIC_AND_NON_LATIN_CHARS, ''); - if (searchValueWithOnlyAlphabets.length === 0) { + const trimmedSearchValue = searchValue.toLowerCase().replaceAll(CONST.REGEX.NON_ALPHABETIC_AND_NON_LATIN_CHARS, ''); + if (trimmedSearchValue.length === 0) { return []; } - const filteredData = _.filter(data, (country) => country.searchValue.includes(searchValueWithOnlyAlphabets)); + const filteredData = _.filter(data, (country) => country.searchValue.includes(trimmedSearchValue)); // sort by country code - return _.sortBy(filteredData, (country) => (country.value.toLowerCase() === searchValueWithOnlyAlphabets ? -1 : 1)); + return _.sortBy(filteredData, (country) => (country.value.toLowerCase() === trimmedSearchValue ? -1 : 1)); } function CountrySelectorModal({currentCountry, isVisible, onClose, onCountrySelected, setSearchValue, searchValue}) { diff --git a/src/components/StatePicker/StateSelectorModal.js b/src/components/StatePicker/StateSelectorModal.js index 3f68b0f42aca..a3c4394907da 100644 --- a/src/components/StatePicker/StateSelectorModal.js +++ b/src/components/StatePicker/StateSelectorModal.js @@ -38,15 +38,15 @@ const defaultProps = { }; function searchOptions(searchValue, data) { - const searchValueWithOnlyAlphabets = searchValue.toLowerCase().replaceAll(CONST.REGEX.NON_ALPHABETIC_AND_NON_LATIN_CHARS, ''); - if (searchValueWithOnlyAlphabets.length === 0) { + const trimmedSearchValue = searchValue.toLowerCase().replaceAll(CONST.REGEX.NON_ALPHABETIC_AND_NON_LATIN_CHARS, ''); + if (trimmedSearchValue.length === 0) { return []; } - const filteredData = _.filter(data, (countryState) => countryState.searchValue.includes(searchValueWithOnlyAlphabets)); + const filteredData = _.filter(data, (countryState) => countryState.searchValue.includes(trimmedSearchValue)); // sort by state code - return _.sortBy(filteredData, (countryState) => (countryState.value.toLowerCase() === searchValueWithOnlyAlphabets ? -1 : 1)); + return _.sortBy(filteredData, (countryState) => (countryState.value.toLowerCase() === trimmedSearchValue ? -1 : 1)); } function StateSelectorModal({currentState, isVisible, onClose, onStateSelected, searchValue, setSearchValue, label}) { From c0d7504b474fa1d783d98fde9f387fd11c8e5637 Mon Sep 17 00:00:00 2001 From: Huzaifa Rasheed Date: Tue, 8 Aug 2023 02:04:56 +0500 Subject: [PATCH 07/10] Moved country/state search options to utils --- .../CountryPicker/CountrySelectorModal.js | 13 +----------- .../StatePicker/StateSelectorModal.js | 13 +----------- src/libs/CountrySelectorUtils/index.js | 21 +++++++++++++++++++ 3 files changed, 23 insertions(+), 24 deletions(-) create mode 100644 src/libs/CountrySelectorUtils/index.js diff --git a/src/components/CountryPicker/CountrySelectorModal.js b/src/components/CountryPicker/CountrySelectorModal.js index f7315ebb91ba..1ed08dadd6c1 100644 --- a/src/components/CountryPicker/CountrySelectorModal.js +++ b/src/components/CountryPicker/CountrySelectorModal.js @@ -6,6 +6,7 @@ import useLocalize from '../../hooks/useLocalize'; import HeaderWithBackButton from '../HeaderWithBackButton'; import SelectionListRadio from '../SelectionListRadio'; import Modal from '../Modal'; +import searchOptions from '../../libs/CountrySelectorUtils'; const propTypes = { /** Whether the modal is visible */ @@ -33,18 +34,6 @@ const defaultProps = { onCountrySelected: () => {}, }; -function searchOptions(searchValue, data) { - const trimmedSearchValue = searchValue.toLowerCase().replaceAll(CONST.REGEX.NON_ALPHABETIC_AND_NON_LATIN_CHARS, ''); - if (trimmedSearchValue.length === 0) { - return []; - } - - const filteredData = _.filter(data, (country) => country.searchValue.includes(trimmedSearchValue)); - - // sort by country code - return _.sortBy(filteredData, (country) => (country.value.toLowerCase() === trimmedSearchValue ? -1 : 1)); -} - function CountrySelectorModal({currentCountry, isVisible, onClose, onCountrySelected, setSearchValue, searchValue}) { const {translate} = useLocalize(); diff --git a/src/components/StatePicker/StateSelectorModal.js b/src/components/StatePicker/StateSelectorModal.js index a3c4394907da..70cf25309c26 100644 --- a/src/components/StatePicker/StateSelectorModal.js +++ b/src/components/StatePicker/StateSelectorModal.js @@ -6,6 +6,7 @@ import Modal from '../Modal'; import HeaderWithBackButton from '../HeaderWithBackButton'; import SelectionListRadio from '../SelectionListRadio'; import useLocalize from '../../hooks/useLocalize'; +import searchOptions from '../../libs/CountrySelectorUtils'; const propTypes = { /** Whether the modal is visible */ @@ -37,18 +38,6 @@ const defaultProps = { label: undefined, }; -function searchOptions(searchValue, data) { - const trimmedSearchValue = searchValue.toLowerCase().replaceAll(CONST.REGEX.NON_ALPHABETIC_AND_NON_LATIN_CHARS, ''); - if (trimmedSearchValue.length === 0) { - return []; - } - - const filteredData = _.filter(data, (countryState) => countryState.searchValue.includes(trimmedSearchValue)); - - // sort by state code - return _.sortBy(filteredData, (countryState) => (countryState.value.toLowerCase() === trimmedSearchValue ? -1 : 1)); -} - function StateSelectorModal({currentState, isVisible, onClose, onStateSelected, searchValue, setSearchValue, label}) { const {translate} = useLocalize(); diff --git a/src/libs/CountrySelectorUtils/index.js b/src/libs/CountrySelectorUtils/index.js new file mode 100644 index 000000000000..5bb3db3eded6 --- /dev/null +++ b/src/libs/CountrySelectorUtils/index.js @@ -0,0 +1,21 @@ +import CONST from '../../CONST'; + +/** + * Searches the countriesData and returns sorted results based on country code + * @param {String} searchValue + * @param {Object} countriesData + * @returns + */ +function searchOptions(searchValue, countriesData) { + const trimmedSearchValue = searchValue.toLowerCase().replaceAll(CONST.REGEX.NON_ALPHABETIC_AND_NON_LATIN_CHARS, ''); + if (trimmedSearchValue.length === 0) { + return []; + } + + const filteredData = _.filter(countriesData, (country) => country.searchValue.includes(trimmedSearchValue)); + + // sort by country code + return _.sortBy(filteredData, (country) => (country.value.toLowerCase() === trimmedSearchValue ? -1 : 1)); +} + +export default searchOptions; From 3873f136675052caf803b86068e09e5d79794e62 Mon Sep 17 00:00:00 2001 From: Huzaifa Rasheed Date: Tue, 8 Aug 2023 02:15:57 +0500 Subject: [PATCH 08/10] Fix lint --- src/libs/CountrySelectorUtils/index.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/libs/CountrySelectorUtils/index.js b/src/libs/CountrySelectorUtils/index.js index 5bb3db3eded6..24852ea384ba 100644 --- a/src/libs/CountrySelectorUtils/index.js +++ b/src/libs/CountrySelectorUtils/index.js @@ -1,10 +1,11 @@ +import _ from 'underscore'; import CONST from '../../CONST'; /** * Searches the countriesData and returns sorted results based on country code * @param {String} searchValue - * @param {Object} countriesData - * @returns + * @param {Object[]} countriesData - An array of country data objects + * @returns {Object[]} An array of sorted country data based on country code */ function searchOptions(searchValue, countriesData) { const trimmedSearchValue = searchValue.toLowerCase().replaceAll(CONST.REGEX.NON_ALPHABETIC_AND_NON_LATIN_CHARS, ''); From 28e5f9ca9df54eacdf662304553d15cac757582e Mon Sep 17 00:00:00 2001 From: Huzaifa Rasheed Date: Tue, 8 Aug 2023 02:32:37 +0500 Subject: [PATCH 09/10] Moved CountrySelectorUtils to searchCountryOptions --- src/components/CountryPicker/CountrySelectorModal.js | 2 +- src/components/StatePicker/StateSelectorModal.js | 2 +- .../index.js => searchCountryOptions.js} | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-) rename src/libs/{CountrySelectorUtils/index.js => searchCountryOptions.js} (65%) diff --git a/src/components/CountryPicker/CountrySelectorModal.js b/src/components/CountryPicker/CountrySelectorModal.js index 1ed08dadd6c1..729507f7b301 100644 --- a/src/components/CountryPicker/CountrySelectorModal.js +++ b/src/components/CountryPicker/CountrySelectorModal.js @@ -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 */ diff --git a/src/components/StatePicker/StateSelectorModal.js b/src/components/StatePicker/StateSelectorModal.js index 70cf25309c26..276ba58f6d7e 100644 --- a/src/components/StatePicker/StateSelectorModal.js +++ b/src/components/StatePicker/StateSelectorModal.js @@ -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 */ diff --git a/src/libs/CountrySelectorUtils/index.js b/src/libs/searchCountryOptions.js similarity index 65% rename from src/libs/CountrySelectorUtils/index.js rename to src/libs/searchCountryOptions.js index 24852ea384ba..84351665111d 100644 --- a/src/libs/CountrySelectorUtils/index.js +++ b/src/libs/searchCountryOptions.js @@ -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 []; @@ -19,4 +19,4 @@ function searchOptions(searchValue, countriesData) { return _.sortBy(filteredData, (country) => (country.value.toLowerCase() === trimmedSearchValue ? -1 : 1)); } -export default searchOptions; +export default searchCountryOptions; From 09f35790a47b073ee7a736d7bd3b2445bbbeb4c7 Mon Sep 17 00:00:00 2001 From: Huzaifa Rasheed Date: Tue, 8 Aug 2023 02:42:41 +0500 Subject: [PATCH 10/10] Updated import name --- src/components/CountryPicker/CountrySelectorModal.js | 4 ++-- src/components/StatePicker/StateSelectorModal.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/CountryPicker/CountrySelectorModal.js b/src/components/CountryPicker/CountrySelectorModal.js index 729507f7b301..b917e771e815 100644 --- a/src/components/CountryPicker/CountrySelectorModal.js +++ b/src/components/CountryPicker/CountrySelectorModal.js @@ -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/searchCountryOptions'; +import searchCountryOptions from '../../libs/searchCountryOptions'; const propTypes = { /** Whether the modal is visible */ @@ -49,7 +49,7 @@ function CountrySelectorModal({currentCountry, isVisible, onClose, onCountrySele [translate, currentCountry], ); - const searchResults = searchOptions(searchValue, countries); + const searchResults = searchCountryOptions(searchValue, countries); const headerMessage = searchValue.trim() && !searchResults.length ? translate('common.noResultsFound') : ''; return ( diff --git a/src/components/StatePicker/StateSelectorModal.js b/src/components/StatePicker/StateSelectorModal.js index 276ba58f6d7e..869c818a7009 100644 --- a/src/components/StatePicker/StateSelectorModal.js +++ b/src/components/StatePicker/StateSelectorModal.js @@ -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/searchCountryOptions'; +import searchCountryOptions from '../../libs/searchCountryOptions'; const propTypes = { /** Whether the modal is visible */ @@ -53,7 +53,7 @@ function StateSelectorModal({currentState, isVisible, onClose, onStateSelected, [translate, currentState], ); - const searchResults = searchOptions(searchValue, countryStates); + const searchResults = searchCountryOptions(searchValue, countryStates); const headerMessage = searchValue.trim() && !searchResults.length ? translate('common.noResultsFound') : ''; return (