"use client"; import React from "react"; import { useRouter } from "next/navigation"; import { ChevronLeft } from "lucide-react"; import { cn } from "../lib/utils"; interface BackButtonProps { className?: string; label?: string; } export default function BackButton({ className, label = "بازگشت" }: BackButtonProps) { const router = useRouter(); const handleBack = () => { // router.back() preserves browser history and scroll position natively if (typeof window !== "undefined" && window.history.length > 1) { router.back(); } else { router.push("/"); } }; return ( ); }