diff --git a/.env b/.env index c3ff4de..2589e4b 100644 --- a/.env +++ b/.env @@ -2,4 +2,4 @@ PORT = 3000 DATABASE_URL="mysql://root:@localhost:3306/hack_db" # --- For Docker-compose -# DATABASE_URL="mysql://root:root@localhost:3306/hack_db" \ No newline at end of file +# DATABASE_URL="mysql://root:root@localhost:3307/hack_db" \ No newline at end of file diff --git a/frontend/index.html b/frontend/index.html index 8a4d6d1..f1c0aea 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -4,7 +4,7 @@ - Vite + React + Hack2gather diff --git a/frontend/package.json b/frontend/package.json index eff902f..f108e4b 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -15,6 +15,7 @@ "framer-motion": "^11.11.17", "lucide-react": "^0.460.0", "postcss-cli": "^11.0.0", + "prop-types": "^15.8.1", "react": "^18.3.1", "react-daisyui": "^5.0.5", "react-dom": "^18.3.1", diff --git a/frontend/src/App.jsx b/frontend/src/App.jsx index 3d19a62..2feb3ae 100644 --- a/frontend/src/App.jsx +++ b/frontend/src/App.jsx @@ -20,7 +20,7 @@ function App() { 3000, 'Finding friends', 3000, - 'explring hackathons' + 'exploring hackathons' ]} wrapper="h1" cursor={true} diff --git a/frontend/src/LoginForm.jsx b/frontend/src/LoginForm.jsx index 7449ea1..1e563e9 100644 --- a/frontend/src/LoginForm.jsx +++ b/frontend/src/LoginForm.jsx @@ -22,6 +22,11 @@ const LoginForm = () => { console.log(response.data); + const userID = response.data.UserID || response.data.user?.UserID; + if (!userID) throw new Error('UserID is missing in the response'); + + + Swal.fire({ title: "Good job!", text: "Login Sucessful!", @@ -35,7 +40,7 @@ const LoginForm = () => { // Save token to localStorage and redirect // localStorage.setItem('authToken', response.data.token); - localStorage.setItem('UserID', JSON.stringify(response.data.UserID)); + localStorage.setItem('UserID', userID); window.location.href = '/profile'; } catch (error) { Swal.fire({ @@ -51,10 +56,10 @@ const LoginForm = () => { className="flex items-center justify-center h-screen bg-cover bg-center" style={{ backgroundImage: `url(${imagelogin})` }} > -
+
-

Login

-
+

Login

+
{ value={formData.email} onChange={handleInputChange} required - className="border border-gray-300 rounded-full w-full py-2 px-3 bg-white bg-opacity-0 focus:outline-none focus:ring-2 focus:ring-blue-500 text-white placeholder-white" + className="border border-gray-300 rounded-full w-full py-3 px-4 bg-white bg-opacity-0 focus:outline-none focus:ring-2 focus:ring-blue-500 text-white placeholder-white transition-transform hover:scale-105" />
-
+
{ value={formData.password} onChange={handleInputChange} required - className="border border-gray-300 rounded-full w-full py-2 px-3 bg-white bg-opacity-0 focus:outline-none focus:ring-2 focus:ring-blue-500 text-white placeholder-white" + className="border border-gray-300 rounded-full w-full py-3 px-4 bg-white bg-opacity-0 focus:outline-none focus:ring-2 focus:ring-blue-500 text-white placeholder-white transition-transform hover:scale-105" />
-
+
- -
+

Don't have an account?{' '} diff --git a/frontend/src/Register.jsx b/frontend/src/Register.jsx index 0220f43..97862f2 100644 --- a/frontend/src/Register.jsx +++ b/frontend/src/Register.jsx @@ -2,6 +2,8 @@ import Swal from 'sweetalert2' import Axios from 'axios' import {useState} from 'react' import imagelogin from './assets/imagelogin.png'; +import { Link } from 'react-router-dom'; + const Register = () => { const [formData, setFormData] = useState( { userName:'', @@ -15,9 +17,20 @@ const Register = () => { const [message, setMessage] = useState(''); const handleInputChange = (e) => { - const { name, value } = e.target; - setFormData({ ...formData, [name]: value }); + const { name, value, files } = e.target; + if (name === 'ProfileImage' && files.length > 0) { + const reader = new FileReader(); + reader.onload = () => { + setFormData({ ...formData, ProfileImage: reader.result }); // Store base64 string + }; + reader.readAsDataURL(files[0]); + } else { + setFormData({ ...formData, [name]: value }); + } }; + + + const handleSubmit = async (e) => { @@ -89,11 +102,11 @@ const Register = () => { className="flex items-center justify-center min-h-screen bg-cover bg-center" style={{ backgroundImage: `url(${imagelogin})` }} > -

+
-

Register

+

Register

-
+
{/* Input fields */} { value={formData.userName} onChange={handleInputChange} required - className="w-full h-12 px-4 py-2 bg-transparent border border-white rounded-full text-white placeholder-white focus:outline-none focus:border-white" + className="w-full h-12 px-4 py-2 bg-transparent border border-white rounded-full text-black placeholder-white focus:outline-none focus:border-white transition duration-300 hover:bg-white hover:text-black" /> { value={formData.email} onChange={handleInputChange} required - className="w-full h-12 px-4 py-2 bg-transparent border border-white rounded-full text-white placeholder-white focus:outline-none focus:border-white" + className="w-full h-12 px-4 py-2 bg-transparent border border-white rounded-full text-white placeholder-white focus:outline-none focus:border-white transition duration-300 hover:bg-white hover:text-black" />