// --------------------------------------------------------------------------- // Ordner: components/admin/users/edit-user // Datei: EditUserForm.jsx // Relativer Pfad: components/admin/users/edit-user/EditUserForm.jsx // --------------------------------------------------------------------------- "use client"; import React from "react"; import { Loader2 } from "lucide-react"; import { normalizeBranchIdDraft } from "@/components/admin/users/usersUi"; import { EDIT_ROLE_OPTIONS } from "@/components/admin/users/edit-user/editUserUtils"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { Checkbox } from "@/components/ui/checkbox"; 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 = EDIT_ROLE_OPTIONS.find((x) => x.value === value)?.label || "Rolle wählen"; return (
Rolle auswählen {EDIT_ROLE_OPTIONS.map((opt) => ( {opt.label} ))}
); } export default function EditUserForm({ user, form, setPatch, error, disabled, isSubmitting, canSubmit, onCancel, onSubmit, }) { const role = String(form?.role || "branch"); const userId = String(user?.id || ""); 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" />
) : (
)}
{role === "branch" ? (
Aktuell: {normalizeBranchIdDraft(form?.branchId || "") || "—"}
) : null}
{ setPatch({ mustChangePassword: Boolean(v) }); }} />

Passwortwechsel erforderlich

Wenn aktiviert, muss der Benutzer beim nächsten Login sein Passwort ändern.

); }