Fixed search box functionality
This commit is contained in:
@@ -11,7 +11,7 @@ export function useGetAccounts(page: number, pageSize: number, searchTerm?: stri
|
||||
params.append("page", page.toString());
|
||||
params.append("pageSize", pageSize.toString());
|
||||
if(searchTerm){
|
||||
params.append("search", searchTerm ?? "");
|
||||
params.append("searchTerm", searchTerm ?? "");
|
||||
}
|
||||
|
||||
const response = await api.get(`/account?${params}`);
|
||||
@@ -28,11 +28,18 @@ export function useGetAccounts(page: number, pageSize: number, searchTerm?: stri
|
||||
});
|
||||
}
|
||||
|
||||
export function useGetAccountsCount(){
|
||||
export function useGetAccountsCount(searchTerm?: string){
|
||||
const searchParams = new URLSearchParams();
|
||||
if(searchTerm){
|
||||
searchParams.append("searchTerm", searchTerm);
|
||||
}
|
||||
|
||||
|
||||
return useQuery({
|
||||
queryKey: [ "accounts", "count"],
|
||||
queryKey: [ "accounts", "count", searchTerm],
|
||||
queryFn: async () => {
|
||||
const response = await api.get("/account/count");
|
||||
|
||||
const response = await api.get(`/account/count?${searchParams}`);
|
||||
|
||||
if(response.status !== 200){
|
||||
throw new Error("Failed to get accounts count");
|
||||
|
||||
@@ -11,7 +11,7 @@ export function useGetGames(page: number, pageSize: number, searchTerm?: string)
|
||||
params.append("page", page.toString());
|
||||
params.append("pageSize", pageSize.toString());
|
||||
if(searchTerm){
|
||||
params.append("search", searchTerm);
|
||||
params.append("searchTerm", searchTerm);
|
||||
}
|
||||
|
||||
const response = await api.get(`/game?${params}`);
|
||||
@@ -28,11 +28,17 @@ export function useGetGames(page: number, pageSize: number, searchTerm?: string)
|
||||
});
|
||||
}
|
||||
|
||||
export function useGetGamesCount(){
|
||||
export function useGetGamesCount(searchTerm?: string){
|
||||
const searchParams = new URLSearchParams();
|
||||
if(searchTerm){
|
||||
searchParams.append("searchTerm", searchTerm);
|
||||
}
|
||||
|
||||
|
||||
return useQuery({
|
||||
queryKey: ["games", "count"],
|
||||
queryKey: ["games", "count", searchTerm],
|
||||
queryFn: async () => {
|
||||
const response = await api.get("/game/count");
|
||||
const response = await api.get(`/game/count?${searchParams}`);
|
||||
|
||||
if(response.status !== 200){
|
||||
throw new Error("Failed to get games count");
|
||||
|
||||
Reference in New Issue
Block a user