Skip to content

Commit

Permalink
fix: delete post success banner and redirect
Browse files Browse the repository at this point in the history
  • Loading branch information
blushi committed Sep 11, 2024
1 parent 92cbad8 commit cca8177
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions web-marketplace/src/pages/Post/Post.Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export const PostHeader = ({
const { deletePost, open, onClose, onOpen } = useDelete({
iri,
projectHref,
offChainProjectId,
});

return (
Expand Down
5 changes: 4 additions & 1 deletion web-marketplace/src/pages/Post/hooks/useDelete.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useCallback, useState } from 'react';
import { useNavigate } from 'react-router-dom';
import { useLingui } from '@lingui/react';
import { useQuery, useQueryClient } from '@tanstack/react-query';
import { useSetAtom } from 'jotai';
import { postData } from 'utils/fetch/postData';
Expand All @@ -21,6 +22,7 @@ type Params = {
};

export const useDelete = ({ iri, offChainProjectId, projectHref }: Params) => {
const { _ } = useLingui();
const retryCsrfRequest = useRetryCsrfRequest();
const { data: token } = useQuery(getCsrfTokenQuery({}));
const setErrorBannerTextAtom = useSetAtom(errorBannerTextAtom);
Expand All @@ -45,7 +47,7 @@ export const useDelete = ({ iri, offChainProjectId, projectHref }: Params) => {
token,
parseTextResponse: true,
retryCsrfRequest,
onSuccess: async _ => {
onSuccess: async () => {
if (offChainProjectId) {
await reactQueryClient.invalidateQueries({
queryKey: getPostsQueryKey({ projectId: offChainProjectId }),
Expand All @@ -68,6 +70,7 @@ export const useDelete = ({ iri, offChainProjectId, projectHref }: Params) => {
}
}
}, [
_,
iri,
navigate,
offChainProjectId,
Expand Down

0 comments on commit cca8177

Please sign in to comment.