'use client'

import { useEffect } from 'react'
import { useRouter, useSearchParams } from 'next/navigation'
import { Suspense } from 'react'

function RedirectInner() {
  const router = useRouter()
  const searchParams = useSearchParams()

  useEffect(() => {
    const editId = searchParams.get('edit')
    const target = editId
      ? `/sdk/advisory-board?edit=${encodeURIComponent(editId)}`
      : '/sdk/advisory-board'
    router.replace(target)
  }, [router, searchParams])

  return (
    <div className="flex items-center justify-center h-64 text-gray-500">
      Weiterleitung...
    </div>
  )
}

export default function NewUseCasePage() {
  return (
    <Suspense fallback={<div className="flex items-center justify-center h-64 text-gray-500">Lade...</div>}>
      <RedirectInner />
    </Suspense>
  )
}
