<template>
  <modal name="suggested-modal" size="lg" >
    <div>
      <b-row class="d-flex justify-content-between mb-2 mt-1">
        <b-col class="d-flex modal-text-color ml-2" cols="8">
          <div class="d-flex align-self-center justify-content-center rounded-div mr-2 mt-1">
            <font-awesome-icon icon="shopping-basket" class="align-self-center" />
          </div>
          <div class="pt-1">
            <div class="inline-block akkurat-regular min-header-text">
            Aproveite e compre também
            </div>
            <div class="akkurat-bold max-header-text"> Sugestões de Compra</div>
          </div>
        </b-col>
        <b-col class="d-flex justify-content-end mr-2 mt-1">
          <span class="close-icon" @click="closeModal">
            <font-awesome-icon icon="times" class="align-self-center" />
          </span>
        </b-col>
      </b-row>
      
<b-row>

<b-col class="products" md='12'>

      <b-row v-for="row in products" :key="row.id">
        <b-col md="10">
          <span class="name bressay-bold-italic text-left"> ({{row.product.code}}) {{row.product.name}} </span>

          <span class="price akkurat-light-regular text-left"> de R$ {{row.regular_price}} por R$ {{row.catalog_value}}</span>
        </b-col>

        <b-col md="2" class="align-middle text-right" @click="addProduct(row)">
          <font-awesome-icon class='shopping-basket' icon="shopping-basket" />
        </b-col>
      </b-row>
 <b-alert variant="success" class="text-center" :show="products.length === 0">não há sugestão de produto.</b-alert>    


</b-col>


</b-row>

      <b-row class="footer">
        <b-col class="d-flex justify-content-center my-3 px-3">
          
          <b-button
            class="btn shadow-none border-0 btn-default btn-blue"
            @click="closeModal"
          >
            Fechar
          </b-button>
        </b-col>
      </b-row>
    </div>
  </modal>
</template>

<script>


export default {
  name: 'suggested-modal',
  
  data: () => ({
    file: null,
  }),
    computed: {
    products() {
      return this.$store.getters.getSuggestedProducts;
    }
  },
  methods: {
    closeModal() {
      this.$modal.hide('suggested-modal');
    },
       addProduct(productPerCampaign) {
      console.log(productPerCampaign);
      this.$store.dispatch("updateOrder", {
        product_per_campaign: productPerCampaign,
        quantity: 1
      });
    }
  },
};
</script>

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

.modal-text-color {
  color: #3E3E3E;
}

.min-header-text {
  letter-spacing: 0.2px;
  font-size: 9px;
}

.max-header-text {
  letter-spacing: 0.4px;
  font-size: 16px;
}


.close-icon {
  color: #979797;
  font-size: 20px;
}

.btn-default {
  border-radius: 20px;
  width: 100%;
  max-width: 192px;
  height: 35px;
  background: #275389;
}

.rounded-div{
    background: #edc52680 0% 0% no-repeat padding-box;
  svg {
    color: #edc526;
  }
}

.close-icon{
    cursor: pointer;
}
.footer{
  bottom: 15px;
  width: 100%;
  position: absolute;
}
.products {
  .row:not(:last-child) {
    border-bottom: 1px solid #979797;
  }

  .row {
    margin: 0px !important;

    padding: 6px 0px;

    .name {
     // display: block;
      letter-spacing: 0;
      color: #3e3e3e;
      font-size: 0.8em;
    }

    .price {
     // display: block;
      letter-spacing: 0;
      color: #2c2c2c;
      font-size: 0.8em;
    }
    .shopping-basket{
      color: #278937;
    position: absolute;
    text-align: center;
    bottom: 1px;
    right: 15px;
      &:hover{
        cursor: pointer;
           background: #5ea569;
   padding: 3px;
   height: 28px;
   width: 28px;
   border-radius: 50%;
      }
    }
  }
}
</style>
