summaryrefslogtreecommitdiff
path: root/iridescence/src/components/InventoryCard.vue
blob: 6bcc548e5c5e1fb6911cc4909f8fb358807e89e1 (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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<template>
  <div id="inventoryCard">
    <div class="card">
      <div class="card-image">
        <figure class="image is-4by3">
          <img
            src="https://bulma.io/images/placeholders/1280x960.png"
            :alt="name"
          />
        </figure>
      </div>
      <div class="card-content">
        <div class="content">
          <p class="title is-4">{{ name }}</p>
          <p class="subtitle is-4">
            {{ dollars(cents) }}
          </p>
          <p class="subtitle is-6">{{ stock }}</p>
        </div>

        <div class="content">
          {{ description }}
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "InventoryCard",
  props: {
    id: Number,
    name: String,
    quantity: Number,
    cents: Number,
    imgPath: String,
    description: String
  },
  computed: {
    stock() {
      if (this.quantity < 0) {
        return "Made to order";
      } else if (this.quantity == 0) {
        return "Out of stock";
      } else {
        return [this.quantity, "in stock"].join(" ");
      }
    }
  },
  methods: {
    dollars: cents => "$ " + (cents / 100).toFixed(2)
  }
};
</script>