"use client"; import React from "react"; import { Loader2 } from "lucide-react"; import { normalizeBranchIdDraft } from "@/components/admin/users/usersUi"; import { CREATE_ROLE_OPTIONS } from "@/components/admin/users/create-user/createUserUtils"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { Alert, AlertTitle, AlertDescription } from "@/components/ui/alert"; import { DialogFooter } from "@/components/ui/dialog"; import { DropdownMenu, DropdownMenuContent, DropdownMenuLabel, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu"; function RoleSelect({ value, onChange, disabled }) { const label = CREATE_ROLE_OPTIONS.find((x) => x.value === value)?.label || "Rolle wählen"; return (
Rolle auswählen {CREATE_ROLE_OPTIONS.map((opt) => ( {opt.label} ))}
); } export default function CreateUserForm({ form, setPatch, error, policyLines, disabled, isSubmitting, onCancel, onSubmit, }) { const role = String(form?.role || "branch"); return (
{error ? ( {error.title} {error.description ? ( {error.description} ) : null} {Array.isArray(error.hints) && error.hints.length > 0 ? (
    {error.hints.map((line) => (
  • {line}
  • ))}
) : null}
) : null}
setPatch({ username: e.target.value })} disabled={disabled} autoCapitalize="none" autoCorrect="off" spellCheck={false} placeholder="z. B. branchuser" />
setPatch({ email: e.target.value })} disabled={disabled} placeholder="name@firma.de" />
setPatch({ role: v })} disabled={disabled} /> {role === "branch" ? (
setPatch({ branchId: e.target.value })} disabled={disabled} placeholder="z. B. NL01" />
) : (
)}
{/* Keep branchId normalized as user types (optional UX polish) */} {role === "branch" ? (
Aktuell: {normalizeBranchIdDraft(form?.branchId || "") || "—"}
) : null}
setPatch({ initialPassword: e.target.value })} disabled={disabled} placeholder="••••••••" />
); }