update password

This commit is contained in:
archer
2023-07-28 10:33:45 +08:00
parent f65a72821b
commit 7a56680935
15 changed files with 217 additions and 54 deletions

View File

@@ -2,14 +2,16 @@ import { useToast } from '@/hooks/useToast';
import { useMutation } from '@tanstack/react-query';
import type { UseMutationOptions } from '@tanstack/react-query';
import { getErrText } from '@/utils/tools';
import { useTranslation } from 'react-i18next';
interface Props extends UseMutationOptions<any, any, any, any> {
successToast?: string;
errorToast?: string;
successToast?: string | null;
errorToast?: string | null;
}
export const useRequest = ({ successToast, errorToast, onSuccess, onError, ...props }: Props) => {
const { toast } = useToast();
const { t } = useTranslation();
const mutation = useMutation<unknown, unknown, any, unknown>({
...props,
onSuccess(res, variables: void, context: unknown) {
@@ -24,7 +26,7 @@ export const useRequest = ({ successToast, errorToast, onSuccess, onError, ...pr
onError?.(err, variables, context);
errorToast &&
toast({
title: getErrText(err, errorToast),
title: t(getErrText(err, errorToast)),
status: 'error'
});
}