// "Gruppe erstellen" as a popup on the Gruppen tab, replacing the slide-over // sub-page that still wore the old boilerplate form controls (FormGroup, // InputText, InputSelector). Same chrome as every other form popup (FormDialog) // and the same ~/ui controls the rest of the settings screens use. // // Presentational: the route owns the fetcher and posts the unchanged create // contract of settings/team/groups/new (action=create, name, description, // color, users[]). import { useState } from "react"; import { useTranslation } from "react-i18next"; import { FeatherPlus } from "@subframe/core"; import ColorBadge from "~/components/ui/badges/ColorBadge"; import { Colors } from "~/application/enums/shared/Colors"; import { getColors } from "~/utils/shared/ColorUtils"; import { Button } from "~/ui/components/Button"; import { Checkbox } from "~/ui/components/Checkbox"; import { Select } from "~/ui/components/Select"; import { TextArea } from "~/ui/components/TextArea"; import { TextInput } from "~/ui/components/TextInput"; import { FormDialog } from "../shared/FormDialog"; export type GroupCandidateUser = { userId: string; name: string; email: string; }; export type GroupNewInput = { name: string; description: string; color: number; userIds: string[]; }; /** Colour is a required column on the group; the slide-over let it post NaN. */ const DEFAULT_COLOR = Colors.BLUE; export function GroupNewDialog({ open, onOpenChange, candidates, submitting, onCreate, }: { open: boolean; onOpenChange: (open: boolean) => void; candidates: readonly GroupCandidateUser[]; submitting: boolean; onCreate: (input: GroupNewInput) => void; }): React.JSX.Element { const { t } = useTranslation(); const [name, setName] = useState(""); const [description, setDescription] = useState(""); const [color, setColor] = useState(DEFAULT_COLOR); const [userIds, setUserIds] = useState>(new Set()); function toggleUser(userId: string, checked: boolean) { setUserIds((prev) => { const next = new Set(prev); if (checked) next.add(userId); else next.delete(userId); return next; }); } return ( } > setName(event.target.value)} required autoFocus autoComplete="off" />
{t("models.user.plural")} {candidates.length === 0 ? ( {t("settings.members.groups.noCandidates")} ) : ( candidates.map((candidate) => ( toggleUser(candidate.userId, checked)} /> )) )}
); }