Fix user editing and email field consistency across the platform

Update handleEditUser to prioritize firstName/lastName over the name field for user editing, and make the email field consistently optional in both create and edit forms.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: a8a78c07-e900-425c-a577-5b4c5894379d
Replit-Commit-Checkpoint-Type: full_checkpoint
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/1957c339-2757-4d1f-8e92-e9f71a1ce58e/a8a78c07-e900-425c-a577-5b4c5894379d/vetH0Gp
This commit is contained in:
michaelschal committed 2025-08-11 18:35:13 +00:00
1 parent a3b457f990
commit 1e72358c6c
4 files changed
+231 -4

No files matched your search

+10 -3
View File
@@ -455,9 +455,16 @@ export default function UsersPage() {
};
const handleEditUser = (userData: UserWithGroups) => {
// Convert the single 'name' field to firstName/lastName
const [firstName = '', ...lastNameParts] = (userData.name || '').split(' ');
const lastName = lastNameParts.join(' ');
// Priority: use firstName/lastName if available, fallback to splitting 'name' field
let firstName = userData.firstName || '';
let lastName = userData.lastName || '';
// If no firstName/lastName but we have a 'name' field, try to split it
if (!firstName && !lastName && userData.name) {
const [firstPart = '', ...lastNameParts] = userData.name.split(' ');
firstName = firstPart;
lastName = lastNameParts.join(' ');
}
const userWithNames = {
...userData,