import { MockupShortlistProvider } from '../provider/MockupShortlistProvider'
import type { ShortlistFilters } from '../provider/IShortlistProvider'
import type { Shortlist, CreateShortlistInput, UpdateShortlistInput, ShortlistItemInput } from '../domain/shortlist'
import type { ListResponse, ItemResponse } from './types'

const provider = MockupShortlistProvider

export const shortlistService = {
  async getAll(filters?: ShortlistFilters): Promise<ListResponse<Shortlist>> {
    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<Shortlist | null>> {
    const data = await provider.getById(id)
    return { data }
  },
  async create(input: CreateShortlistInput): Promise<ItemResponse<Shortlist>> {
    const data = await provider.create(input)
    return { data }
  },
  async update(id: string, input: UpdateShortlistInput): Promise<ItemResponse<Shortlist>> {
    const data = await provider.update(id, input)
    return { data }
  },
  async addItem(id: string, item: ShortlistItemInput): Promise<ItemResponse<Shortlist>> {
    const data = await provider.addItem(id, item)
    return { data }
  },
  async removeItem(id: string, resultId: string): Promise<ItemResponse<Shortlist>> {
    const data = await provider.removeItem(id, resultId)
    return { data }
  },
  async remove(id: string): Promise<ItemResponse<void>> {
    await provider.remove(id)
    return { data: undefined }
  },
}
