import {
  GroupsApiService,
  SearchApiService,
} from '../../../../../../../libs/data-access/gn4/src'
import { TranslateService } from '@ngx-translate/core'
import { PlatformServiceInterface } from '../../../../../../../libs/common/domain/src/lib/platform.service.interface'
import { ElasticsearchService } from '../elasticsearch'
import { OrganizationsStrategy } from './organization-strategy.token'
import { OrganizationsFromGroupsService } from './organizations-from-groups.service'
import { OrganizationsFromMetadataService } from './organizations-from-metadata.service'

export const organizationsServiceFactory = (
  strategy: OrganizationsStrategy,
  esService: ElasticsearchService,
  searchApiService: SearchApiService,
  groupsApiService: GroupsApiService,
  translateService: TranslateService,
  platformService: PlatformServiceInterface
) =>
  strategy === 'groups'
    ? new OrganizationsFromGroupsService(
        esService,
        searchApiService,
        groupsApiService,
        translateService
      )
    : new OrganizationsFromMetadataService(
        esService,
        searchApiService,
        groupsApiService,
        platformService,
        translateService
      )
