Pull Request branch dev-clone to main #1

Merged
gitea merged 429 commits from dev-clone into main 2024-12-23 09:31:34 +00:00
2 changed files with 19 additions and 9 deletions
Showing only changes of commit a0707d67a9 - Show all commits

View File

@ -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: {

View File

@ -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,