Skip to content

Commit

Permalink
scaffolding for typeahead query
Browse files Browse the repository at this point in the history
  • Loading branch information
SeongHo Park committed Jul 25, 2024
1 parent c28b3c1 commit c2e272b
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions frontend/src/lib/gql/typeahead-queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,43 @@ export async function _userTypeaheadSearch(userSearch: string, limit = 10): Prom

return users;
}

// export function orgMemberFilter(userSearch: string): OrgMemberFilterInput {
// return {
// or: [
// {name: {icontains: userSearch}},
// {email: {icontains: userSearch}},
// {username: {icontains: userSearch}}
// ]
// };
// }

// export async function _orgMemberTypeaheadSearch(orgMemberSearch: string, limit = 10): Promise<OrgMemberTypeaheadResult> {
// if (!orgMemberSearch) return Promise.resolve([]);
// const client = getClient();
// const result = client.query(graphql(`
// query loadOrgMembersTypeahead($filter: UserFilterInput, $take: Int!) {
// usersInMyOrgs(where: $filter, orderBy: {name: ASC}, take: $take) {
// user {
// id
// name
// email
// username
// }
// }
// }
// `), { filter: orgMemberFilter(orgMemberSearch), take: limit });

// const users = result.then(members => {
// // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
// const count = members.data?.members.length ?? 0;
// if (0 < count && count <= limit) {
// // eslint-disable-next-line @typescript-eslint/no-unsafe-return
// return members.data?.members?.user ?? [];
// } else {
// return [];
// }
// });

// return users;
// }

0 comments on commit c2e272b

Please sign in to comment.