import React, { useState } from "react"; import { cn } from "@/lib/utils"; import { Button } from "./button"; import { Card } from "./card"; import { Input } from "./input"; import { SendHorizontal } from "lucide-react"; const EMAIL_RE = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; export interface LoanApplicantInviteProps { /** Called when the user submits a valid email */ onInvite?: (email: string) => void; loading?: boolean; className?: string; } export function LoanApplicantInvite({ onInvite, loading = false, className, }: LoanApplicantInviteProps) { const [email, setEmail] = useState(""); const isValid = EMAIL_RE.test(email); const handleSend = () => { if (!isValid) return; onInvite?.(email); setEmail(""); }; const handleKeyDown = (e: React.KeyboardEvent) => { if (e.key === "Enter") handleSend(); }; return (

Create Joint Application

setEmail(e.target.value)} onKeyDown={handleKeyDown} placeholder="Co-applicant email" className="flex-1 border-r-0 focus-visible:ring-0 focus-visible:ring-offset-0" aria-label="Co-applicant email" />
{email && !isValid && (

Invalid email address

)}
); }