<template>
  <div class="admin--dashboard">
    <div class="admin--dashboard-stats">
    </div>
  </div>
</template>

<script setup>
import { ref, onMounted } from 'vue'

definePageMeta({
  layout: 'admin',
  middleware: ['auth']
})

const stats = ref({
  popups: 0,
  branches: 0,
  employees: 0,
  brochures: 0
})

const { get } = useApi()

const loadDashboardStats = async () => {
  const { data, error } = await get('/dashboard/stats')

  console.log('[Dashboard] API 응답:', { data, error })

  if (error) {
    console.error('[Dashboard] 통계 로드 실패:', error)
    return
  }

  // API 응답: { success: true, data: { popups, branches, employees, brochures } }
  if (data?.success && data?.data) {
    stats.value = data.data
    console.log('[Dashboard] 통계 로드 성공:', stats.value)
  }
}

onMounted(() => {
  loadDashboardStats()
})
</script>
