From 0ab74755d6ccebf6f2d69d3b4e79e0faef6e6d84 Mon Sep 17 00:00:00 2001 From: Lanskikh Date: Wed, 18 Jun 2025 18:31:18 +0500 Subject: [PATCH] fix client page --- src/pages/ClientsPage.tsx | 43 +++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/src/pages/ClientsPage.tsx b/src/pages/ClientsPage.tsx index 8f3c980..4f2af8d 100644 --- a/src/pages/ClientsPage.tsx +++ b/src/pages/ClientsPage.tsx @@ -1,3 +1,4 @@ +import api from "../utils/api"; import Button from "../components/Button"; import CloseIcon from "../components/icons/CloseIcon"; import SpinIcon from "../components/icons/SpinIcon"; @@ -6,8 +7,8 @@ import SearchInput from "../components/SearchInput"; import { useState } from "react"; import { useDebounce } from "@uidotdev/usehooks"; import { useQuery } from "@tanstack/react-query"; -import api from "../utils/api"; import { User } from "../types/User"; +import { Client } from "../types/Client"; function ClientsPage() { const [limit, setLimit] = useState(10); @@ -21,14 +22,26 @@ function ClientsPage() { }); const { data: clients, isLoading } = useQuery({ - queryKey: ["clients"], - queryFn: () => api.get("clients").json(), + queryKey: ["clients", debouncedSearch], + queryFn: () => + api + .get("clients", { + searchParams: debouncedSearch + ? { search: debouncedSearch, limit } + : {}, + }) + .json(), enabled: !!me, }); const { data: count } = useQuery({ queryKey: ["clients", "count", debouncedSearch], - queryFn: () => api.get(`sessions/count?clients`).json(), + queryFn: () => + api + .get(`clients/count`, { + searchParams: debouncedSearch ? { search: debouncedSearch } : {}, + }) + .json(), enabled: !!me, }); @@ -37,11 +50,11 @@ function ClientsPage() { } return ( -
+

Клиенты

-
+
) : clients?.length ? ( - clients?.map(({ fullname }) => ( -
-

{fullname}

+ clients?.map(({ name }) => ( +
+

{name}

)) ) : (