import { useMutation } from "@tanstack/react-query"; import { useTranslation } from "react-i18next"; import { toast } from "react-toastify"; import { getMillis } from "taehui-ts/date"; import { sprintf } from "sprintf-js"; import { wwwAXIOS } from "src/Www"; import { useAvatarStore } from "src/Stores"; export default function useWipeTotem() { const { taehuiAvatarName, setSession, saveTotem } = useAvatarStore(); const { t } = useTranslation(); return useMutation({ mutationFn: async ({ totem }: { totem: string }) => { const { data } = await wwwAXIOS.delete("/avatar/totem", { headers: { millis: getMillis(), totem, }, }); return data; }, onSuccess: async () => { toast.success(sprintf(t("notSignedInText"), taehuiAvatarName)); setSession({ totem: "", avatarID: "", avatarName: "'", level: 0, fax: "", avatarIntro: "", }); saveTotem(); }, }); }