import { GetterTree } from 'vuex'
import { State } from './index'
import { RootState } from '~/store/index'

export type Getters<S = State> = {
  lang(state: S, key: string): any
  langMain(state: S, key: string): any
  langData(state: S, key: string): any
  langForms(state: S, key: string): any
}

export const getters: GetterTree<State, RootState> & Getters = {
  lang: (state: State, key: string) => {
    return state.lang.get(key)
  },
  langMain: (state: State, key: string) => {
    return state.lang.get(key)?.main || null
  },
  langData: (state: State, key: string) => {
    return state.lang.get(key)?.data || null
  },
  langForms: (state: State, key: string) => {
    return state.lang.get(key)?.forms || null
  },
}
