<template>
  <div class="app-container">
    <el-tabs v-model="activeName">
      <el-tab-pane v-for="item in tables" :key="item.name" :label="$t(item.titleKey)" :name="item.component" />
      <component :is="activeName" />
    </el-tabs>
  </div>
</template>
<script>
import BadgeRule from './badge-rule'
import BadgeGive from './badge-give'
import BadgeRevoke from './badge-revoke'
import { mapGetters } from 'vuex'
export default {
  name: 'BadgeTab',
  components: { BadgeRule, BadgeGive, BadgeRevoke },
  data() {
    return {
      activeName: 'BadgeRule',
      tables: [
        {
          titleKey: 'pages.badgeManagement.tabs.rule',
          component: 'BadgeRule'
        }
      ]
    }
  },
  computed: {
    ...mapGetters(['buttonPermissions'])
  },
  created() {
    if (this.buttonPermissions.includes('content:manager:badge:send:or:revoke')) {
      this.tables.push({
        titleKey: 'pages.badgeManagement.tabs.giveOrRetrieve',
        component: 'BadgeGive'
      })
      this.tables.push({
        titleKey: 'pages.badgeManagement.tabs.retrieve',
        component: 'BadgeRevoke'
      })
    }
  }
}
</script>
