diff --git a/src/Utils/request/useMutation.ts b/src/Utils/request/useMutation.ts deleted file mode 100644 index cff4919a6bd..00000000000 --- a/src/Utils/request/useMutation.ts +++ /dev/null @@ -1,50 +0,0 @@ -import React from "react"; - -import request from "@/Utils/request/request"; -import { - MutationRoute, - RequestOptions, - RequestResult, -} from "@/Utils/request/types"; -import { mergeRequestOptions } from "@/Utils/request/utils"; - -/** - * @deprecated use `useMutation` from `@tanstack/react-query` instead. - */ -export default function useDeprecatedMutation( - route: MutationRoute, - options: RequestOptions, -) { - const [response, setResponse] = React.useState>(); - const [isProcessing, setIsProcessing] = React.useState(false); - - const controllerRef = React.useRef(); - - const runQuery = React.useCallback( - async (overrides?: RequestOptions) => { - controllerRef.current?.abort(); - - const controller = new AbortController(); - controllerRef.current = controller; - - const resolvedOptions = - options && overrides - ? mergeRequestOptions(options, overrides) - : (overrides ?? options); - - setIsProcessing(true); - const response = await request(route, { - ...resolvedOptions, - signal: controller.signal, - }); - if (response.error?.name !== "AbortError") { - setResponse(response); - setIsProcessing(false); - } - return response; - }, - [route, JSON.stringify(options)], - ); - - return { ...response, isProcessing, mutate: runQuery }; -} diff --git a/src/components/Questionnaire/QuestionnaireForm.tsx b/src/components/Questionnaire/QuestionnaireForm.tsx index fab86814679..e58617b281e 100644 --- a/src/components/Questionnaire/QuestionnaireForm.tsx +++ b/src/components/Questionnaire/QuestionnaireForm.tsx @@ -14,7 +14,6 @@ import Loading from "@/components/Common/Loading"; import routes from "@/Utils/request/api"; import mutate from "@/Utils/request/mutate"; -import { HTTPError } from "@/Utils/request/types"; import useQuery from "@/Utils/request/useQuery"; import { DetailedValidationError, @@ -85,7 +84,7 @@ export function QuestionnaireForm({ toast.success(t("questionnaire_submitted_successfully")); onSubmit?.(); }, - onError: (error: HTTPError) => { + onError: (error) => { const errorData = error.cause; if (errorData?.results) { handleSubmissionError(errorData.results as ValidationErrorResponse[]);