From e887d8a11c0fc6fcce69496cda22ad4c4e0fdc62 Mon Sep 17 00:00:00 2001 From: michaelschal <35957947-michaelschal@users.noreply.replit.com> Date: Mon, 11 Aug 2025 18:45:39 +0000 Subject: [PATCH] Allow clearing user name and email fields through the interface Update frontend and backend to permit empty strings for firstName, lastName, and email fields when updating user data, addressing an issue where clearing these fields was not persisted. 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 --- client/src/pages/Users.tsx | 5 ++++- server/routes.ts | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/client/src/pages/Users.tsx b/client/src/pages/Users.tsx index 91ecfe7..0fa0654 100644 --- a/client/src/pages/Users.tsx +++ b/client/src/pages/Users.tsx @@ -147,7 +147,10 @@ export default function UsersPage() { // Nettoyer les données côté frontend avant envoi const cleanedUpdates = {}; for (const [key, value] of Object.entries(data.updates)) { - if (value !== undefined && value !== null && value !== '') { + // For name fields (firstName, lastName, email), allow empty strings to clear the fields + if (key === 'firstName' || key === 'lastName' || key === 'email') { + cleanedUpdates[key] = value || ''; + } else if (value !== undefined && value !== null && value !== '') { cleanedUpdates[key] = value; } } diff --git a/server/routes.ts b/server/routes.ts index f03f7ce..b8214f9 100644 --- a/server/routes.ts +++ b/server/routes.ts @@ -935,8 +935,8 @@ export async function registerRoutes(app: Express): Promise { const updateUserSchema = z.object({ username: z.string().optional(), role: z.enum(['admin', 'manager', 'employee']).optional(), - firstName: z.string().optional(), - lastName: z.string().optional(), + firstName: z.union([z.string(), z.literal("")]).optional(), + lastName: z.union([z.string(), z.literal("")]).optional(), email: z.union([z.string().email(), z.literal("")]).optional(), password: z.string().optional(), });