Pull Request branch dev-clone to main #1
|
|
@ -94,13 +94,13 @@ export const submitOption = async (form: {
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const submitOptionMutationOptions: () => UseMutationOptions<
|
export const submitOptionMutationOptions: UseMutationOptions<
|
||||||
SubmitOptionResponse,
|
SubmitOptionResponse,
|
||||||
Error,
|
Error,
|
||||||
Parameters<typeof submitOption>[0]
|
Parameters<typeof submitOption>[0]
|
||||||
> = () => ({
|
> = {
|
||||||
mutationFn: submitOption,
|
mutationFn: submitOption,
|
||||||
});
|
};
|
||||||
|
|
||||||
export const submitValidation = async (
|
export const submitValidation = async (
|
||||||
form: {
|
form: {
|
||||||
|
|
|
||||||
|
|
@ -180,8 +180,17 @@ export default function AssessmentPage() {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
// Mutation function to submit answer
|
// Usage of the mutation in your component
|
||||||
const submitOptionMutation = useMutation(submitOptionMutationOptions());
|
const submitOptionMutation = useMutation({
|
||||||
|
...submitOptionMutationOptions, // Spread the mutation options here
|
||||||
|
onSuccess: () => {
|
||||||
|
// Refetch the average scores after a successful submission
|
||||||
|
averageScoreQuery.refetch();
|
||||||
|
},
|
||||||
|
onError: (error) => {
|
||||||
|
console.error("Error submitting option:", error);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const assessmentId = getQueryParam("id");
|
const assessmentId = getQueryParam("id");
|
||||||
|
|
@ -213,6 +222,7 @@ export default function AssessmentPage() {
|
||||||
// Update state
|
// Update state
|
||||||
setAnswers(updatedAnswers);
|
setAnswers(updatedAnswers);
|
||||||
|
|
||||||
|
// Call the mutation to submit the option
|
||||||
submitOptionMutation.mutate({
|
submitOptionMutation.mutate({
|
||||||
optionId,
|
optionId,
|
||||||
assessmentId,
|
assessmentId,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user