<template>
  <div>
    <span class="icon is-large">
      <i class="fas fa-2x fa-piggy-bank"></i>
    </span>
    <nav class="columns is-mobile">
      <div class="column">
          <p class="heading">CP</p>
          <p class="is-size-3">{{ wealth[0] }}</p>
      </div>
      <div class="column">
          <p class="heading">SP</p>
          <p class="is-size-3">{{ wealth[1] }}</p>
      </div>
      <div class="column">
          <p class="heading">GP</p>
          <p class="is-size-3">{{ wealth[2] }}</p>
      </div>
      <div class="column">
          <p class="heading">PP</p>
          <p class="is-size-3">{{ wealth[3] }}</p>
      </div>
    </nav>
    <nav v-show="edit" class="columns is-mobile">
      <div class="column">
        <input type="number" class="input" v-show="edit" v-model="edit_values[0]"></input>
      </div>
      <div class="column">
        <input type="number" class="input" v-show="edit" v-model="edit_values[1]"></input>
      </div>
      <div class="column">
        <input type="number" class="input" v-show="edit" v-model="edit_values[2]"></input>
      </div>
      <div class="column">
        <input type="number" class="input" v-show="edit" v-model="edit_values[3]"></input>
      </div>
    </nav>
    <nav v-show="edit" class="columns is-mobile">
      <div class="column is-3 is-offset-3">
        <button class="button is-fullwidth is-danger"
            @click="updateWealth('minus')">
          <span class="icon"><i class="fas fa-2x fa-minus"></i></span>
        </button>
      </div>
      <div class="column is-3">
        <button class="button is-primary is-fullwidth"
            @click="updateWealth('plus')">
          <span class="icon"><i class="fas fa-2x fa-plus"></i></span>
        </button>
      </div>
    </nav>
  </div>
</template>

<script>
    export default {
        props: ["wealth", "edit"],
        data () { 
            return {
                edit_values: [0,0,0,0], 
            }; 
        },
        methods: {
            updateWealth (op) {
                const values = this.edit_values.map(Number);
                console.log('updateWealth', op, values);
                let success;
                if (true) {
                    success = true;
                } 
                if (success) {
                    this.$emit('updated');
                    this.edit_values.fill(0)

                }
            }
        }
    }
</script>
