update: add queries for submit and change option on assessment
This commit is contained in:
parent
2e9156a30b
commit
b33d99f0d3
|
|
@ -1,8 +1,17 @@
|
|||
import client from "@/honoClient";
|
||||
import fetchRPC from "@/utils/fetchRPC";
|
||||
import { queryOptions } from "@tanstack/react-query";
|
||||
import { queryOptions, useMutation, UseMutationOptions } from "@tanstack/react-query";
|
||||
import { InferRequestType } from "hono";
|
||||
|
||||
type SubmitOptionResponse = {
|
||||
message: string;
|
||||
answer: {
|
||||
id: string;
|
||||
createdAt: string | null;
|
||||
validationInformation: string;
|
||||
};
|
||||
};
|
||||
|
||||
// Query untuk mendapatkan skor assessment saat ini
|
||||
export const getCurrentAssessmentScoreQueryOptions = (assessmentId: string) =>
|
||||
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,
|
||||
});
|
||||
Loading…
Reference in New Issue
Block a user