Skip to content

Commit 16826a7

Browse files
fix: remove password fields from Edit User dialog
Co-Authored-By: daniel.resgate <daniel.rider69@gmail.com>
1 parent 8e155b7 commit 16826a7

File tree

1 file changed

+7
-58
lines changed

1 file changed

+7
-58
lines changed

frontend/src/components/Admin/EditUser.tsx

Lines changed: 7 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -40,23 +40,12 @@ import { handleError } from "@/utils"
4040

4141
const roleOptions: UserRole[] = ['comercial', 'juridico', 'financeiro', 'rh', 'pj', 'super_admin']
4242

43-
const formSchema = z
44-
.object({
45-
email: z.email({ message: "Invalid email address" }),
46-
full_name: z.string().optional(),
47-
role: z.enum(['comercial', 'juridico', 'financeiro', 'rh', 'pj', 'super_admin']),
48-
is_active: z.boolean().optional(),
49-
password: z
50-
.string()
51-
.min(8, { message: "Password must be at least 8 characters" })
52-
.optional()
53-
.or(z.literal("")),
54-
confirm_password: z.string().optional(),
55-
})
56-
.refine((data) => !data.password || data.password === data.confirm_password, {
57-
message: "The passwords don't match",
58-
path: ["confirm_password"],
59-
})
43+
const formSchema = z.object({
44+
email: z.email({ message: "Invalid email address" }),
45+
full_name: z.string().optional(),
46+
role: z.enum(['comercial', 'juridico', 'financeiro', 'rh', 'pj', 'super_admin']),
47+
is_active: z.boolean().optional(),
48+
})
6049

6150
type FormData = z.infer<typeof formSchema>
6251

@@ -97,12 +86,7 @@ const EditUser = ({ user, onSuccess }: EditUserProps) => {
9786
})
9887

9988
const onSubmit = (data: FormData) => {
100-
// exclude confirm_password from submission data and remove password if empty
101-
const { confirm_password: _, ...submitData } = data
102-
if (!submitData.password) {
103-
delete submitData.password
104-
}
105-
mutation.mutate(submitData)
89+
mutation.mutate(data)
10690
}
10791

10892
return (
@@ -205,41 +189,6 @@ const EditUser = ({ user, onSuccess }: EditUserProps) => {
205189
)}
206190
/>
207191

208-
<FormField
209-
control={form.control}
210-
name="password"
211-
render={({ field }) => (
212-
<FormItem>
213-
<FormLabel>Set Password</FormLabel>
214-
<FormControl>
215-
<Input
216-
placeholder="Password"
217-
type="password"
218-
{...field}
219-
/>
220-
</FormControl>
221-
<FormMessage />
222-
</FormItem>
223-
)}
224-
/>
225-
226-
<FormField
227-
control={form.control}
228-
name="confirm_password"
229-
render={({ field }) => (
230-
<FormItem>
231-
<FormLabel>Confirm Password</FormLabel>
232-
<FormControl>
233-
<Input
234-
placeholder="Password"
235-
type="password"
236-
{...field}
237-
/>
238-
</FormControl>
239-
<FormMessage />
240-
</FormItem>
241-
)}
242-
/>
243192
</div>
244193

245194
<DialogFooter>

0 commit comments

Comments
 (0)