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(), });