import { Suspense } from "react"
import { redirect } from "next/navigation"

/**
 * Catch-all route for legacy /app/* URLs
 * Redirects to the corresponding route without the /app prefix
 */
async function LegacyRedirect({ params: paramsPromise }: { params: Promise<{ slug: string[] }> }) {
  const params = await paramsPromise
  const newPath = `/${params.slug.join("/")}`
  redirect(newPath)
  return null
}

export default function LegacyAppCatchAll(props: { params: Promise<{ slug: string[] }> }) {
  return (
    <Suspense fallback={null}>
      <LegacyRedirect params={props.params} />
    </Suspense>
  )
}
