Skip to content

Commit

Permalink
Add update data after success cancel (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
SergeYvas authored Oct 12, 2023
1 parent 3ffc75e commit 64eeef2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/hooks/useListDetails.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand All @@ -17,6 +17,7 @@ export const useListDetails = (id: string, queryOptions = {}) => {
},
);
return ({
refetchDetails: refetch,
isLoading,
data,
});
Expand Down
3 changes: 2 additions & 1 deletion src/pages/listInformation/ListInformationPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand Down Expand Up @@ -77,6 +77,7 @@ export const ListInformationPage: React.FC = () => {
})();
},
onCancelSuccess: () => {
refetchDetails();
showSuccessMessage({
message: t('cancel-refresh.success', {
listName
Expand Down

0 comments on commit 64eeef2

Please sign in to comment.