<template>
  <div>
    <div class="d-flex akkurat-regular justify-content-start p-2 text-end">Filtros:</div>
    <div class="filters-wrap">
      <div class="d-flex justify-content-start pt-1 pl-4">
        <b-form-group class="akkurat-regular" label="Produtos">
          <b-form-radio
            v-for="option in productOptions"
            :key="option.value"
            v-model="selectedProduct"
            :value="option.value"
            size="sm"
            class="text-left radius-text"
          >
            <span class="filters-text akkurat-light-regular">{{ option.text }}</span>
          </b-form-radio>
        </b-form-group>
      </div>
      <hr class="line-between" />
      <div class="d-flex justify-content-start pt-1 pl-4">
        <categories @change="changeSelectedCategories" v-model="selectedCategories" ref="categories"></categories>
      </div>
    </div>
    <div class="pt-1">
      <general-button @clicked="clearFilters" icon="filter" title="Limpar Filtros" />
    </div>
  </div>
</template>

<script>
import Categories from "./Sidebar/Categories";
export default {
  name: "side-filter",
  components: {
    Categories
  },
  data: () => ({
    selectedProduct: "todos_os_produtos",
    selectedCategories: [],
    productOptions: [
      { text: "Todos os Produtos", value: "todos_os_produtos" },
      { text: "Ponta de Estoque", value: "queima_de_estoque" },
      { text: "Promoção", value: "promocao" },
      { text: "Kit`s", value: "kits" }
    ]
  }),
  methods: {
    check(e) {
      if (e.target.checked) {
        console.log(e.target.value);
      }
    },
    changeSelectedCategories(){
     
      this.$emit('change-filters',this.selectedCategories);
    },
    clearFilters() {
     
      this.selectedProduct= "todos_os_produtos";
      this.$refs.categories.clearValue();

    }
  }
};
</script>

<style lang="scss" scoped>
@import "../../assets/css/main.scss";

.filters-wrap {
  /* height: 562px; */
  background: #ffffff 0% 0% no-repeat padding-box;
  box-shadow: $box-shadow;
  border-radius: 10px;
}

.line-between {
  width: 85%;
  margin: 1px auto;
}

.filters-text {
  text-align: left;
  font: Light 10px/21px Akkurat;
  letter-spacing: 0;
  color: #636363;
  opacity: 1;
}

.radius-text {
  font-size: 0.725rem;
}
</style>
