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

export const siteInfoService = {
    getAll: async (): Promise<SiteInfo[]> => {
        const response = await api.get<SiteInfo[]>("/v1/admin/site-info")
        return response.data
    },

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

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

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

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