import type { Route } from './+types/route'

import { Link } from 'react-router'

import {
  Breadcrumb,
  BreadcrumbItem,
  BreadcrumbLink,
  BreadcrumbList,
  BreadcrumbPage,
  BreadcrumbSeparator
} from '@repo/ui/components/ui/breadcrumb'
import { request as req } from '@repo/util/request'

export async function loader({ request, params, context }: Route.LoaderArgs) {
  const seats = await req({
    url: `/orgs/${params.orgid}/seats`,
    request,
    context
  }).then((r) => r.json() as any)

  return { seats }
}

export default function Route({ loaderData: { seats } }: Route.ComponentProps) {
  console.log(seats)
  return (
    <div className="space-y-2.5">
      <Breadcrumb>
        <BreadcrumbList>
          <BreadcrumbItem>
            <BreadcrumbLink asChild>
              <Link to="../enrollments">Matrículas</Link>
            </BreadcrumbLink>
          </BreadcrumbItem>
          <BreadcrumbSeparator />
          <BreadcrumbItem>
            <BreadcrumbPage>Adicionar matrículas</BreadcrumbPage>
          </BreadcrumbItem>
        </BreadcrumbList>
      </Breadcrumb>
    </div>
  )
}
