Download references/invite-admin/src/components/InviteDialog.tsx from mirasim-ai/devbrowse-bench: direct link, hf CLI and curl.
- Browser
- Download file 1.63 kB
-
https://huggingface.co/datasets/mirasim-ai/devbrowse-bench/resolve/main/references/invite-admin/src/components/InviteDialog.tsx
- Command line
-
hf download hf://datasets/mirasim-ai/devbrowse-bench/references/invite-admin/src/components/InviteDialog.tsx
-
curl -L -o InviteDialog.tsx https://huggingface.co/datasets/mirasim-ai/devbrowse-bench/resolve/main/references/invite-admin/src/components/InviteDialog.tsx
1.63 kB
| import { useState } from "react"; | |
| import { createPortal } from "react-dom"; | |
| import { useTeam } from "../store/TeamContext"; | |
| export function InviteDialog({ onClose }: { onClose: () => void }) { | |
| const { sendInvite } = useTeam(); | |
| const [email, setEmail] = useState(""); | |
| const [error, setError] = useState<string | null>(null); | |
| const [sending, setSending] = useState(false); | |
| const send = async () => { | |
| setSending(true); | |
| setError(null); | |
| try { | |
| await sendInvite(email); | |
| onClose(); | |
| } catch (e) { | |
| setError((e as Error).message); | |
| } finally { | |
| setSending(false); | |
| } | |
| }; | |
| return createPortal( | |
| <div className="overlay" onClick={(e) => e.target === e.currentTarget && onClose()}> | |
| <section className="sheet" role="dialog" aria-modal="true" aria-labelledby="invite-title"> | |
| <h2 id="invite-title">Invite a teammate</h2> | |
| <form | |
| onSubmit={(e) => { | |
| e.preventDefault(); | |
| void send(); | |
| }} | |
| > | |
| <label className="field"> | |
| <input type="email" value={email} onChange={(e) => setEmail(e.target.value)} placeholder="name@company.com" autoFocus /> | |
| </label> | |
| {error && <p className="form-error">{error}</p>} | |
| <div className="actions"> | |
| <button type="button" onClick={onClose}> | |
| Cancel | |
| </button> | |
| <button type="submit" className="primary" disabled={!email.trim() || sending}> | |
| Send invite | |
| </button> | |
| </div> | |
| </form> | |
| </section> | |
| </div>, | |
| document.body, | |
| ); | |
| } | |