update: add queries for submit and change option on assessment

This commit is contained in:
abiyasa05 2024-10-17 13:28:59 +07:00
parent 2e9156a30b
commit b33d99f0d3

View File

@ -1,8 +1,17 @@
import client from "@/honoClient"; import client from "@/honoClient";
import fetchRPC from "@/utils/fetchRPC"; import fetchRPC from "@/utils/fetchRPC";
import { queryOptions } from "@tanstack/react-query"; import { queryOptions, useMutation, UseMutationOptions } from "@tanstack/react-query";
import { InferRequestType } from "hono"; import { InferRequestType } from "hono";
type SubmitOptionResponse = {
message: string;
answer: {
id: string;
createdAt: string | null;
validationInformation: string;
};
};
// Query untuk mendapatkan skor assessment saat ini // Query untuk mendapatkan skor assessment saat ini
export const getCurrentAssessmentScoreQueryOptions = (assessmentId: string) => export const getCurrentAssessmentScoreQueryOptions = (assessmentId: string) =>
queryOptions({ queryOptions({
@ -118,3 +127,25 @@ export const getAverageScoreSubAspectQueryOptions = (assessmentId: string) =>
}) })
), ),
}); });
export const submitOption = async (form: {
optionId: string;
assessmentId: string;
questionId: string;
isFlagged?: boolean;
filename?: string;
}): Promise<SubmitOptionResponse> => {
return await fetchRPC(
client.assessments.submitOption.$post({
json: form,
})
);
};
export const submitOptionMutationOptions: () => UseMutationOptions<
SubmitOptionResponse,
Error,
Parameters<typeof submitOption>[0]
> = () => ({
mutationFn: submitOption,
});