From 6886c93760260716aa6b2da68b11a54f83dbbfa6 Mon Sep 17 00:00:00 2001 From: Carter Date: Thu, 6 Mar 2025 10:33:16 -0600 Subject: [PATCH] using prefix search for team list and user list pages --- src/common/ResponsiveTable.tsx | 1 - src/pages/Users.tsx | 2 +- src/providers/pond/teamAPI.tsx | 7 +++++-- src/providers/pond/userAPI.tsx | 9 ++++++--- src/teams/TeamList.tsx | 3 +-- 5 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/common/ResponsiveTable.tsx b/src/common/ResponsiveTable.tsx index df661ac..8df0851 100644 --- a/src/common/ResponsiveTable.tsx +++ b/src/common/ResponsiveTable.tsx @@ -130,7 +130,6 @@ export default function ResponsiveTable(props: Props) { }); useEffect(() => { - console.log(filterList) localStorage.setItem(filterKey, JSON.stringify(filterList)); }, [filterList]) diff --git a/src/pages/Users.tsx b/src/pages/Users.tsx index f84dc4f..4052cf3 100644 --- a/src/pages/Users.tsx +++ b/src/pages/Users.tsx @@ -134,7 +134,7 @@ export default function Users() { const loadUsers = () => { setIsLoading(true) - userAPI.listUsers(pageSize, page*pageSize, "desc", "name", searchText).then(resp => { + userAPI.listUsers(pageSize, page*pageSize, "desc", "name", undefined, searchText).then(resp => { let r: User[] = [] resp.users.forEach((user, _index) => { r.push(user) diff --git a/src/providers/pond/teamAPI.tsx b/src/providers/pond/teamAPI.tsx index d0b2f1b..5c5695b 100644 --- a/src/providers/pond/teamAPI.tsx +++ b/src/providers/pond/teamAPI.tsx @@ -27,7 +27,8 @@ export interface ITeamAPIContext { orderBy?: string, search?: string, asRoot?: boolean, - as?: string + as?: string, + prefixSearch?: string, ) => Promise>; listAllTeams: () => Promise>; listObjectTeams: (scope: Scope, as?: string) => Promise; @@ -113,7 +114,8 @@ export default function TeamProvider(props: PropsWithChildren) { orderBy?: string, search?: string, asRoot?: boolean, - as?: string + as?: string, + prefixSearch?: string, ) => { //let asText = team ? "&as=" + team.key() : ""; let url = pondURL( @@ -125,6 +127,7 @@ export default function TeamProvider(props: PropsWithChildren) { ("&order=" + or(order, "asc")) + ("&by=" + or(orderBy, "key")) + (search ? "&search=" + search : "") + + (prefixSearch ? "&prefixSearch=" + prefixSearch : "") + (asRoot ? "&asRoot=" + asRoot.toString() : "") + (as ? "&as=" + as : "") ) diff --git a/src/providers/pond/userAPI.tsx b/src/providers/pond/userAPI.tsx index e361b9b..247f77c 100644 --- a/src/providers/pond/userAPI.tsx +++ b/src/providers/pond/userAPI.tsx @@ -24,7 +24,8 @@ export interface IUserAPIContext { offset: number, order?: "asc" | "desc", by?: string, - search?: string + search?: string, + prefixSearch?: string, ) => Promise; listProfiles: () => Promise; listObjectUsers: (scope: Scope) => Promise; @@ -62,7 +63,8 @@ export default function UserProvider(props: PropsWithChildren) { offset: number, order?: "asc" | "desc", by?: string, - search?: string + search?: string, + prefixSearch?: string, ): Promise => { return new Promise((resolve, reject) => { get( @@ -73,7 +75,8 @@ export default function UserProvider(props: PropsWithChildren) { offset + ("&order=" + (order ? order : "asc")) + ("&by=" + (by ? by : "name")) + - (search ? "&search=" + search : "") + (search ? "&search=" + search : "") + + (prefixSearch ? "&prefixSearch=" + prefixSearch : "") ) ) .then((res: any) => { diff --git a/src/teams/TeamList.tsx b/src/teams/TeamList.tsx index 147dc19..886c811 100644 --- a/src/teams/TeamList.tsx +++ b/src/teams/TeamList.tsx @@ -73,9 +73,8 @@ export default function TeamList() { setLoading(true); let newTeamPerms: Map = new Map(); let newTeamPrefs: Map = new Map(); - let searchString = search; teamAPI - .listTeams(limit, limit * page, undefined, "name", searchString, undefined, as) + .listTeams(limit, limit * page, undefined, "name", undefined, undefined, as, search) .then(resp => { setTotal(resp.data.total ? resp.data.total : 0); let newTeams: Team[] = []