From a96aa6216be0f9a309e0bfe1c2a682425a919a2f Mon Sep 17 00:00:00 2001 From: Rohitha Pudu Date: Fri, 17 May 2024 16:09:40 +0530 Subject: [PATCH] add toast notifications in signup --- frontend/src/app/signup/page.tsx | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/frontend/src/app/signup/page.tsx b/frontend/src/app/signup/page.tsx index f274718..8b4aa70 100644 --- a/frontend/src/app/signup/page.tsx +++ b/frontend/src/app/signup/page.tsx @@ -4,6 +4,8 @@ import Link from "next/link"; import axios from "axios"; import { useDataContext } from "@/context/dataContext"; import { redirect, useRouter } from "next/navigation"; +import { toast, ToastContainer } from "react-toastify"; +import 'react-toastify/dist/ReactToastify.css'; export default function Signup() { const router = useRouter(); @@ -11,6 +13,18 @@ export default function Signup() { return ( <> + {(authState === "loading" || authState === "notloggedin") && ( )} @@ -30,14 +44,17 @@ function SignupInner() { e.preventDefault(); if (email.length == 0) { setError("*Email can't be empty"); + toast.error("*Email can't be empty"); return; } if (username.length == 0) { setError("*username can't be empty"); + toast.error("*Username can't be empty"); return; } if (password.length == 0) { setError("*Password can't be empty"); + toast.error("*Password can't be empty"); return; } setSigningUp(true); @@ -51,9 +68,11 @@ function SignupInner() { } ); setSigningUp(false); + toast.success("Signup successful!"); router.push("/login"); } catch (error) { setSigningUp(false); + toast.error((error as Error).message); setError((error as Error).message); } };