import agent from '../api/agent'
import { tagState } from '../stateManagement/tagState'
import stringArrayToSelectObject from './stringArrayToSelectObject'


export const retrieveTags = async () => {
  const tagsAPI = await agent.RetrieveTags.tags()
  const genres = stringArrayToSelectObject(tagsAPI.data.genre)
  const series = stringArrayToSelectObject(tagsAPI.data.series)
  const store = stringArrayToSelectObject(tagsAPI.data.store)
  const developer = stringArrayToSelectObject(tagsAPI.data.developer)
  const publisher = stringArrayToSelectObject(tagsAPI.data.publisher)
  tagState.genres.merge(genres)
  tagState.series.set(series)
  tagState.store.set(store)
  tagState.developer.set(developer)
  tagState.publisher.set(publisher)
}
