Some checks failed
build-images / web (push) Has been cancelled
vision2026-ci / Python SDK resource tests (push) Has been cancelled
build-images / api (push) Has been cancelled
build-images / worker-gpu (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (comfy-workflow-schema) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (effects-core) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (eventbus-types) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (growth-analytics) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (provider-adapter-kit) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (publishing-connectors) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (render-core) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (shot-template-schema) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (trends-schema) (push) Has been cancelled
vision2026-ci / Desktop engine crates (test + clippy + fmt) (push) Has been cancelled
codeql / Analyze (javascript-typescript) (push) Has been cancelled
codeql / Analyze (python) (push) Has been cancelled
perf / API hot-path micro-smoke (budgeted) (push) Has been cancelled
perf / Desktop engine crates (release build check) (push) Has been cancelled
vision2026-ci / API phase modules (ruff + pytest) (push) Has been cancelled
vision2026-ci / Alembic upgrade + drift check (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (caption-engine) (push) Has been cancelled
Paid, hosted product at menivor.com, now retired as a company project. Fresh squashed history of the cleaned working tree (secret-scanned, no .env, no customer data, no outreach logs). Built on MoneyPrinterTurbo (MIT, harry0703) — see NOTICE.
98 lines
3.0 KiB
TypeScript
98 lines
3.0 KiB
TypeScript
"use client";
|
|
|
|
import * as React from "react";
|
|
import { UserPlus } from "lucide-react";
|
|
import {
|
|
ASSIGNABLE_WORKSPACE_ROLES,
|
|
type AssignableWorkspaceRole,
|
|
} from "@/lib/types";
|
|
import { Button } from "@/components/ui/button";
|
|
import { Input } from "@/components/ui/input";
|
|
import { Label } from "@/components/ui/label";
|
|
import { Select } from "@/components/ui/select";
|
|
import { roleLabel } from "@/components/team/roles";
|
|
|
|
export interface InviteMemberFormProps {
|
|
inviting: boolean;
|
|
inviteError: string;
|
|
onInvite: (email: string, role: AssignableWorkspaceRole) => Promise<boolean>;
|
|
}
|
|
|
|
const DEFAULT_ROLE: AssignableWorkspaceRole = "member";
|
|
|
|
/**
|
|
* Invite-by-email form with a role picker. Only rendered for owners/admins
|
|
* (the caller gates it). People who already have an account join right away;
|
|
* anyone else gets a pending invite whose accept link the parent shows.
|
|
* Clears the email on success.
|
|
*/
|
|
export function InviteMemberForm({
|
|
inviting,
|
|
inviteError,
|
|
onInvite,
|
|
}: Readonly<InviteMemberFormProps>) {
|
|
const [email, setEmail] = React.useState("");
|
|
const [role, setRole] = React.useState<AssignableWorkspaceRole>(DEFAULT_ROLE);
|
|
|
|
const trimmed = email.trim();
|
|
// Minimal boundary check; the backend is the source of truth for validity.
|
|
const emailLooksValid = /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(trimmed);
|
|
const canSubmit = emailLooksValid && !inviting;
|
|
|
|
const handleSubmit = async (event: React.FormEvent<HTMLFormElement>) => {
|
|
event.preventDefault();
|
|
if (!canSubmit) return;
|
|
const ok = await onInvite(trimmed, role);
|
|
if (ok) {
|
|
setEmail("");
|
|
setRole(DEFAULT_ROLE);
|
|
}
|
|
};
|
|
|
|
return (
|
|
<form onSubmit={handleSubmit} className="space-y-3">
|
|
<div className="grid gap-3 sm:grid-cols-[1fr_auto_auto] sm:items-end">
|
|
<div className="space-y-1.5">
|
|
<Label htmlFor="invite-email">Invite by email</Label>
|
|
<Input
|
|
id="invite-email"
|
|
type="email"
|
|
inputMode="email"
|
|
autoComplete="off"
|
|
value={email}
|
|
onChange={(e) => setEmail(e.target.value)}
|
|
placeholder="teammate@example.com"
|
|
disabled={inviting}
|
|
/>
|
|
</div>
|
|
<div className="space-y-1.5">
|
|
<Label htmlFor="invite-role">Role</Label>
|
|
<Select
|
|
id="invite-role"
|
|
value={role}
|
|
onChange={(e) =>
|
|
setRole(e.target.value as AssignableWorkspaceRole)
|
|
}
|
|
disabled={inviting}
|
|
>
|
|
{ASSIGNABLE_WORKSPACE_ROLES.map((r) => (
|
|
<option key={r} value={r}>
|
|
{roleLabel(r)}
|
|
</option>
|
|
))}
|
|
</Select>
|
|
</div>
|
|
<Button type="submit" disabled={!canSubmit}>
|
|
<UserPlus className="size-4" aria-hidden />
|
|
{inviting ? "Inviting…" : "Invite"}
|
|
</Button>
|
|
</div>
|
|
{inviteError && (
|
|
<p className="text-sm text-destructive" role="alert">
|
|
{inviteError}
|
|
</p>
|
|
)}
|
|
</form>
|
|
);
|
|
}
|