import React from "react";
import { cn } from "@/lib/utils";
import { Button } from "@/components/ui/button";

/**
 * Full-screen success card shown after a loan application is submitted.
 * Extracted from the submitted/ page in the loan application flow.
 */

export type SubmissionConfirmationCardProps = {
  onViewSubmission?: () => void;
  className?: string;
};

function CircleCheckIcon({ className }: { className?: string }) {
  return (
    <svg
      xmlns="http://www.w3.org/2000/svg"
      viewBox="0 0 80 80"
      fill="none"
      className={cn("size-20", className)}
      aria-hidden="true"
    >
      <circle cx="40" cy="40" r="38" stroke="currentColor" strokeWidth="3" />
      <path
        d="M24 40l12 12 20-24"
        stroke="currentColor"
        strokeWidth="3.5"
        strokeLinecap="round"
        strokeLinejoin="round"
      />
    </svg>
  );
}

export function SubmissionConfirmationCard({
  onViewSubmission,
  className,
}: SubmissionConfirmationCardProps) {
  return (
    <div
      className={cn(
        "flex flex-col items-center gap-6 px-6 py-12 text-center",
        className,
      )}
    >
      <CircleCheckIcon className="text-primary" />

      <div className="flex flex-col gap-2">
        <p className="text-2xl font-bold">Awesome!</p>
        <p className="text-2xl font-bold">
          You&apos;ve submitted your loan application!
        </p>
      </div>

      <p className="max-w-sm text-sm text-muted-foreground">
        Your broker will take a look at your loan application and get back to
        you with the results soon!
      </p>

      {onViewSubmission && (
        <Button type="button" variant="outline" onClick={onViewSubmission}>
          View Your Submission
        </Button>
      )}
    </div>
  );
}
