// https://react-spectrum.adobe.com/react-aria/routing.html#app-router

"use client"

import { useRouter } from "next/navigation"
import { RouterProvider } from "react-aria-components"

import type { PropsWithChildren } from "react"

declare module "react-aria-components" {
  interface RouterConfig {
    routerOptions: NonNullable<
      Parameters<ReturnType<typeof useRouter>["push"]>[1]
    >
  }
}

export function RACRouterProvider({ children }: PropsWithChildren) {
  const router = useRouter()

  return <RouterProvider navigate={router.push}>{children}</RouterProvider>
}
