<template>
  <div class="flexcr dashboard">
    <div class="dashboard-item" v-for="(item, index) in dashboard" :key="index">
      <div class="item-value">{{info[item.key] || "0"}}</div>
      <div class="item-title">{{item.title}}</div>
      <el-button
        type="primary"
        class="item-button"
        :disabled="!enable"
        @click="item.onClick">
        {{item.button}}
      </el-button>
    </div>
  </div>
</template>

<script>
  export default {
    name: "Dashboard",
    props: {
      siteId: String|Number,
      info: {
        type: Object,
        default: {}
      },
      enable: {
        type: Boolean,
        default: false
      }
    },
    data() {
      return {
        siteInfo: {},
        dashboard: [{
          key: "stations",
          title: "Stations",
          button: "Configure Station",
          onClick: () => this.toStations()
        },{
          key: "connectors",
          title: "Connectors",
          button: "View Connectors",
          onClick: () => this.toConnectors()
        },{
          key: "activeTransaction",
          title: "Active Transaction",
          button: "View Transactions",
          onClick: () => this.toTransactions()
        },{
          key: "reservationsMade",
          title: "Reservations Made",
          button: "View Reservations",
          onClick: () => this.toReservations()
        }]
      };
    },
    mounted() {
      
    },
    methods: {
      toStations() {
        this.$router.push({
          path: "/site-management/stations/" + this.siteId
        })
      },
      toConnectors() {
        this.$router.push({
          path: "/site-management/connectors/" + this.siteId
        })
      },
      toTransactions() {
        this.$router.push({
          path: "/transactions-reservations/transactions"
        })
      },
      toReservations() {
        this.$router.push({
          path: "/transactions-reservations/reservations"
        })
      }
    }
  }
</script>

<style scoped>
.dashboard {
  zoom: 0.88;
}
.dashboard-item {
  flex: 1;
  display: flex;
  margin: 5px 8px;
  align-items: center;
  flex-direction: column;
}
.item-value {
  color: #333;
  font-size: 22px;
  font-weight: bold;
  line-height: 30px;
}
.item-title {
  color: #333;
  font-size: 14px;
  line-height: 20px;
  white-space: nowrap;
  text-transform: uppercase;
}
.item-button {
  width: 100%;
  max-width: 200px;
  font-size: 13px;
  margin-top: 10px;
  padding: 12px 10px;
  text-transform: uppercase;
}
</style>