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


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


export const geOneNews = (newsId: number) => {
   return axiosInstance.get(`news/view?n=${newsId}`);
}


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


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




