"use client"

import { useEffect } from "react"
import Link from "next/link"
import { useTranslations } from "next-intl"
import { Button } from "@/shared/components/ui/button"

export default function PracticeSessionError({
  error,
  reset,
}: {
  error: Error & { digest?: string }
  reset: () => void
}): React.ReactNode {
  const t = useTranslations("student")
  useEffect(() => {
    console.error("Practice session error:", error)
  }, [error])

  return (
    <div className="flex h-full flex-col items-center justify-center space-y-4 p-8">
      <h2 className="text-xl font-semibold">{t("error.title")}</h2>
      <p className="text-sm text-muted-foreground">{error.message}</p>
      <div className="flex gap-2">
        <Button onClick={reset}>{t("error.retry")}</Button>
        <Button variant="outline" asChild>
          <Link href="/student/practice">{t("classDetail.backToCourses")}</Link>
        </Button>
      </div>
    </div>
  )
}
