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

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


export const geOnePost = (postId: number) => {
   return axiosInstance.get(`post/view?p=${postId}`);
}

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


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


