Skip to content

Commit

Permalink
use refetch instead of a key
Browse files Browse the repository at this point in the history
  • Loading branch information
khavinshankar committed May 20, 2024
1 parent 074d9f6 commit df053ef
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/Components/ABDM/ABDMFacilityRecords.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import Loading from "../Common/Loading";
import Page from "../Common/components/Page";
import CareIcon from "../../CAREUI/icons/CareIcon";
import ButtonV2 from "../Common/components/ButtonV2";
import { useState } from "react";

interface IProps {
facilityId: string;
Expand All @@ -24,10 +23,12 @@ const TableHeads = [
];

export default function ABDMFacilityRecords({ facilityId }: IProps) {
const [key, setKey] = useState(0);
const { data: consentsResult, loading } = useQuery(routes.abha.listConsents, {
const {
data: consentsResult,
loading,
refetch,
} = useQuery(routes.abha.listConsents, {
query: { facility: facilityId, ordering: "-created_date" },
key: key.toString(),
});

if (loading) {
Expand Down Expand Up @@ -59,9 +60,7 @@ export default function ABDMFacilityRecords({ facilityId }: IProps) {
className="sticky right-0 top-0 py-3.5 pl-3 pr-4 sm:pr-6"
>
<ButtonV2
onClick={async () => {
setKey((prev) => prev + 1);
}}
onClick={() => refetch()}
ghost
className="max-w-2xl text-sm text-gray-700 hover:text-gray-900"
>
Expand Down

0 comments on commit df053ef

Please sign in to comment.