"use client"

import { useEffect } from "react"

type RedirectProps = {
  url: string
  timeout?: number
}
export function Redirect({ url, timeout }: RedirectProps) {
  useEffect(() => {
    const timer = setTimeout(() => {
      window.location.href = url
    }, timeout || 0)

    return () => clearTimeout(timer)
  }, [url, timeout])

  return null
}
