import { apiGet, isMockApiEnabled, type ServiceRequestOptions } from '@/services/api-client'
import { discoverService } from '@/services/discover-service'
import type { DiscoverParams, DiscoverSection } from '@/types/domain'

export const gamesService = {
  getSections: async (
    params: Omit<DiscoverParams, 'mediaType'>,
    options: ServiceRequestOptions = {},
  ): Promise<DiscoverSection[]> => {
    if (isMockApiEnabled()) {
      return discoverService.getSections({ ...params, mediaType: 'game' }, options)
    }

    return apiGet<DiscoverSection[]>('/api/v1/games', {
      page: params.page ?? 1,
      pageSize: params.pageSize ?? 6,
      query: params.query?.trim() ?? '',
      genre: params.genre ?? '',
    })
  },
}
