"use client"; import React from "react"; import { Loader2 } from "lucide-react"; import BranchNumberInput from "@/components/admin/users/BranchNumberInput"; 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, branchesStatus, branchExistence, disabled, isSubmitting, canSubmit, onCancel, onSubmit, }) { const role = String(form?.role || "branch"); const branchMessageId = "cu-branch-message"; const showUnknownBranch = role === "branch" && Boolean(branchExistence?.hasUnknownBranch); const showFailOpenNote = role === "branch" && Boolean(branchExistence?.listError); const showBranchLoading = role === "branch" && !showUnknownBranch && branchesStatus === "loading"; 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 })} disabled={disabled} invalid={showUnknownBranch} describedBy={showUnknownBranch ? branchMessageId : undefined} /> {showUnknownBranch ? (

Diese Niederlassung ist nicht in der aktuellen Liste vorhanden.

) : null} {showFailOpenNote ? (

Hinweis: Die Niederlassungsliste konnte nicht geladen werden. Die Existenz kann aktuell nicht geprüft werden.

) : null} {showBranchLoading ? (

Niederlassungsliste wird geladen…

) : null}
) : (
)}
setPatch({ initialPassword: e.target.value })} disabled={disabled} placeholder="••••••••" />
); }