Download references/shared-modal/src/components/InviteDialog.tsx from mirasim-ai/devbrowse-bench: direct link, hf CLI and curl.
- Browser
- Download file 1.41 kB
-
https://huggingface.co/datasets/mirasim-ai/devbrowse-bench/resolve/main/references/shared-modal/src/components/InviteDialog.tsx
- Command line
-
hf download hf://datasets/mirasim-ai/devbrowse-bench/references/shared-modal/src/components/InviteDialog.tsx
-
curl -L -o InviteDialog.tsx https://huggingface.co/datasets/mirasim-ai/devbrowse-bench/resolve/main/references/shared-modal/src/components/InviteDialog.tsx
1.41 kB
| import { useState } from "react"; | |
| import { teamApi } from "../api/team"; | |
| import type { Invite } from "../types"; | |
| import { Modal } from "./Modal"; | |
| export function InviteDialog({ onInvited, onClose }: { onInvited: (invite: Invite) => void; onClose: () => void }) { | |
| const [email, setEmail] = useState(""); | |
| const [error, setError] = useState<string | null>(null); | |
| const [sending, setSending] = useState(false); | |
| const send = async () => { | |
| setSending(true); | |
| setError(null); | |
| try { | |
| onInvited(await teamApi.invite(email.trim())); | |
| onClose(); | |
| } catch (e) { | |
| setError((e as Error).message); | |
| } finally { | |
| setSending(false); | |
| } | |
| }; | |
| return ( | |
| <Modal title="Invite a teammate" onClose={onClose}> | |
| <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> | |
| </Modal> | |
| ); | |
| } | |