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

const tab = ref(props.modelValue || 'org_access')
const tabs = ref([
  {value: 'org_access', text: 'Org Access'},
  {value: 'user_assignment', text: 'User Assignment'},
  /*{value: 'window_access', text: 'Window Access'},
  {value: 'process_access', text: 'Process Access'},
  {value: 'form_access', text: 'Form Access'},
  {value: 'info_access', text: 'Info Access'},
  {value: 'workflow_access', text: 'Workflow Access'},
  {value: 'task_access', text: 'Task Access'},
  {value: 'document_action_access', text: 'Document Action Access'},
  {value: 'included_roles', text: 'Included Roles'},
  {value: 'document_status_access', text: 'Document Status Access'}*/
])

const openTab = async (val) => {
  if(tab.value !== val) {
    tab.value = val
    sessionStorage.setItem('role_detail_record', tab.value)
  }
}
onMounted(() => {
  const getSessionStorageTab = sessionStorage.getItem('role_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)" />
      <AdminRoleDetailRecordOrgaccess v-if="tab === 'org_access'" :action="action" :info="info" />
      <AdminRoleDetailRecordUserAssignment v-else-if="tab === 'user_assignment'" :action="action" :info="info" />
  </div>
</template>