Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 27 additions & 19 deletions frontend/components/signupform.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,28 +27,36 @@ export default function SignupForm() {
const onSubmit = async (data: SignupFormData) => {
setServerError(null);
const toastId = toast.loading("Creating account...");
let userCredential;
try {
const userCredential = await createUserWithEmailAndPassword(auth, data.email, data.password);

// Update the user's profile with their name
await updateProfile(userCredential.user, {
displayName: data.name
});

toast.dismiss(toastId);
toast.success("Account Created!", {
description: "Welcome to InnerHue.",
});

router.push("/");
userCredential = await createUserWithEmailAndPassword(
auth,
data.email,
data.password
);
} catch (error: unknown) {
const message = error instanceof Error ? error.message : "Something went wrong.";
toast.dismiss(toastId);
setServerError(message);
toast.error("Signup failed", {
description: message,
});
const message =
error instanceof Error ? error.message : "Something went wrong." ;
toast.dismiss(toastId);
setServerError(message) ;
toast.error("Signup failed", {
description: message,
});
return ;// stop here — don't try updateProfile if account creation failed
}
try {
await updateProfile(userCredential.user, {
displayName: data.name,
});
} catch (profileError) {
console.error("Failed to set display name:", profileError) ;
}

toast.dismiss(toastId);
toast.success("Account Created!", {
description: "Welcome to InnerHue.",
});
router.push("/");
};

return (
Expand Down
Loading