Skip to content

Commit

Permalink
Fix submit button not disabled after submitting
Browse files Browse the repository at this point in the history
  • Loading branch information
olimsaidov committed Nov 25, 2024
1 parent 98683c6 commit be9c922
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion aidbox-forms-smart-launch/src/pages/questionnaire-response.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { useParams } from "react-router-dom";
import { useClient } from "@/hooks/use-client.jsx";
import { useMutation, useSuspenseQuery } from "@tanstack/react-query";
import {
useMutation,
useQueryClient,
useSuspenseQuery,
} from "@tanstack/react-query";
import { useAwaiter } from "@/hooks/use-awaiter.jsx";
import { useEffect, useRef } from "react";
import { findQuestionnaire, saveQuestionnaireResponse } from "@/lib/utils.js";
Expand All @@ -9,6 +13,7 @@ export const QuestionnaireResponse = () => {
const ref = useRef();
const { id } = useParams();
const client = useClient();
const queryClient = useQueryClient();

const { data: questionnaireResponse } = useSuspenseQuery({
queryKey: ["questionnaire-response", id],
Expand All @@ -24,6 +29,9 @@ export const QuestionnaireResponse = () => {

const mutation = useMutation({
mutationFn: saveQuestionnaireResponse.bind(null, client, questionnaire),
onSuccess: (qr) => {
queryClient.setQueryData(["questionnaire-response", id], qr);
},
});

useEffect(() => {
Expand Down

0 comments on commit be9c922

Please sign in to comment.