import { api } from "@/lib/api"
import type { Banner } from "@/types/api"

export const bannerService = {
    getAll: async (): Promise<Banner[]> => {
        const response = await api.get<Banner[]>("/v1/admin/banners")
        return response.data
    },

    getById: async (id: string): Promise<Banner> => {
        const response = await api.get<Banner>(`/v1/admin/banners/${id}`)
        return response.data
    },

    create: async (data: FormData): Promise<Banner> => {
        const response = await api.post<Banner>("/v1/admin/banners", data, {
            headers: {
                "Content-Type": "multipart/form-data",
            },
        })
        return response.data
    },

    update: async (id: string, data: FormData): Promise<Banner> => {
        const response = await api.put<Banner>(`/v1/admin/banners/${id}`, data, {
            headers: {
                "Content-Type": "multipart/form-data",
            },
        })
        return response.data
    },

    delete: async (id: string): Promise<void> => {
        await api.delete(`/v1/admin/banners/${id}`)
    }
}
