<template>
  <user-dashboard-container page-class="agent-requests" panel-title="ویرایش اطلاعات نمایندگی">
    <div class="upload-assets">
      <el-skeleton v-if="loading" class="mt-5" :rows="6" />

      <template v-else>
        <template v-if="lastRepresentation.editAccess">
          <EnrollRepresentationForm :data="lastRepresentation"/>
        </template>

        <div v-else class="mt-5" style="text-align: center; color: red">
          <h3>شما دسترسی ویرایش اطلاعات ندارید</h3>
        </div>
      </template>
    </div>
  </user-dashboard-container>
</template>

<script>
import { mapGetters } from 'vuex'
export default {
  name: 'AgentEditInfo',
  layout: 'user',
  data() {
    return {
      lastRepresentation: {},
      loading: true
    }
  },
  head() {
    return {
      title: 'آسان سرویس | ویرایش اطلاعات'
    }
  },
  computed: {
    ...mapGetters({
      agentAssetCategories: 'front/agentAssetCategories'
    }),
    user() {
      return this.$auth.user
    }
  },
  async mounted() {
    try {
      const lastRep = await this.$axios.$get(`/api/user/representation/${this.user.representation_id}`)
      this.lastRepresentation = lastRep
    } catch (err) {
      console.log('err', err)
    }
    this.loading = false
  }
}
</script>
