Skip to content

Commit

Permalink
updated view for facility users
Browse files Browse the repository at this point in the history
  • Loading branch information
Mahendar0701 committed Dec 30, 2024
1 parent d7f0669 commit 91765fd
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/components/Facility/FacilityUsers.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { useState } from "react";
import { useTranslation } from "react-i18next";

import CountBlock from "@/CAREUI/display/Count";
Expand All @@ -10,14 +9,15 @@ import useFilters from "@/hooks/useFilters";

import routes from "@/Utils/request/api";
import useTanStackQueryInstead from "@/Utils/request/useQuery";
import { useView } from "@/Utils/useView";

export default function FacilityUsers(props: { facilityId: number }) {
const { t } = useTranslation();
const { qParams, updateQuery, Pagination, resultsPerPage } = useFilters({
limit: 18,
cacheBlacklist: ["username"],
});
const [activeTab, setActiveTab] = useState(0);
const [activeTab, setActiveTab] = useView("users");
const { facilityId } = props;

const { data: facilityData } = useTanStackQueryInstead(
Expand All @@ -43,6 +43,10 @@ export default function FacilityUsers(props: { facilityId: number }) {
prefetch: facilityId !== undefined,
});

const handleTabChange = (tab: number) => {
setActiveTab(tab === 1 ? "list" : "card");
};

return (
<Page
title={`${t("users")} - ${facilityData?.name}`}
Expand All @@ -61,8 +65,8 @@ export default function FacilityUsers(props: { facilityId: number }) {
users={userListData?.results ?? []}
onSearch={(username) => updateQuery({ username })}
searchValue={qParams.username}
activeTab={activeTab}
onTabChange={setActiveTab}
activeTab={activeTab === "list" ? 1 : 0}
onTabChange={handleTabChange}
/>

<Pagination totalCount={userListData?.count ?? 0} />
Expand Down

0 comments on commit 91765fd

Please sign in to comment.