import { Box } from "@mantine/core"
import { ArrowLeftIcon } from "@phosphor-icons/react"
import { useRouter } from "@tanstack/react-router"

interface BackButtonProps {
  offsetY: number;
}

const BackButton = ({ offsetY }: BackButtonProps) => {
  const router = useRouter()

  return (
    <Box
      style={{ cursor: 'pointer', zIndex: 1000, transform: `translateY(-${offsetY}px)` }}
      onClick={() => router.history.back()}
      pos='absolute'
      left={{ base: 0, sm: 100, md: 200, lg: 300 }}
      m={20}
    >
      <ArrowLeftIcon weight='bold' size={20} />
    </Box>
  );
}

export default BackButton;
