<template>
  <div class="container">
    <div class="container">
      <div class="row">
        <div class="col-md-12 col-lg-8">
          <div class="title-box-d">
            <br />
            <h1 class="title-d" style="text-align:left; font-size: 250%">My Cart</h1>
          </div>
        </div>
      </div>
      <!-- ListView -->
      <ListView
        :items="cartItems"
        :displayColumns="columns"
        :displayFormats="formats"
        :editable="true"
        :deleteable="true"
        @onEdit="Edit"
        @onDelete="Delete"
      />
    </div>
    <modal name="menu" :width="600" :height="auto">
      <Cart :showItem="CurrentItem" />
    </modal>
  </div>
</template>

<script>
import { mapState, mapActions } from "vuex";
import ListView from "../shared/listView";
import Cart from "./cartItem";

export default {
  name: "MyCart",
  components: {
    ListView,
    Cart,
  },
  data() {
    return {
      wait: true,
      columns: ["image", "name", "description", "qty", "subTotal"],
      formats: ["image", "", "", "", "money"],
      item: {},
    };
  },
  methods: {
    New() {},
    Edit(item) {
      this.item = item;
      this.$modal.show("menu");
    },
    Delete(item) {
      this.cartItems.pop(item);
    },
  },
  computed: {
    ...mapState("cart", ["cartItems"]),
    CurrentItem() {
      return this.item;
    },
  },
};
</script>
