"use client"

import { Suspense } from 'react'
import { AuthGuard } from "@/components/auth-guard"
import { AuthFlow } from "@/components/auth/auth-flow"
import { redirect } from "next/navigation"
import { useSearchParams } from 'next/navigation'

function RegisterContent() {
  const searchParams = useSearchParams()
  const partnerCode = searchParams.get('partner')

  return (
    <AuthGuard fallback={<AuthFlow partnerCode={partnerCode} />}>
      {/* Если пользователь авторизован, перенаправляем в дашборд */}
      {redirect('/dashboard')}
    </AuthGuard>
  )
}

export default function RegisterPage() {
  return (
    <Suspense fallback={<div>Загрузка...</div>}>
      <RegisterContent />
    </Suspense>
  )
} 