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

const tab = ref('prices')
const tabs = ref([
  {value: 'prices', text: 'Product Price'},
  {value: 'breaks', text: 'Product Price Break'},
])

const openTab = async (val) => {
  if(tab.value !== val) {
    tab.value = val
    sessionStorage.setItem('price_list_version_detail_record', tab.value)
  }
}
onMounted(() => {
  const getSessionStorageTab = sessionStorage.getItem('price_list_version_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)" />
    <MaterialsPriceListVersionDetailRecordPrice v-if="tab === 'prices'" :action="action" :info="info" />
    <MaterialsPriceListVersionDetailRecordBreak v-if="tab === 'breaks'" :action="action" :info="info" />
  </div>
</template>