Skip to content

Commit

Permalink
fixed error on updating user, and form errors on manual singup (#1061)
Browse files Browse the repository at this point in the history
  • Loading branch information
MadsNyl authored Aug 15, 2024
1 parent 0952bb3 commit 12fd0c7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const UserSettings = ({ isAdmin, user }: UserSettingsProps) => {

const form = useForm<z.infer<typeof formSchema>>({
resolver: zodResolver(formSchema),
defaultValues: { ...user, gender: user.gender.toString() },
defaultValues: { ...user, image: user.image || '', gender: user.gender.toString() },
});

const onSubmit = (values: z.infer<typeof formSchema>) => {
Expand Down
9 changes: 8 additions & 1 deletion src/pages/SignUp/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,14 @@ const SignUp = () => {
navigate(redirectURL || URLS.login);
},
onError: (e) => {
toast.error(e.detail);
Object.keys(e.detail).forEach((key: string) => {
if (key in userData) {
const errorKey = key as keyof UserCreate;
const errorMessage = (e.detail as unknown as Record<string, any>)[key];

Check warning on line 90 in src/pages/SignUp/index.tsx

View workflow job for this annotation

GitHub Actions / build (18.x)

Unexpected any. Specify a different type

Check warning on line 90 in src/pages/SignUp/index.tsx

View workflow job for this annotation

GitHub Actions / build (18.x)

Unexpected any. Specify a different type
form.setError(errorKey, { message: errorMessage });
}
});
toast.error('Det er en eller flere feil i skjemaet');
},
});
};
Expand Down

0 comments on commit 12fd0c7

Please sign in to comment.