<script setup>
defineProps({
  action: String,
  info: Object
})

const tab = ref('user_roles')
const tabs = ref([
  {value: 'user_roles', text: 'User Roles'},
  {value: 'user_substitute', text: 'User Substitute'},
  {value: 'user_orgaccess', text: 'Org Access'},
  {value: 'user_mail', text: 'User Mail'},
  {value: 'user_query', text: 'Queries'},
  {value: 'ldap_access', text: 'LDAP Access'},
  {value: 'document_status_access', text: 'Document Status Access'}
])

const openTab = async (val) => {
  if(tab.value !== val) {
    tab.value = val
    sessionStorage.setItem('user_detail_record', tab.value)
  }
}
onMounted(() => {
  const getSessionStorageTab = sessionStorage.getItem('user_detail_record')
  if(getSessionStorageTab) {
    openTab(getSessionStorageTab)
  }
})
</script>

<template>
  <div class="bt-2px_dashed_hexe2e2e2">
    <DetailRecordTab v-model="tab" :tabs="tabs" @handler="(val) => openTab(val.value)" />
    <AdminUserDetailRecordRole v-if="tab === 'user_roles'" :action="action" :info="info" />
    <AdminUserDetailRecordSubstitute v-else-if="tab === 'user_substitute'" :action="action" :info="info" />
    <AdminUserDetailRecordOrgaccess v-else-if="tab === 'user_orgaccess'" :action="action" :info="info" />
    <AdminUserDetailRecordMail v-else-if="tab === 'user_mail'" :action="action" :info="info" />
    <AdminUserDetailRecordQuery v-else-if="tab === 'user_query'" :action="action" :info="info" />
    <AdminUserDetailRecordDocaccess v-else-if="tab === 'document_status_access'" :action="action" :info="info" />
  </div>
</template>