Skip to content

Commit

Permalink
Merge pull request #34083 from dukenv0307/fix/34020
Browse files Browse the repository at this point in the history
Replace all spaces before compare with search text in workspace invite
  • Loading branch information
thienlnam authored Jan 11, 2024
2 parents da359c3 + 52a052a commit 7517d74
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
8 changes: 6 additions & 2 deletions src/pages/RoomInvitePage.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import {parsePhoneNumber} from 'awesome-phonenumber';

Check failure on line 1 in src/pages/RoomInvitePage.js

View workflow job for this annotation

GitHub Actions / lint / lint

'parsePhoneNumber' import from 'awesome-phonenumber' is restricted. Please use '@libs/PhoneNumber' instead
import Str from 'expensify-common/lib/str';
import lodashGet from 'lodash/get';
import PropTypes from 'prop-types';
import React, {useCallback, useEffect, useMemo, useState} from 'react';
Expand All @@ -13,6 +15,7 @@ import useLocalize from '@hooks/useLocalize';
import useThemeStyles from '@hooks/useThemeStyles';
import compose from '@libs/compose';
import * as DeviceCapabilities from '@libs/DeviceCapabilities';
import * as LoginUtils from '@libs/LoginUtils';
import Navigation from '@libs/Navigation/Navigation';
import * as OptionsListUtils from '@libs/OptionsListUtils';
import * as PersonalDetailsUtils from '@libs/PersonalDetailsUtils';
Expand Down Expand Up @@ -102,8 +105,9 @@ function RoomInvitePage(props) {
filterSelectedOptions = _.filter(selectedOptions, (option) => {
const accountID = lodashGet(option, 'accountID', null);
const isOptionInPersonalDetails = _.some(personalDetails, (personalDetail) => personalDetail.accountID === accountID);

const isPartOfSearchTerm = option.text.toLowerCase().includes(searchTerm.trim().toLowerCase());
const parsedPhoneNumber = parsePhoneNumber(LoginUtils.appendCountryCode(Str.removeSMSDomain(searchTerm)));
const searchValue = parsedPhoneNumber.possible ? parsedPhoneNumber.number.e164 : searchTerm.toLowerCase();
const isPartOfSearchTerm = option.text.toLowerCase().includes(searchValue) || option.login.toLowerCase().includes(searchValue);
return isPartOfSearchTerm || isOptionInPersonalDetails;
});
}
Expand Down
7 changes: 6 additions & 1 deletion src/pages/workspace/WorkspaceInvitePage.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import {parsePhoneNumber} from 'awesome-phonenumber';

Check failure on line 1 in src/pages/workspace/WorkspaceInvitePage.js

View workflow job for this annotation

GitHub Actions / lint / lint

'parsePhoneNumber' import from 'awesome-phonenumber' is restricted. Please use '@libs/PhoneNumber' instead
import Str from 'expensify-common/lib/str';
import lodashGet from 'lodash/get';
import PropTypes from 'prop-types';
import React, {useEffect, useMemo, useState} from 'react';
Expand All @@ -14,6 +16,7 @@ import useNetwork from '@hooks/useNetwork';
import useThemeStyles from '@hooks/useThemeStyles';
import compose from '@libs/compose';
import * as DeviceCapabilities from '@libs/DeviceCapabilities';
import * as LoginUtils from '@libs/LoginUtils';
import Navigation from '@libs/Navigation/Navigation';
import * as OptionsListUtils from '@libs/OptionsListUtils';
import * as PolicyUtils from '@libs/PolicyUtils';
Expand Down Expand Up @@ -141,8 +144,10 @@ function WorkspaceInvitePage(props) {
filterSelectedOptions = _.filter(selectedOptions, (option) => {
const accountID = lodashGet(option, 'accountID', null);
const isOptionInPersonalDetails = _.some(personalDetails, (personalDetail) => personalDetail.accountID === accountID);
const parsedPhoneNumber = parsePhoneNumber(LoginUtils.appendCountryCode(Str.removeSMSDomain(searchTerm)));
const searchValue = parsedPhoneNumber.possible ? parsedPhoneNumber.number.e164 : searchTerm.toLowerCase();

const isPartOfSearchTerm = option.text.toLowerCase().includes(searchTerm.trim().toLowerCase());
const isPartOfSearchTerm = option.text.toLowerCase().includes(searchValue) || option.login.toLowerCase().includes(searchValue);
return isPartOfSearchTerm || isOptionInPersonalDetails;
});
}
Expand Down

0 comments on commit 7517d74

Please sign in to comment.