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

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


export const geOneVote = (voteId: number) => {
   return axiosInstance.get(`vote/view?v=${voteId}`);
}

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


export const updateVote = async (body: UpdateVoteInput): Promise<AxiosResponse<UpdateVoteInput, any>> => {
   return await axiosInstance.post<UpdateVoteInput>('/vote/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);
};







