import { MockupNeedProvider } from '../provider/MockupNeedProvider'
import type { NeedFilters } from '../provider/INeedProvider'
import type { Need, CreateNeedInput, UpdateNeedInput } from '../domain/need'
import type { ListResponse, ItemResponse } from './types'

const provider = MockupNeedProvider

export const needService = {
  async getAll(filters?: NeedFilters): Promise<ListResponse<Need>> {
    const data = await provider.getAll(filters)
    return { data, meta: { total: data.length, page: 1, pageSize: data.length, hasMore: false } }
  },
  async getById(id: string): Promise<ItemResponse<Need | null>> {
    const data = await provider.getById(id)
    return { data }
  },
  async create(input: CreateNeedInput): Promise<ItemResponse<Need>> {
    const data = await provider.create(input)
    return { data }
  },
  async update(id: string, input: UpdateNeedInput): Promise<ItemResponse<Need>> {
    const data = await provider.update(id, input)
    return { data }
  },
  async remove(id: string): Promise<ItemResponse<void>> {
    await provider.remove(id)
    return { data: undefined }
  },
}
