import filter from 'lodash/filter'

export default {
  methods: {
    setSearch(search) {
      if (search.key && search.value !== '') {
        this.currentData = filter(this.initialData, item => {
          return (
            item[search.key].indexOf(search.value) > -1 ||
            item[search.key].indexOf(search.value.toLowerCase()) > -1 ||
            item[search.key].toLowerCase().indexOf(search.value.toLowerCase()) >
              -1
          )
        })
      } else if (search.value === '') {
        this.currentData = this.initialData
      }
    }
  }
}
