'use client'

import { redirect } from 'next/navigation'
import { useSession } from 'next-auth/react'

import CrossplaneResourceBrowser from '@/components/crossplane/CrossplaneResourceBrowser'

export default function CrossplanePage() {
  const { data: session, status } = useSession()

  if (status === 'loading') {
    return (
      <div className="flex min-h-screen items-center justify-center">
        <div className="animate-spin rounded-full h-8 w-8 border-b-2 border-blue-600"></div>
      </div>
    )
  }

  if (!session) {
    redirect('/api/auth/signin')
  }

  return (
    <div className="container mx-auto px-4 py-8">
      <CrossplaneResourceBrowser />
    </div>
  )
}

