From 64eeef2a05c8fc5513e2b343383882207c53a9cb Mon Sep 17 00:00:00 2001 From: Vasilev Sergey Date: Fri, 13 Oct 2023 00:10:48 +0400 Subject: [PATCH] Add update data after success cancel (#43) --- src/hooks/useListDetails.ts | 3 ++- src/pages/listInformation/ListInformationPage.tsx | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/hooks/useListDetails.ts b/src/hooks/useListDetails.ts index dc8a29db..32ca386b 100644 --- a/src/hooks/useListDetails.ts +++ b/src/hooks/useListDetails.ts @@ -4,7 +4,7 @@ import { ListsRecordDetails } from '../interfaces'; export const useListDetails = (id: string, queryOptions = {}) => { const ky = useOkapiKy(); - const { data, isLoading } = useQuery( + const { data, isLoading, refetch } = useQuery( { queryKey: ['listDetails', id], queryFn: async () => { @@ -17,6 +17,7 @@ export const useListDetails = (id: string, queryOptions = {}) => { }, ); return ({ + refetchDetails: refetch, isLoading, data, }); diff --git a/src/pages/listInformation/ListInformationPage.tsx b/src/pages/listInformation/ListInformationPage.tsx index 9eb1479e..b8c31dff 100644 --- a/src/pages/listInformation/ListInformationPage.tsx +++ b/src/pages/listInformation/ListInformationPage.tsx @@ -33,7 +33,7 @@ export const ListInformationPage: React.FC = () => { const { formatNumber } = useIntl(); const { id }: {id: string} = useParams(); - const { data: listData, isLoading: isDetailsLoading } = useListDetails(id); + const { data: listData, isLoading: isDetailsLoading, refetchDetails } = useListDetails(id); const { name: listName = '' } = listData ?? {}; const [refreshTrigger, setRefreshTrigger] = useState(uniqueId()); @@ -77,6 +77,7 @@ export const ListInformationPage: React.FC = () => { })(); }, onCancelSuccess: () => { + refetchDetails(); showSuccessMessage({ message: t('cancel-refresh.success', { listName