import { getCategories } from '~/apis/common/get-categories'
import { handleCookie } from '~/libs/cookies'
import { CategoriesPage } from '~/pages/dashboard-categories'

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

export const loader = async ({ request }: Route.LoaderArgs) => {
  const { staffToken } = await handleCookie(request)
  const { data: dataCategories } = await getCategories({
    accessToken: staffToken,
  })
  return { dataCategories }
}

const DashboardCategoriesIndexLayout = () => <CategoriesPage />
export default DashboardCategoriesIndexLayout
