import { Eye } from "lucide-react";
import { useNavigate } from "react-router-dom";
import { Button } from "@/components/ui/button";
import { buildStaffApplicationReviewHref } from "@/lib/applicationReviewNavigation";

type Props = {
  applicationId: string;
  /** Dashboard path to return to after review (must start with `/dashboard` per `ApplicationReviewPage`). */
  returnTo?: string;
  className?: string;
};

/**
 * Opens submitted forms for an application via `GET /api/applications/:id` + draft bundle on the review route.
 * Uses staff review route + read-only forms (`formsView=1`).
 */
export function ViewSubmittedApplicationButton({
  applicationId,
  returnTo = "/dashboard",
  className,
}: Props) {
  const navigate = useNavigate();

  return (
    <Button
      type="button"
      size="icon"
      variant="outline"
      className={className}
      onClick={() =>
        navigate(
          buildStaffApplicationReviewHref({
            applicationId,
            returnTo,
            viewOnly: true,
          }),
        )
      }
      aria-label="Xem hồ sơ"
    >
      <Eye className="h-4 w-4" />
    </Button>
  );
}
