/* eslint-disable @typescript-eslint/no-explicit-any */
"use serve"
import axiosInstance from "@/lib/constant";
import { QuizInput, QuizQuestionInput, QuizQuestionOptionInput, UpdateQuizInput, UpdateQuizQuestionInput, UpdateQuizQuestionOptionInput } from "./type";
import { AxiosResponse } from "axios";

export const getQuizes = () => {
   return axiosInstance.get(`quiz/all`);
}


export const geOneQuiz = (quizId: number) => {
   return axiosInstance.get(`quiz/view?q=${quizId}`);
}

export const createQuiz = async (body: QuizInput): Promise<AxiosResponse<QuizInput, any>> => {
   return await axiosInstance.post<QuizInput>('/quiz/add', body);
};


export const updateQuiz = async (body: UpdateQuizInput): Promise<AxiosResponse<UpdateQuizInput, any>> => {
   return await axiosInstance.post<UpdateQuizInput>('/quiz/update', body);
};


export const createQuizQuestion = async (body: QuizQuestionInput): Promise<AxiosResponse<QuizQuestionInput, any>> => {
   return await axiosInstance.post<QuizQuestionInput>('/quiz/add-question', body);
};


export const geOneQuizQuestion = (questionId: number) => {
   return axiosInstance.get(`quiz/view-question?qs=${questionId}`);
}


export const updateQuizQuestion = async (body: UpdateQuizQuestionInput): Promise<AxiosResponse<UpdateQuizQuestionInput, any>> => {
   return await axiosInstance.post<UpdateQuizQuestionInput>('/quiz/update-question', body);
};


export const addQuestionOption = async (body: QuizQuestionOptionInput): Promise<AxiosResponse<QuizQuestionOptionInput, any>> => {
   return await axiosInstance.post<QuizQuestionOptionInput>('/quiz/add-question-option', body);
};


export const geOneQuizQuestionOption = (optionId: number) => {
   return axiosInstance.get(`quiz/view-question-option?o=${optionId}`);
}


export const updateQuestionOption = async (body: UpdateQuizQuestionOptionInput): Promise<AxiosResponse<UpdateQuizQuestionOptionInput, any>> => {
   return await axiosInstance.post<UpdateQuizQuestionOptionInput>('/quiz/update-question-option', body);
};





