mirror of
https://github.com/lingble/chatwoot.git
synced 2025-11-03 12:37:56 +00:00
feat: Optimize contact search keys
This commit is contained in:
@@ -148,10 +148,21 @@ const isAnyDropdownActive = computed(() => {
|
|||||||
|
|
||||||
const handleContactSearch = value => {
|
const handleContactSearch = value => {
|
||||||
showContactsDropdown.value = true;
|
showContactsDropdown.value = true;
|
||||||
emit('searchContacts', {
|
const query = typeof value === 'string' ? value.trim() : '';
|
||||||
keys: ['email', 'phone_number', 'name'],
|
const hasAlphabet = Array.from(query).some(char => {
|
||||||
query: value,
|
const lower = char.toLowerCase();
|
||||||
|
const upper = char.toUpperCase();
|
||||||
|
return lower !== upper;
|
||||||
});
|
});
|
||||||
|
const isEmailLike = /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(query);
|
||||||
|
|
||||||
|
const keys = ['email', 'phone_number', 'name'].filter(key => {
|
||||||
|
if (key === 'phone_number' && hasAlphabet) return false;
|
||||||
|
if (key === 'name' && isEmailLike) return false;
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
|
||||||
|
emit('searchContacts', { keys, query: value });
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleDropdownUpdate = (type, value) => {
|
const handleDropdownUpdate = (type, value) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user