import { getUsers } from '~/apis/admin/get-users'
import { handleCookie } from '~/libs/cookies'
import { UsersPage } from '~/pages/dashboard-users'

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

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

  return { usersData }
}

const DashboardUsersLayout = () => <UsersPage />
export default DashboardUsersLayout
