diff --git a/src/components/Facility/FacilityUsers.tsx b/src/components/Facility/FacilityUsers.tsx index a4af2733d83..fb351a0e603 100644 --- a/src/components/Facility/FacilityUsers.tsx +++ b/src/components/Facility/FacilityUsers.tsx @@ -12,44 +12,47 @@ import UserListView from "@/components/Users/UserListAndCard"; import useFilters from "@/hooks/useFilters"; +import { RESULTS_PER_PAGE_LIMIT } from "@/common/constants"; + import routes from "@/Utils/request/api"; import query from "@/Utils/request/query"; export default function FacilityUsers(props: { facilityId: number }) { const { t } = useTranslation(); const { qParams, updateQuery, Pagination } = useFilters({ - limit: 18, + limit: RESULTS_PER_PAGE_LIMIT, cacheBlacklist: ["username"], }); const [activeTab, setActiveTab] = useState(0); const { facilityId } = props; const { data: userListData, isLoading: userListLoading } = useQuery({ - queryKey: ["facilityUsers", facilityId], + queryKey: ["facilityUsers", facilityId, qParams], queryFn: query(routes.facility.getUsers, { pathParams: { facility_id: facilityId }, + queryParams: { + username: qParams.username, + limit: qParams.limit, + offset: (qParams.page - 1) * qParams.limit, + }, }), enabled: !!facilityId, }); - if (userListLoading) { - return ( -
- -
- -
- - -
-
-
- -
- - -
-
+ if (!userListData) { + return
{t("no_users_found")}
; + } + + return ( + + + {userListLoading ? (
{Array.from({ length: 6 }).map((_, i) => ( @@ -64,41 +67,21 @@ export default function FacilityUsers(props: { facilityId: number }) {
-
- - -
))} - - ); - } - if (!userListData) { - return
{t("no_users_found")}
; - } - - return ( - - - - updateQuery({ username })} - searchValue={qParams.username} - activeTab={activeTab} - onTabChange={setActiveTab} - /> - + ) : ( + updateQuery({ username })} + searchValue={qParams.username} + activeTab={activeTab} + onTabChange={setActiveTab} + /> + )} );