/* eslint-disable @typescript-eslint/no-explicit-any */
"use serve"
import axiosInstance from "@/lib/constant";
import { VoteOptionInput, UpdateVoteOptionInput, PredictionInput, UpdatePredictionInput } from "./type";
import { AxiosResponse } from "axios";

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


export const geOnePrediction = (predictionId: number) => {
   return axiosInstance.get(`prediction/view?p=${predictionId}`);
}

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


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


export const createVoteOption = async (body: VoteOptionInput): Promise<AxiosResponse<VoteOptionInput, any>> => {
   return await axiosInstance.post<VoteOptionInput>('/vote/add-option', body);
};


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


export const updateVoteOption = async (body: UpdateVoteOptionInput): Promise<AxiosResponse<UpdateVoteOptionInput, any>> => {
   return await axiosInstance.post<UpdateVoteOptionInput>('/vote/update-option', body);
};







