<template>
  <div class="account-info region-card" :data-language="language">
    <div class="card">
      <div class="account-info flex-l">
        <div class="avatar flex-c" :style="userAvatarColor">{{ firstNameStr }}</div>
        <div class="info">
          <div class="nickname">{{ name }}</div>
          <div class="account">{{ $t('pages.dashboard.account.accountLabel') }}: {{ loginName }}</div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { mapGetters } from 'vuex'
import { extractColorByText } from '@/utils'

export default {
  name: 'AccountInfo',
  computed: {
    ...mapGetters(['buttonPermissions', 'name', 'loginName', 'language']),
    userAvatarColor() {
      return 'background-color:' + extractColorByText(this.name) + ';'
    },
    firstNameStr() {
      return this.name ? this.name.trim().charAt(0) : '?'
    }
  }
}
</script>

<style lang="scss">
.account-info {
  .avatar {
    width: 55px;
    height: 55px;
    border-radius: 100%;
    color: #FFFFFF;
    font-weight: bold;
  }

  .info {
    padding: 0 10px;
    font-size: 12px;
    line-height: 18px;
  }
}
</style>
