Skip to content

Commit 41d5044

Browse files
committed
[TOOL-3328] Dashboard: Show error message in toast on Email submission fail in onboaridng flow (#6186)
<!-- start pr-codex --> ## PR-Codex overview This PR enhances error handling in the `AccountForm` component by improving the way errors are processed and displayed to the user. ### Detailed summary - Replaced the `onError` parameter's type from `Error` to a more generic `error`. - Added console logging for errors. - Implemented specific error handling for duplicate email and invalid email address cases. - Integrated `toast` notifications for user-friendly error messages. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex -->
1 parent a8ac98b commit 41d5044

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)