// "Mitglied hinzufügen" as a popup on the Mitarbeiter tab, replacing the // separate sub-page. The sub-page existed because the hub's members tab is an // index route and can carry no children, so the tab's Dialog outlet never // received the form — posting the create contract with a fetcher sidesteps the // routing constraint entirely and keeps settings/team/members/new as the action. // // Presentational: the route owns the fetcher. Field contract unchanged // (email / first-name / last-name / send-invitation-email + csrf). // // Role-at-invite from David's wireframe is still NOT built: the invitation // backend stores no role — roles are assigned in the list (D01) after acceptance. import { useEffect, useState } from "react"; import { useTranslation } from "react-i18next"; import { FeatherPlus } from "@subframe/core"; import type { PlanFeatureUsageDto } from "~/application/dtos/subscriptions/PlanFeatureUsageDto"; import { Alert } from "~/ui/components/Alert"; import { Button } from "~/ui/components/Button"; import { Checkbox } from "~/ui/components/Checkbox"; import { TextInput } from "~/ui/components/TextInput"; import { FormDialog } from "../shared/FormDialog"; export type InviteMemberInput = { email: string; firstName: string; lastName: string; sendInvitationEmail: boolean; }; export function InviteMemberDialog({ open, onOpenChange, featurePlanUsage, submitting, errorMessage, onInvite, }: { open: boolean; onOpenChange: (open: boolean) => void; /** Seat limit of the plan; when exhausted the form is replaced by the upgrade hint. */ featurePlanUsage: PlanFeatureUsageDto | undefined; submitting: boolean; errorMessage: string | null; onInvite: (input: InviteMemberInput) => void; }): React.JSX.Element { const { t } = useTranslation(); const [email, setEmail] = useState(""); const [firstName, setFirstName] = useState(""); const [lastName, setLastName] = useState(""); const [sendEmail, setSendEmail] = useState(false); // Fresh fields on every open; the dialog stays mounted between invites. useEffect(() => { if (!open) return; setEmail(""); setFirstName(""); setLastName(""); setSendEmail(false); }, [open]); const seatsExhausted = Boolean(featurePlanUsage && !featurePlanUsage.enabled); const canSubmit = !seatsExhausted && email.trim().length > 0 && firstName.trim().length > 0; return ( } > {seatsExhausted ? ( ) : null} {errorMessage ? : null} setEmail(event.target.value)} required autoFocus autoComplete="off" disabled={seatsExhausted} />
setFirstName(event.target.value)} required autoComplete="off" disabled={seatsExhausted} /> setLastName(event.target.value)} autoComplete="off" disabled={seatsExhausted} />
{/* w-fit, because the kit checkbox is justify-between and would otherwise stretch across the dialog and strand its label at the far edge. */}
); }