"use client"; import * as React from "react"; import { cn } from "./lib/utils"; export interface InviteModalProps { open: boolean; onOpenChange: (open: boolean) => void; roles?: string[]; onSend?: (email: string, role: string) => void; } /** Team member invite modal: email + role selector + dispatch state. */ export function InviteModal({ open, onOpenChange, roles = ["admin", "editor", "member"], onSend }: InviteModalProps) { const [email, setEmail] = React.useState(""); const [role, setRole] = React.useState(roles[roles.length - 1]); const [sent, setSent] = React.useState(false); const valid = /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email); React.useEffect(() => { if (!open) return; const handleKeyDown = (event: KeyboardEvent) => { if (event.key === "Escape") onOpenChange(false); }; document.addEventListener("keydown", handleKeyDown); return () => document.removeEventListener("keydown", handleKeyDown); }, [open, onOpenChange]); if (!open) return null; return (
onOpenChange(false)}>
e.stopPropagation()} className="w-full max-w-sm rounded-lg border border-border bg-card p-5 shadow-lg animate-[invScale_0.25s_cubic-bezier(0.16,1,0.3,1)_both] motion-reduce:animate-none" > {!sent ? ( <>

Invite team member

An invitation email will be dispatched immediately.

setEmail(e.target.value)} placeholder="ada@example.com" aria-label="Invitation email" className="w-full rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring" />
{roles.map((r) => ( ))}
) : (

Invitation sent

{email}

)}
); }