From 5052f84e7db388892ec04fc92ac8af42fa542449 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 21 Oct 2024 09:35:05 +0000 Subject: [PATCH 1/4] docs(contributor): contrib-readme-action has updated readme --- README.md | 71 ++++++++++++++++++++++++++++++------------------------- 1 file changed, 39 insertions(+), 32 deletions(-) diff --git a/README.md b/README.md index ba9c6e34..7b045cc0 100644 --- a/README.md +++ b/README.md @@ -414,40 +414,49 @@ We extend our heartfelt gratitude to all the amazing contributors who have made - - AliGates915 + + smog-root
- Ali Gates + smog-root
- - chikatlarakesh + + vaibhav-yerkar
- CHIKATLA RAKESH + Vaibhav._Y
- - mishradev1 + + Vaibhav-Kumar-K-R
- Dev Mishra + Vaibhav-Kumar-K-R
- - jaidh01 + + Syed-Farazuddin
- Jai Dhingra + Syed Faraz
- - Mohitranag18 + + stutxi
- Mohit Rana + Stuti +
+ + + + Sapna127 +
+ Sapna Kul
+ + MutiatBash @@ -455,41 +464,39 @@ We extend our heartfelt gratitude to all the amazing contributors who have made Bashua Mutiat - - - - Sapna127 + + Mohitranag18
- Sapna Kul + Mohit Rana
- - stutxi + + jaidh01
- Stuti + Jai Dhingra
- - Syed-Farazuddin + + mishradev1
- Syed Faraz + Dev Mishra
- - Vaibhav-Kumar-K-R + + chikatlarakesh
- Vaibhav-Kumar-K-R + CHIKATLA RAKESH
- - vaibhav-yerkar + + AliGates915
- Vaibhav._Y + Ali Gates
From 0c7608ac2208f577f2b27b6fff532d0dac7c54a4 Mon Sep 17 00:00:00 2001 From: Vinay Anand Lodhi Date: Mon, 21 Oct 2024 16:37:54 +0530 Subject: [PATCH 2/4] antd alert message added --- backend/index.js | 2 +- frontend/package.json | 2 +- frontend/src/components/Pages/Login.css | 43 ++++++++++++++++ frontend/src/components/Pages/Login.jsx | 45 +++++++++++++++-- frontend/src/components/Pages/Signup.jsx | 63 +++++++++++++++++++----- 5 files changed, 135 insertions(+), 20 deletions(-) create mode 100644 frontend/src/components/Pages/Login.css diff --git a/backend/index.js b/backend/index.js index b8d9e76b..1bb24c71 100644 --- a/backend/index.js +++ b/backend/index.js @@ -3,7 +3,7 @@ require("dotenv").config(); const cors = require("cors"); const mongoose = require("mongoose"); const logger = require("./config/logger"); -const errorMiddleware = require("./middlewares/errorMiddleware"); // Corrected typo +const errorMiddleware = require("./middlewares/errrorMiddleware"); // Corrected typo const passport = require("passport"); const { handleGoogleOAuth } = require("./controller/googleOAuth.controller"); const app = express(); diff --git a/frontend/package.json b/frontend/package.json index 30175db5..e2a55a73 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -16,7 +16,7 @@ "@splidejs/react-splide": "^0.7.12", "@splidejs/splide": "^4.1.4", "@splidejs/splide-extension-auto-scroll": "^0.5.3", - "antd": "^5.21.2", + "antd": "^5.21.5", "autoprefixer": "^10.4.19", "axios": "^1.7.7", "clsx": "^2.1.1", diff --git a/frontend/src/components/Pages/Login.css b/frontend/src/components/Pages/Login.css new file mode 100644 index 00000000..916e09b7 --- /dev/null +++ b/frontend/src/components/Pages/Login.css @@ -0,0 +1,43 @@ + + /* Success message line animation */ + .success-message::after { + content: ''; + display: block; + width: 0; + height: 4px; + background-color: lightgreen; + position: absolute; + bottom: -4px; + left: 0; + transition: width 2s ease-in-out; + } + + .success-message.ant-message-success { + position: relative; + } + + .success-message.ant-message-success::after { + width: 100%; /* This will animate to 100% width */ + } + + /* Error message line animation */ + .error-message::after { + content: ''; + display: block; + width: 0; + height: 4px; + background-color: red; + position: absolute; + bottom: -4px; + left: 0; + transition: width 2s ease-in-out; + } + + .error-message.ant-message-error { + position: relative; + } + + .error-message.ant-message-error::after { + width: 100%; /* This will animate to 100% width */ + } + \ No newline at end of file diff --git a/frontend/src/components/Pages/Login.jsx b/frontend/src/components/Pages/Login.jsx index 7c760afa..e4c81aa9 100644 --- a/frontend/src/components/Pages/Login.jsx +++ b/frontend/src/components/Pages/Login.jsx @@ -1,11 +1,11 @@ import React, { useState, useEffect } from 'react'; import photo from '../../assets/login.png'; import { Link, useNavigate } from 'react-router-dom'; -import { message } from 'antd'; +import { message } from 'antd'; // Ant Design message component import Cookies from 'js-cookie'; import { FaEye } from 'react-icons/fa'; import { FaEyeSlash } from 'react-icons/fa6'; - +import "./Login.css"; const Login = () => { const API_URL = import.meta.env.VITE_BACKEND_URL || 'http://localhost:3000'; const [data, setData] = useState({ @@ -18,10 +18,19 @@ const Login = () => { const navigate = useNavigate(); + // Configuring the message to show at a certain top distance + message.config({ + top: 80, // Distance from the top of the viewport + duration: 2, // Auto close time in seconds + maxCount: 3, // Max number of messages + }); + + // Function to handle changes in the form inputs const handleChange = (e) => { setData({ ...data, [e.target.name]: e.target.value }); }; + // Function to handle form submission (login) const handleSubmit = async (e) => { e.preventDefault(); setIsLoading(true); @@ -35,14 +44,40 @@ const Login = () => { body: JSON.stringify(data), }); const result = await response.json(); + if (!response.ok) { throw new Error(result.message || 'Login failed'); } + + // Successful login message with a light green line below + message.success({ + content: 'Login successful', + className: 'success-message', // Add custom class for styling + style: { + fontSize: '22px', + right: '50px', // Position it on the right side + position: 'fixed', // Fix it to the viewport + paddingTop: '10px', // Add padding to move the text down + paddingBottom: '10px', // Padding for balance + }, + }); + // Set token in cookies Cookies.set('authToken', result.token, { expire: '1h', secure: true }); - message.success('Login successful'); - navigate('/'); + navigate('/'); // Navigate to homepage after successful login } catch (err) { - setError(err.message || 'An error occurred. Please try again.'); + // Show error message if login fails with a red line below + message.error({ + content: 'Something went wrong while logging in.', + className: 'error-message', // Add custom class for styling + style: { + fontSize: '18px', + right: '50px', // Position it on the right side + position: 'fixed', // Fix it to the viewport + paddingTop: '10px', // Add padding to move the text down + paddingBottom: '10px', // Padding for balance + }, + }); + setError('An error occurred. Please try again.'); } finally { setIsLoading(false); } diff --git a/frontend/src/components/Pages/Signup.jsx b/frontend/src/components/Pages/Signup.jsx index b10ce1c5..ad46915a 100644 --- a/frontend/src/components/Pages/Signup.jsx +++ b/frontend/src/components/Pages/Signup.jsx @@ -1,10 +1,18 @@ -import { useState, useEffect } from 'react'; +import React, { useState, useEffect } from 'react'; +import { message } from 'antd'; // Import Ant Design message import photo from '../../assets/login.png'; import { useNavigate, Link } from 'react-router-dom'; import { FaEye } from 'react-icons/fa'; import { FaEyeSlash } from 'react-icons/fa6'; import zxcvbn from 'zxcvbn'; // Password strength checker + +// Configure message globally +message.config({ + top: 80, // Align with the login page + duration: 2, // Duration of the message visibility +}); + const Signup = () => { const API_URL = import.meta.env.VITE_BACKEND_URL || 'http://localhost:3000'; const navigate = useNavigate(); @@ -25,26 +33,43 @@ const Signup = () => { const handleSubmit = async (e) => { e.preventDefault(); setIsLoading(true); + setError(null); // Reset error before submission + + // Frontend validation if (!data.email || !data.password || !data.name) { - setError('Please fill in all fields'); + message.error({ + content: 'Please fill in all fields.', + style: { fontSize: '18px' }, + }); setIsLoading(false); return; } if (data.password.length < 8) { - setError('Password must be at least 8 characters long'); + message.error({ + content: 'Password must be at least 8 characters long.', + style: { fontSize: '18px' }, + }); setIsLoading(false); return; } if (data.name.length < 3) { - setError('Name must be at least 3 characters long'); + message.error({ + content: 'Name must be at least 3 characters long.', + style: { fontSize: '18px' }, + }); setIsLoading(false); return; } if (!data.email.includes('@')) { - setError('Please enter a valid email address'); + message.error({ + content: 'Please enter a valid email address.', + style: { fontSize: '18px' }, + }); setIsLoading(false); return; } + + // Submit form data try { const response = await fetch(`${API_URL}/api/user/register`, { method: 'POST', @@ -52,16 +77,33 @@ const Signup = () => { body: JSON.stringify(data), }); const result = await response.json(); + if (!response.ok) { setIsLoading(false); - setError(result.error); + message.error({ + content: result.error || 'An error occurred during registration.', + style: { fontSize: '18px' }, + }); return; } - alert('Registered successfully! Please log in.'); - navigate('/'); + + // Successful registration message + message.success({ + content: 'Registered successfully! Please log in.', + style: { fontSize: '18px' }, + }); + + // Redirect to login page + navigate('/login'); } catch (error) { setError(error.message); console.error('Error:', error); + message.error({ + content: 'An error occurred while submitting the form.', + style: { fontSize: '18px' }, + }); + } finally { + setIsLoading(false); } }; @@ -139,11 +181,6 @@ const Signup = () => { Strength: {getPasswordStrengthText(passwordStrength)}

- {error && ( -
- {error} -
- )}

Already have an account? Date: Tue, 22 Oct 2024 15:12:05 +0530 Subject: [PATCH 3/4] remove css file --- frontend/src/components/Pages/Login.css | 43 ------------------------- frontend/src/components/Pages/Login.jsx | 1 - 2 files changed, 44 deletions(-) delete mode 100644 frontend/src/components/Pages/Login.css diff --git a/frontend/src/components/Pages/Login.css b/frontend/src/components/Pages/Login.css deleted file mode 100644 index 916e09b7..00000000 --- a/frontend/src/components/Pages/Login.css +++ /dev/null @@ -1,43 +0,0 @@ - - /* Success message line animation */ - .success-message::after { - content: ''; - display: block; - width: 0; - height: 4px; - background-color: lightgreen; - position: absolute; - bottom: -4px; - left: 0; - transition: width 2s ease-in-out; - } - - .success-message.ant-message-success { - position: relative; - } - - .success-message.ant-message-success::after { - width: 100%; /* This will animate to 100% width */ - } - - /* Error message line animation */ - .error-message::after { - content: ''; - display: block; - width: 0; - height: 4px; - background-color: red; - position: absolute; - bottom: -4px; - left: 0; - transition: width 2s ease-in-out; - } - - .error-message.ant-message-error { - position: relative; - } - - .error-message.ant-message-error::after { - width: 100%; /* This will animate to 100% width */ - } - \ No newline at end of file diff --git a/frontend/src/components/Pages/Login.jsx b/frontend/src/components/Pages/Login.jsx index e4c81aa9..f9f9e053 100644 --- a/frontend/src/components/Pages/Login.jsx +++ b/frontend/src/components/Pages/Login.jsx @@ -5,7 +5,6 @@ import { message } from 'antd'; // Ant Design message component import Cookies from 'js-cookie'; import { FaEye } from 'react-icons/fa'; import { FaEyeSlash } from 'react-icons/fa6'; -import "./Login.css"; const Login = () => { const API_URL = import.meta.env.VITE_BACKEND_URL || 'http://localhost:3000'; const [data, setData] = useState({ From 054b7ce3a71e91d8527166ddb5a4424bb61a34a3 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 22 Oct 2024 09:42:42 +0000 Subject: [PATCH 4/4] docs(contributor): contrib-readme-action has updated readme --- README.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 2d55b3c4..13715b17 100644 --- a/README.md +++ b/README.md @@ -455,11 +455,13 @@ We extend our heartfelt gratitude to all the amazing contributors who have made Stuti + + - - Mohitranag18 + + Sapna127
- Mohit Rana + Sapna Kul