From ab3c47130310b355a640ffe1aac94c731e1e628d Mon Sep 17 00:00:00 2001 From: Alex Date: Fri, 3 Jul 2026 22:51:21 +0200 Subject: [PATCH 1/6] Add Profile page and API integration --- GuessWho/frontend/src/App.jsx | 3 + GuessWho/frontend/src/profile/Profile.css | 0 GuessWho/frontend/src/profile/Profile.jsx | 82 +++++++++++++++++++++++ GuessWho/frontend/src/signup/SignUp.jsx | 2 +- 4 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 GuessWho/frontend/src/profile/Profile.css create mode 100644 GuessWho/frontend/src/profile/Profile.jsx diff --git a/GuessWho/frontend/src/App.jsx b/GuessWho/frontend/src/App.jsx index 7a6d04c..e0687a8 100644 --- a/GuessWho/frontend/src/App.jsx +++ b/GuessWho/frontend/src/App.jsx @@ -2,12 +2,15 @@ import { Routes, Route } from 'react-router-dom'; import SignUp from './signup/SignUp'; import Dashboard from './dashboard/Dashboard'; +import Profile from './profile/Profile'; + function App() { return ( } /> } /> + } /> ); } diff --git a/GuessWho/frontend/src/profile/Profile.css b/GuessWho/frontend/src/profile/Profile.css new file mode 100644 index 0000000..e69de29 diff --git a/GuessWho/frontend/src/profile/Profile.jsx b/GuessWho/frontend/src/profile/Profile.jsx new file mode 100644 index 0000000..53aea55 --- /dev/null +++ b/GuessWho/frontend/src/profile/Profile.jsx @@ -0,0 +1,82 @@ +import { useState } from 'react'; +import { useNavigate } from 'react-router-dom'; +import './Profile.css'; + +export default function Profile() { + const [fullName, setFullName] = useState(''); + const [aboutMe, setAboutMe] = useState(''); + + const navigate = useNavigate(); + + const isFormIncomplete = + !fullName.trim() || !aboutMe.trim(); + + const handleSubmit = async (e) => { + e.preventDefault(); + + if (isFormIncomplete) { + alert('Please complete all fields.'); + return; + } + + try { + const response = await fetch('/api/profile', { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ + fullName, + aboutMe, + }), + }); + + const data = await response.json(); + + if (!response.ok) { + alert(data.message); + return; + } + + alert('Profile created successfully!'); + navigate('/dashboard'); + } catch (error) { + console.error(error); + alert('Cannot connect to the server.'); + } + }; + + return ( +
+

Create Profile

+ +
+ setFullName(e.target.value)} + /> + +
+
+ +