import { ChevronLeft } from "lucide-react";
import { useRouter } from "next/navigation";

const BackButton = () => {
  const router = useRouter();

  const handleBack = () => {
    if (window.history.length > 1) {
      router.back();
    } else {
      router.push("/");
    }
  };

  return (
    <button
      onClick={handleBack}
      className="text-blue-500 hover:underline focus:outline-none flex items-center"
    >
      <ChevronLeft className="inline-block w-4 h-4 mr-2" />
      Zurück
    </button>
  );
};

export default BackButton;
