summaryrefslogtreecommitdiff
path: root/iridescence/src/components/CartCheckout.vue
blob: 590e5b97e7b99612840c1d7b2c2c2730dabd0ee4 (plain) (blame)
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
<template>
  <div id="cartCheckout">
    <div class="buttons has-addons">
      <router-link to="/cart" class="button is-primary is-rounded"
        >🛒 {{ checkoutReady }}</router-link
      >
      <button class="button is-static">x{{ inCart }}</button>
      <button class="button is-static is-rounded">
        {{ cartTotal }}
      </button>
    </div>
  </div>
</template>

<script>
export default {
  name: "CartCheckout",
  computed: {
    inCart() {
      return Object.values(this.$store.state.cart).reduce(
        (acc, cur) => acc + cur,
        0
      );
    },
    cartTotal() {
      return this.$store.getters.cartTotal;
    },
    checkoutReady() {
      if (this.inCart) {
        return "Checkout";
      } else {
        return "";
      }
    }
  }
};
</script>