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

const tab = ref('accounting')
const tabs = ref([
  {value: 'accounting', text: 'Accounting'},
  {value: 'assigned_products', text: 'Assigned Products'},
  {value: 'translation', text: 'Translation'},
])

const openTab = async (val) => {
  if(tab.value !== val) {
    tab.value = val
    sessionStorage.setItem('product_category_detail_record', tab.value)
  }
}
onMounted(() => {
  const getSessionStorageTab = sessionStorage.getItem('product_category_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)" />
    <MaterialsProductCategoryDetailRecordAccounting v-if="tab === 'accounting'" :action="action" :info="info" />
    <MaterialsProductCategoryDetailRecordTranslation v-else-if="tab === 'translation'" :action="action" :info="info" />
    <MaterialsProductCategoryDetailRecordAssignedProduct v-else-if="tab === 'assigned_products'" :action="action" :info="info" />
  </div>
</template>