<template>
  <div class="flexcr dashboard">
    <div class="dashboard-item" v-for="(item, index) in dashboard" :key="index">
      <div class="item-value" v-if="info">{{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: "GroupSummary",
    props: {
      siteId: String|Number,
      info: {
        type: Object,
        default: () => {}
      },
      enable: {
        type: Boolean,
        default: true
      }
    },
    data() {
      return {
        siteInfo: {},
        dashboard: [{
          key: "creditLimit",
          title: "CREDIT LIMIT",
          button: "CONFIGURE LIMIT",
          onClick: () => this.toCreditLimit()
        },{
          key: "allowedSites",
          title: "ALLOWED SITES",
          button: "CONFIGURE SITES",
          onClick: () => this.toSiteMgmt()
        },{
          key: "users",
          title: "USERS",
          button: "VIEW USERS",
          onClick: () => this.toUsers()
        },{
          key: "transactions",
          title: "TRANSACTIONS",  
          button: "VIEW TRANSACTIONS",
          onClick: () => this.toTransactions()
        }]
      };
    },
    mounted() {
      
    },
    methods: {
      toCreditLimit() {
        this.$router.push({
          path: "/partnership-management/monthly-credit-management"
        })
      },
      toSiteMgmt() {
        this.$router.push({
          path: "/partnership-management/group-management"
        })
      },
      toTransactions() {
        this.$router.push({
          path: "/station-activities/transactions"
        })
      },
      toUsers() {
        this.$router.push({
          path: "/user-management"
        })
      }
    }
  }
</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>