<template>
  <div id="inventorySearch">
    <input
      class="input is-primary is-medium"
      type="text"
      placeholder="Find something in particular..."
      v-model.trim="term"
      @input="updateSearch"
      autofocus
    />
    <content class="has-text-centered" v-if="noResults">
      <p>We couldn't find anything like that...</p>
    </content>
  </div>
</template>

<script>
export default {
  name: "InventorySearch",
  data() {
    return {
      term: ""
    };
  },
  computed: {
    noResults() {
      return !this.$store.getters.inventory.length;
    }
  },
  methods: {
    updateSearch() {
      this.$store.commit("filterTerm", this.term);
    }
  }
};
</script>
