import { ActionProcessorItem } from '..'
import { Element, Action } from '../../'
import helpers from '@/helpers'

export default class AutofillProcessor implements ActionProcessorItem {
  public processValue(element: Element, index: number, rootState: any, rootGetters: any): Action | null {
    if (element.key !== undefined && element.key !== 'master') {
      return {
        action: 'loadCountryRelation',
        payload: {
          country_id: rootGetters.getAppLocationCountry.countryId,
          relations: [element.key],
        },
      } as Action
    }

    return null
  }
}
