import { useMutation, useQueryClient } from "@tanstack/react-query"; import { toast } from "react-toastify"; import { useTranslation } from "react-i18next"; import { getMillis } from "taehui-ts/date"; import { isClientFault, wwwAXIOS } from "src/Www"; export default function useWipeComment() { const queryClient = useQueryClient(); const { t } = useTranslation(); return useMutation({ mutationFn: async ({ commentID, totem, }: { commentID: number; totem: string; }) => { await wwwAXIOS.delete(`/comment/${commentID}`, { headers: { millis: getMillis(), totem, }, }); }, onSuccess: async () => { await queryClient.invalidateQueries({ queryKey: ["comment"] }); }, onError: (e) => { if (isClientFault(e)) { toast.error(t("failedValidateCipher")); } }, }); }