import { useNavigate } from "@remix-run/react";
import { Button } from "../../atoms";

type BackButtonProps = {
  text?: string;
  backUrl?: string;
};

const BackButton = ({ text, backUrl }: BackButtonProps) => {
  const navigate = useNavigate();

  const handleGoBack = () => {
    backUrl ? navigate(backUrl) : navigate(-1);
  };

  return (
    <Button variant="simple" className="text-mono-600 p-0" onClick={handleGoBack}>
      <>&#8592;<span className="pl-1">{text}</span></>
    </Button>
  );
};

export { BackButton, BackButtonProps };
