All files / components/Admin/AdminHome/RightSide TopProducts.vue

100% Statements 3/3
100% Branches 2/2
100% Functions 1/1
100% Lines 3/3

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49                                                  1x   2x                                 1x        
<template>
  <div>
    <div class="d-flex justify-content-between">
      <p class="text-uppercase">top products</p>
      <p>Today</p>
    </div>
    <span v-if="!topTodayProducts.length"
      >There were no products sold during this time</span
    >
    <ol v-else class="d-flex flex-column p-0">
      <li v-for="(product, index) in topTodayProducts" :key="product.id">
        <a
          href="/#"
          class="d-flex w-100"
          v-on:click.prevent="
            openModal('top-products-modal', { product, index })
          "
        >
          <span class="text-ellipsis">{{ product.title }}</span></a
        >
      </li>
    </ol>
    <TopProductsModal :modalData="modalData" />
  </div>
</template>
 
<script>
import TopProductsModal from "./TopProductsModal.vue";
 
export default {
  name: "TopProducts",
  props: {
    topTodayProducts: Array,
  },
  data: () => ({
    modalData: null,
  }),
  components: { TopProductsModal },
  methods: {
    openModal: function (modal, modalData) {
      this.modalData = modalData;
      this.$root.$emit("bv::show::modal", modal);
    },
  },
};
</script>
 
<style scoped>
</style>