<script setup lang="ts">
import { usePageDataStore } from '#layers/stores/usePageDataStore'
import { getLayoutType } from '#layers/utils/dataUtil'
import type { PageDataValue } from '#layers/types/api/pageData'

const getPageData = ref<PageDataValue | null>(null)

onMounted(() => {
  const pageDataStore = usePageDataStore()
  const { pageData } = storeToRefs(pageDataStore)
  getPageData.value = pageData.value
})

const currentLayout = computed(() => getLayoutType(getPageData.value))


definePageMeta({
  layout: false, // 동적 레이아웃을 위해 기본 레이아웃 비활성화
  middleware: ['inspection'],
})
</script>

<template>
  <NuxtLayout :name="currentLayout">
    <LayoutsMain v-if="getPageData" :page-data="getPageData" />
  </NuxtLayout>
</template>
