import { Outlet } from 'react-router'

import { getCategories } from '~/apis/common/get-categories'
import { getSubscriptions } from '~/apis/common/get-subscriptions'
import { getTags } from '~/apis/common/get-tags'
import { AdminProvider } from '~/contexts/admin'
import { AdminDashboardLayout } from '~/layouts/admin/dashboard'

import type { Route } from './+types/_admin.lg-admin._dashboard'

export const loader = async ({}: Route.LoaderArgs) => {
  const { data: categoriesData } = await getCategories()
  const { data: tagsData } = await getTags()
  const { data: subscriptionsData } = await getSubscriptions()

  return {
    categoriesData,
    tagsData,
    subscriptionsData,
  }
}

const DashboardLayout = () => {
  return (
    <AdminProvider>
      <AdminDashboardLayout>
        <Outlet />
      </AdminDashboardLayout>
    </AdminProvider>
  )
}
export default DashboardLayout
