Profile Image edit
This commit is contained in:
@@ -17,7 +17,7 @@ import {
|
||||
Typography,
|
||||
} from '@mui/material';
|
||||
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
||||
import { Link } from '@tanstack/react-router';
|
||||
import { Link, useNavigate } from '@tanstack/react-router';
|
||||
import { FC, useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import Api from '../../api/Api';
|
||||
@@ -42,9 +42,9 @@ const Post: FC<Props> = ({ post }) => {
|
||||
},
|
||||
});
|
||||
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
const { t } = useTranslation();
|
||||
const queryClient = useQueryClient();
|
||||
const navigate = useNavigate();
|
||||
|
||||
return (
|
||||
<Card>
|
||||
@@ -121,10 +121,11 @@ const Post: FC<Props> = ({ post }) => {
|
||||
color="error"
|
||||
onClick={() => {
|
||||
deleteMutation.mutate(post.id, {
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({
|
||||
onSuccess: async (data) => {
|
||||
await queryClient.invalidateQueries({
|
||||
queryKey: ['posts'],
|
||||
});
|
||||
navigate({ to: '/', search: { page: data.pages - 1 } });
|
||||
},
|
||||
onError: setError,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user