good enough search working...cheaper than algolia and time saver...move on
This commit is contained in:
@@ -42,7 +42,10 @@ const Conversations = () => {
|
||||
if (searchVal) {
|
||||
enqueueSnackbar('searching...', { variant: 'info' });
|
||||
|
||||
setSearchUsersResults(await searchUsers(searchVal));
|
||||
const results = await searchUsers(searchVal);
|
||||
setSearchUsersResults(results);
|
||||
|
||||
console.warn(results);
|
||||
}
|
||||
},
|
||||
500,
|
||||
@@ -180,8 +183,7 @@ function ListPeople({ people }: { people: User[] }) {
|
||||
}}
|
||||
subheader={
|
||||
<ListSubheader>
|
||||
<FiActivity />
|
||||
<Typography variant="subtitle2"> Priority</Typography>
|
||||
<Typography variant="subtitle2"> Search Results</Typography>
|
||||
</ListSubheader>
|
||||
}
|
||||
>
|
||||
|
||||
@@ -12,6 +12,10 @@ import {
|
||||
query,
|
||||
where,
|
||||
getDocs,
|
||||
orderBy,
|
||||
limit,
|
||||
startAt,
|
||||
endAt,
|
||||
} from 'firebase/firestore';
|
||||
|
||||
import { User as FirebaseUser } from 'firebase/auth';
|
||||
@@ -79,14 +83,18 @@ export const searchUsers = async (searchQuery: string): Promise<User[] | undefin
|
||||
try {
|
||||
const emaildocSearchQuery = query(
|
||||
db.users,
|
||||
where('email', '>=', searchQuery.toUpperCase()),
|
||||
where('email', '<=', searchQuery.toUpperCase() + '\uf8ff'),
|
||||
orderBy('email'),
|
||||
startAt(searchQuery),
|
||||
endAt(searchQuery + '\uf8ff'),
|
||||
limit(5),
|
||||
);
|
||||
|
||||
const nameSearchQuery = query(
|
||||
db.users,
|
||||
where('displayName', '>=', searchQuery.toUpperCase()),
|
||||
where('displayName', '<=', searchQuery.toUpperCase() + '\uf8ff'),
|
||||
orderBy('displayName'),
|
||||
startAt(searchQuery),
|
||||
endAt(searchQuery + '\uf8ff'),
|
||||
limit(5),
|
||||
);
|
||||
|
||||
const emailquerySnap = await getDocs(emaildocSearchQuery);
|
||||
|
||||
Reference in New Issue
Block a user