import { api } from '@/lib/api'
import type { Home } from '@/types/api'

export const homeService = {
    getAll: async () => {
        // Assuming backend returns array or PaginatedResponse. Using array for now based on recent patterns.
        const response = await api.get<Home[]>('/v1/admin/homes')
        return response.data
    },

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

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

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

    delete: async (id: string) => {
        await api.delete(`/v1/admin/homes/${id}`)
    }
}
