<template>
  <div class="page-admin">
    <template v-if="user.role === 'admin'">
      <div class="page-admin__body">
        <div class="page-admin__tiles">
          <AdminTileMyself :user="user" />
          <AdminTileGames :games="games.games" />
        </div>
      </div>
    </template>
    <template v-else>
      <p>You are not an admin.</p>
    </template>
  </div>
</template>

<script>
export default {
  async fetch() {
    await this.$engine.fetchUserInfo()
    await this.$engine.fetchGames()
  },
  computed: {
    isAdmin() {
      return this.$store.state.engine.user?.role === 'admin'
    },
    user() {
      return this.$store.state.engine.user || {}
    },
    games() {
      return this.$store.state.engine.games || {}
    },
  },
}
</script>

<style lang="scss">
@import '~/assets/css/components';

.page-admin {
  color: #ffffff;
  width: 100%;
  height: 100%;

  &__body {
    position: relative;
  }

  &__tiles {
    display: flex;
    flex-wrap: wrap;
    padding: 24px;
  }
}
</style>
