├── .env.example ├── .gitignore ├── README.md ├── package-lock.json ├── package.json ├── public ├── favicon.ico ├── index.html ├── logo192.png ├── logo512.png ├── manifest.json └── robots.txt └── src ├── App.js ├── assets ├── avatarr.png ├── loader.gif └── login.svg ├── components ├── card │ ├── Card.js │ └── Card.module.scss ├── changeRole │ └── ChangeRole.js ├── footer │ └── Footer.js ├── header │ ├── Header.js │ └── Header.scss ├── infoBox │ ├── InfoBox.js │ └── InfoBox.scss ├── layout │ └── Layout.js ├── loader │ ├── Loader.js │ └── Loader.scss ├── notification │ ├── Notification.js │ └── Notification.scss ├── pageMenu │ └── PageMenu.js ├── passwordInput │ ├── PasswordInput.js │ └── PasswordInput.scss ├── protect │ └── hiddenLink.js ├── search │ ├── Search.js │ └── Search.module.scss └── userStats │ ├── UserStats.js │ └── UsersStats.scss ├── customHook └── useRedirectLoggedOutUser.js ├── index.css ├── index.js ├── pages ├── auth │ ├── Forgot.js │ ├── Login.js │ ├── LoginWithCode.js │ ├── Register.js │ ├── Reset.js │ ├── Verify.js │ └── auth.module.scss ├── changePassword │ ├── ChangePassword.js │ └── ChangePassword.scss ├── home │ ├── Home.js │ └── Home.scss ├── profile │ ├── Profile.js │ └── Profile.scss └── userList │ ├── UserList.js │ └── UserList.scss └── redux ├── features ├── auth │ ├── authService.js │ ├── authSlice.js │ └── filterSlice.js └── email │ ├── emailService.js │ └── emailSlice.js └── store.js /.env.example: -------------------------------------------------------------------------------- 1 | REACT_APP_BACKEND_URL=http://localhost:5000 2 | REACT_APP_CLOUD_NAME=zinotrust 3 | REACT_APP_UPLOAD_PRESET=sdfvdfgdvd 4 | REACT_APP_GOOGLE_CLIENT_ID=149927346748-tbjbdk61ukaipkflo28g91cokrsrnm64.apps.googleusercontent.com 5 | REACT_APP_GOOGLE_CLIENT_SECRET=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 6 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | .env 8 | 9 | # testing 10 | /coverage 11 | 12 | # production 13 | /build 14 | 15 | # misc 16 | .DS_Store 17 | .env.local 18 | .env.development.local 19 | .env.test.local 20 | .env.production.local 21 | 22 | npm-debug.log* 23 | yarn-debug.log* 24 | yarn-error.log* 25 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Getting Started with Create React App 2 | 3 | This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). 4 | 5 | ## Available Scripts 6 | 7 | In the project directory, you can run: 8 | 9 | ### `npm start` 10 | 11 | Runs the app in the development mode.\ 12 | Open [http://localhost:3000](http://localhost:3000) to view it in your browser. 13 | 14 | The page will reload when you make changes.\ 15 | You may also see any lint errors in the console. 16 | 17 | ### `npm test` 18 | 19 | Launches the test runner in the interactive watch mode.\ 20 | See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. 21 | 22 | ### `npm run build` 23 | 24 | Builds the app for production to the `build` folder.\ 25 | It correctly bundles React in production mode and optimizes the build for the best performance. 26 | 27 | The build is minified and the filenames include the hashes.\ 28 | Your app is ready to be deployed! 29 | 30 | See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. 31 | 32 | ### `npm run eject` 33 | 34 | **Note: this is a one-way operation. Once you `eject`, you can't go back!** 35 | 36 | If you aren't satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. 37 | 38 | Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you're on your own. 39 | 40 | You don't have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn't feel obligated to use this feature. However we understand that this tool wouldn't be useful if you couldn't customize it when you are ready for it. 41 | 42 | ## Learn More 43 | 44 | You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). 45 | 46 | To learn React, check out the [React documentation](https://reactjs.org/). 47 | 48 | ### Code Splitting 49 | 50 | This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting) 51 | 52 | ### Analyzing the Bundle Size 53 | 54 | This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size) 55 | 56 | ### Making a Progressive Web App 57 | 58 | This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app) 59 | 60 | ### Advanced Configuration 61 | 62 | This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration) 63 | 64 | ### Deployment 65 | 66 | This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment) 67 | 68 | ### `npm run build` fails to minify 69 | 70 | This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify) 71 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "frontend", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "@react-oauth/google": "^0.5.0", 7 | "@reduxjs/toolkit": "^1.9.0", 8 | "@testing-library/jest-dom": "^5.16.5", 9 | "@testing-library/react": "^13.4.0", 10 | "@testing-library/user-event": "^13.5.0", 11 | "axios": "^1.1.3", 12 | "node-sass": "^7.0.3", 13 | "react": "^18.2.0", 14 | "react-confirm-alert": "^3.0.6", 15 | "react-dom": "^18.2.0", 16 | "react-icons": "^4.6.0", 17 | "react-paginate": "^8.1.4", 18 | "react-redux": "^8.0.5", 19 | "react-router-dom": "^6.4.3", 20 | "react-scripts": "5.0.1", 21 | "react-toastify": "^9.1.1", 22 | "web-vitals": "^2.1.4" 23 | }, 24 | "scripts": { 25 | "start": "react-scripts start", 26 | "build": "react-scripts build", 27 | "test": "react-scripts test", 28 | "eject": "react-scripts eject" 29 | }, 30 | "eslintConfig": { 31 | "extends": [ 32 | "react-app", 33 | "react-app/jest" 34 | ] 35 | }, 36 | "browserslist": { 37 | "production": [ 38 | ">0.2%", 39 | "not dead", 40 | "not op_mini all" 41 | ], 42 | "development": [ 43 | "last 1 chrome version", 44 | "last 1 firefox version", 45 | "last 1 safari version" 46 | ] 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zinotrust/mern-auth-frontend/54798b75b25e27d4b3f69b970cc1c847bfc00e7a/public/favicon.ico -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | 13 | 14 | 15 | React App 16 | 17 | 18 | 19 |
20 |
21 | 22 | 23 | -------------------------------------------------------------------------------- /public/logo192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zinotrust/mern-auth-frontend/54798b75b25e27d4b3f69b970cc1c847bfc00e7a/public/logo192.png -------------------------------------------------------------------------------- /public/logo512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zinotrust/mern-auth-frontend/54798b75b25e27d4b3f69b970cc1c847bfc00e7a/public/logo512.png -------------------------------------------------------------------------------- /public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | }, 10 | { 11 | "src": "logo192.png", 12 | "type": "image/png", 13 | "sizes": "192x192" 14 | }, 15 | { 16 | "src": "logo512.png", 17 | "type": "image/png", 18 | "sizes": "512x512" 19 | } 20 | ], 21 | "start_url": ".", 22 | "display": "standalone", 23 | "theme_color": "#000000", 24 | "background_color": "#ffffff" 25 | } 26 | -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /src/App.js: -------------------------------------------------------------------------------- 1 | import { BrowserRouter, Routes, Route } from "react-router-dom"; 2 | import Layout from "./components/layout/Layout"; 3 | 4 | import Forgot from "./pages/auth/Forgot"; 5 | import Login from "./pages/auth/Login"; 6 | import LoginWithCode from "./pages/auth/LoginWithCode"; 7 | import Register from "./pages/auth/Register"; 8 | import Reset from "./pages/auth/Reset"; 9 | import Verify from "./pages/auth/Verify"; 10 | import ChangePassword from "./pages/changePassword/ChangePassword"; 11 | import Home from "./pages/home/Home"; 12 | import Profile from "./pages/profile/Profile"; 13 | import UserList from "./pages/userList/UserList"; 14 | import axios from "axios"; 15 | import { ToastContainer } from "react-toastify"; 16 | import "react-toastify/dist/ReactToastify.css"; 17 | import { useEffect } from "react"; 18 | import { useDispatch, useSelector } from "react-redux"; 19 | import { 20 | getLoginStatus, 21 | getUser, 22 | selectIsLoggedIn, 23 | selectUser, 24 | } from "./redux/features/auth/authSlice"; 25 | import { GoogleOAuthProvider } from "@react-oauth/google"; 26 | 27 | axios.defaults.withCredentials = true; 28 | 29 | function App() { 30 | const dispatch = useDispatch(); 31 | const isLoggedIn = useSelector(selectIsLoggedIn); 32 | const user = useSelector(selectUser); 33 | 34 | useEffect(() => { 35 | dispatch(getLoginStatus()); 36 | if (isLoggedIn && user === null) { 37 | dispatch(getUser()); 38 | } 39 | }, [dispatch, isLoggedIn, user]); 40 | 41 | return ( 42 | <> 43 | 44 | 45 | 46 | 47 | 51 | 52 | 53 | } 54 | /> 55 | } /> 56 | } /> 57 | } /> 58 | } /> 59 | } /> 60 | 61 | 65 | 66 | 67 | } 68 | /> 69 | 73 | 74 | 75 | } 76 | /> 77 | 81 | 82 | 83 | } 84 | /> 85 | 89 | 90 | 91 | } 92 | /> 93 | 94 | 95 | 96 | 97 | ); 98 | } 99 | 100 | export default App; 101 | -------------------------------------------------------------------------------- /src/assets/avatarr.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zinotrust/mern-auth-frontend/54798b75b25e27d4b3f69b970cc1c847bfc00e7a/src/assets/avatarr.png -------------------------------------------------------------------------------- /src/assets/loader.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zinotrust/mern-auth-frontend/54798b75b25e27d4b3f69b970cc1c847bfc00e7a/src/assets/loader.gif -------------------------------------------------------------------------------- /src/assets/login.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/components/card/Card.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import styles from "./Card.module.scss"; 3 | 4 | const Card = ({ children, cardClass }) => { 5 | return
{children}
; 6 | }; 7 | 8 | export default Card; 9 | -------------------------------------------------------------------------------- /src/components/card/Card.module.scss: -------------------------------------------------------------------------------- 1 | .card { 2 | border: 1px solid transparent; 3 | border-radius: 5px; 4 | box-shadow: var(--box-shadow); 5 | overflow: hidden; 6 | } 7 | -------------------------------------------------------------------------------- /src/components/changeRole/ChangeRole.js: -------------------------------------------------------------------------------- 1 | import React, { useState } from "react"; 2 | import { FaCheck } from "react-icons/fa"; 3 | import { useDispatch } from "react-redux"; 4 | import { toast } from "react-toastify"; 5 | import { getUsers, upgradeUser } from "../../redux/features/auth/authSlice"; 6 | import { 7 | EMAIL_RESET, 8 | sendAutomatedEmail, 9 | } from "../../redux/features/email/emailSlice"; 10 | 11 | const ChangeRole = ({ _id, email }) => { 12 | const [userRole, setUserRole] = useState(""); 13 | const dispatch = useDispatch(); 14 | 15 | // Change User role 16 | const changeRole = async (e) => { 17 | e.preventDefault(); 18 | 19 | if (!userRole) { 20 | toast.error("Please select a role"); 21 | } 22 | 23 | const userData = { 24 | role: userRole, 25 | id: _id, 26 | }; 27 | 28 | const emailData = { 29 | subject: "Account Role Changed - AUTH:Z", 30 | send_to: email, 31 | reply_to: "noreply@zino", 32 | template: "changeRole", 33 | url: "/login", 34 | }; 35 | 36 | await dispatch(upgradeUser(userData)); 37 | await dispatch(sendAutomatedEmail(emailData)); 38 | await dispatch(getUsers()); 39 | dispatch(EMAIL_RESET()); 40 | }; 41 | 42 | return ( 43 |
44 |
changeRole(e, _id, userRole)} 47 | > 48 | 55 | 58 |
59 |
60 | ); 61 | }; 62 | 63 | export default ChangeRole; 64 | -------------------------------------------------------------------------------- /src/components/footer/Footer.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | 3 | const Footer = () => { 4 | return ( 5 | <> 6 |
7 |
8 |

All Rights Reserved. © 2023

9 |
10 | 11 | ); 12 | }; 13 | 14 | export default Footer; 15 | -------------------------------------------------------------------------------- /src/components/header/Header.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import "./Header.scss"; 3 | import { BiLogIn } from "react-icons/bi"; 4 | import { FaUserCircle } from "react-icons/fa"; 5 | import { Link, NavLink, useNavigate } from "react-router-dom"; 6 | import { useDispatch } from "react-redux"; 7 | import { logout, RESET } from "../../redux/features/auth/authSlice"; 8 | import { ShowOnLogin, ShowOnLogout } from "../protect/hiddenLink"; 9 | import { UserName } from "../../pages/profile/Profile"; 10 | 11 | const activeLink = ({ isActive }) => (isActive ? "active" : ""); 12 | 13 | const Header = () => { 14 | const navigate = useNavigate(); 15 | const dispatch = useDispatch(); 16 | 17 | const goHome = () => { 18 | navigate("/"); 19 | }; 20 | 21 | const logoutUser = async () => { 22 | dispatch(RESET()); 23 | await dispatch(logout()); 24 | navigate("/login"); 25 | }; 26 | 27 | return ( 28 |
29 | 63 |
64 | ); 65 | }; 66 | 67 | export default Header; 68 | -------------------------------------------------------------------------------- /src/components/header/Header.scss: -------------------------------------------------------------------------------- 1 | .header { 2 | background-color: #030b6b; 3 | height: 7rem; 4 | 5 | display: flex; 6 | justify-content: center; 7 | align-items: center; 8 | // max-width: 1000px; 9 | width: 100%; 10 | margin: 0 auto; 11 | padding: 0 20px; 12 | 13 | & nav { 14 | width: 100%; 15 | max-width: 1000px; 16 | color: #fff; 17 | display: flex; 18 | justify-content: space-between; 19 | align-items: center; 20 | 21 | & > .logo { 22 | color: #fff; 23 | display: flex; 24 | justify-content: center; 25 | align-items: center; 26 | font-size: 3rem; 27 | cursor: pointer; 28 | } 29 | } 30 | } 31 | .home-links { 32 | display: flex; 33 | justify-content: center; 34 | align-items: center; 35 | & li a { 36 | color: #fff; 37 | } 38 | & > * { 39 | margin-left: 1rem; 40 | color: #fff; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/components/infoBox/InfoBox.js: -------------------------------------------------------------------------------- 1 | import "./InfoBox.scss"; 2 | 3 | const InfoBox = ({ bgColor, title, count, icon }) => { 4 | return ( 5 |
6 | {icon} 7 | 8 |

{title}

9 |

{count}

10 |
11 |
12 | ); 13 | }; 14 | 15 | export default InfoBox; 16 | -------------------------------------------------------------------------------- /src/components/infoBox/InfoBox.scss: -------------------------------------------------------------------------------- 1 | .info-box { 2 | width: 100%; 3 | height: 7rem; 4 | max-width: 22rem; 5 | margin-right: 1rem; 6 | margin-bottom: 1rem; 7 | display: flex; 8 | justify-content: flex-start; 9 | align-items: center; 10 | vertical-align: middle; 11 | flex-wrap: wrap; 12 | color: #fff; 13 | transform: translateY(0); 14 | transition: all 0.3s; 15 | 16 | // background-color: green; 17 | 18 | &:hover { 19 | cursor: pointer; 20 | // border: 3px solid #fff; 21 | transform: translateY(-5px); 22 | } 23 | 24 | .info-icon { 25 | padding: 0 2rem; 26 | color: #fff; 27 | } 28 | .info-text > * { 29 | color: #fff; 30 | } 31 | 32 | // .card { 33 | // border: 1px solid #ccc; 34 | // border-bottom: 3px solid var(--light-blue); 35 | // padding: 5px; 36 | // background-color: #f5f6fa; 37 | // } 38 | } 39 | 40 | @media screen and (max-width: 600px) { 41 | .info-box { 42 | max-width: 100%; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/components/layout/Layout.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import Footer from "../footer/Footer"; 3 | import Header from "../header/Header"; 4 | 5 | const Layout = ({ children }) => { 6 | return ( 7 | <> 8 |
9 |
10 | {children} 11 |
12 |