import { ArrowUpRightIcon } from "@/components/icons";
import { Button } from "@/components/ui/button";

type FormFooterProps = {
  cancelLabel: string;
  submitLabel: string;
  pending: boolean;
  /** Without it, "Cancel" is a plain reset button; with it (e.g. to also clear a file or checkbox), it calls this. */
  onCancel?: () => void;
};

/** Outlined pill (Figma "Cancel"); also used for "Send another request" after a successful send. */
export const outlinePillClass =
  "h-auto rounded-full border-subtle bg-transparent px-[22px] py-3 text-base font-bold tracking-[0.5px] text-soft hover:bg-white/10 dark:bg-transparent";

/** Bottom bar of a form card (Figma: Request Service, Job Application): outlined "Cancel" and the white send pill. */
export function FormFooter({ cancelLabel, submitLabel, pending, onCancel }: FormFooterProps) {
  return (
    <div className="flex items-center justify-between border-t border-white/7 bg-white/2 p-5 md:px-8 md:py-6">
      <Button
        type={onCancel ? "button" : "reset"}
        onClick={onCancel}
        variant="outline"
        className={outlinePillClass}
      >
        {cancelLabel}
      </Button>
      <Button type="submit" variant="white" size="pill" disabled={pending} className="h-[50px] text-base text-text-dark">
        {submitLabel}
        <ArrowUpRightIcon data-icon="inline-end" className="rtl:-scale-x-100" />
      </Button>
    </div>
  );
}
