Skip to content

Commit 0ad0bca

Browse files
committed
Add toast message for email verification
1 parent b5e3f9a commit 0ad0bca

File tree

7 files changed

+14
-13
lines changed

7 files changed

+14
-13
lines changed

frontend/src/App.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ import Matching from "./pages/Matching";
1717
import Layout from "./components/Layout";
1818
import AuthProvider from "./contexts/AuthContext";
1919
import ProfileContextProvider from "./contexts/ProfileContext";
20+
import { ToastContainer } from "react-toastify";
21+
import "react-toastify/dist/ReactToastify.css";
2022

2123
function App() {
2224
return (
@@ -53,6 +55,7 @@ function App() {
5355
<Route path="signup" element={<SignUp />} />
5456
<Route path="login" element={<LogIn />} />
5557
</Routes>
58+
<ToastContainer position="bottom-right" />
5659
</AuthProvider>
5760
);
5861
}

frontend/src/components/Layout/index.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import { Box } from "@mui/material";
22
import { Outlet } from "react-router-dom";
33
import Navbar from "../Navbar";
4-
import { ToastContainer } from "react-toastify";
5-
import "react-toastify/dist/ReactToastify.css";
64

75
const Layout: React.FC = () => {
86
return (
@@ -17,7 +15,6 @@ const Layout: React.FC = () => {
1715
>
1816
<Navbar />
1917
<Outlet />
20-
<ToastContainer position="bottom-right" />
2118
</Box>
2219
);
2320
};

frontend/src/contexts/AuthContext.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { userClient } from "../utils/api";
55
import { useNavigate } from "react-router-dom";
66
import { toast } from "react-toastify";
77
import Loader from "../components/Loader";
8-
import { SUCCESS_LOG_OUT } from "../utils/constants";
8+
import { SUCCESS_LOG_OUT, SUCCESSFUL_SIGNUP } from "../utils/constants";
99

1010
type User = {
1111
id: string;
@@ -75,7 +75,10 @@ const AuthProvider: React.FC<{ children?: React.ReactNode }> = (props) => {
7575
email: email,
7676
password: password,
7777
})
78-
.then(() => login(email, password))
78+
.then(() => {
79+
login(email, password);
80+
toast.success(SUCCESSFUL_SIGNUP);
81+
})
7982
.catch((err) => {
8083
setUser(null);
8184
toast.error(err.response?.data.message || err.message);
@@ -112,7 +115,9 @@ const AuthProvider: React.FC<{ children?: React.ReactNode }> = (props) => {
112115
}
113116

114117
return (
115-
<AuthContext.Provider value={{ signup, login, logout, user, setUser, loading }}>
118+
<AuthContext.Provider
119+
value={{ signup, login, logout, user, setUser, loading }}
120+
>
116121
{children}
117122
</AuthContext.Provider>
118123
);

frontend/src/pages/Home/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111

1212
import classes from "./index.module.css";
1313
import AppMargin from "../../components/AppMargin";
14+
1415
// import {
1516
// complexityList,
1617
// languageList,
@@ -52,7 +53,6 @@ const Home: React.FC = () => {
5253
>
5354
Start an interactive practice session today!
5455
</Typography>
55-
5656
<Typography
5757
variant="subtitle1"
5858
textAlign={"center"}

frontend/src/pages/LogIn/index.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ import LogInSvg from "../../assets/login.svg?react";
1111
import { useNavigate } from "react-router-dom";
1212
import { useAuth } from "../../contexts/AuthContext";
1313
import { emailValidator } from "../../utils/validators";
14-
import { ToastContainer } from "react-toastify";
15-
import "react-toastify/dist/ReactToastify.css";
1614
import { useForm } from "react-hook-form";
1715
import PasswordTextField from "../../components/PasswordTextField";
1816
import {
@@ -154,7 +152,6 @@ const LogIn: React.FC = () => {
154152
>
155153
<LogInSvg width="80%" height="80%" />
156154
</Box>
157-
<ToastContainer position="bottom-right" />
158155
</Box>
159156
);
160157
};

frontend/src/pages/SignUp/index.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ import {
88
passwordValidator,
99
usernameValidator,
1010
} from "../../utils/validators";
11-
import { ToastContainer } from "react-toastify";
12-
import "react-toastify/dist/ReactToastify.css";
1311
import { useForm } from "react-hook-form";
1412
import PasswordTextField from "../../components/PasswordTextField";
1513
import {
@@ -191,7 +189,6 @@ const SignUp: React.FC = () => {
191189
>
192190
<SignUpSvg width="80%" height="80%" />
193191
</Box>
194-
<ToastContainer position="bottom-right" />
195192
</Box>
196193
);
197194
};

frontend/src/utils/constants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ export const PASSWORD_MISMATCH_ERROR_MESSAGE = "Password does not match";
5151
/* Toast Messages */
5252
// Authentication
5353
export const SUCCESS_LOG_OUT = "Logged out successfully!";
54+
export const SUCCESSFUL_SIGNUP =
55+
"User created successfully. Please verify your email address.";
5456

5557
// Field Validation
5658
export const FILL_ALL_FIELDS = "Please fill in all fields";

0 commit comments

Comments
 (0)