Skip to content

Commit 2e54f78

Browse files
committed
[TOOL-3328] Dashboard: Show error message in toast on Email submission fail in onboaridng flow (#6186)
1 parent 1f6bb7c commit 2e54f78

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

apps/dashboard/src/app/login/onboarding/AccountForm.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { zodResolver } from "@hookform/resolvers/zod";
88
import { useTrack } from "hooks/analytics/useTrack";
99
import { useState } from "react";
1010
import { useForm } from "react-hook-form";
11+
import { toast } from "sonner";
1112
import {
1213
type AccountValidationSchema,
1314
accountValidationSchema,
@@ -81,15 +82,21 @@ export const AccountForm: React.FC<AccountFormProps> = ({
8182
data,
8283
});
8384
},
84-
onError: (err) => {
85-
const error = err as Error;
85+
onError: (error) => {
86+
console.error(error);
8687

8788
if (
8889
onDuplicateError &&
8990
error?.message.match(/email address already exists/)
9091
) {
9192
onDuplicateError(values.email);
93+
return;
94+
} else if (error.message.includes("INVALID_EMAIL_ADDRESS")) {
95+
toast.error("Invalid Email Address");
96+
} else {
97+
toast.error(error.message || "Failed to update account");
9298
}
99+
93100
trackEvent({
94101
category: "account",
95102
action: "update",

0 commit comments

Comments
 (0)