From 871efad30f92a043a88afaee4a670553e2856472 Mon Sep 17 00:00:00 2001 From: Moueed Ali Date: Wed, 3 Sep 2025 09:56:13 +0200 Subject: [PATCH 01/26] feat/added feature for email and password validaion --- src/pages/register/index.js | 36 +++++++++++++++++++++++++++++++++++- src/service/apiClient.js | 2 +- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/src/pages/register/index.js b/src/pages/register/index.js index 5cc70e32..6947030d 100644 --- a/src/pages/register/index.js +++ b/src/pages/register/index.js @@ -14,6 +14,30 @@ const Register = () => { setFormData({ ...formData, [name]: value }); }; + const validateEmail = (email) => { + const mailFormat = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/; + if (email.match(mailFormat)) { + return true; // return true if email is in valid format + } + else { + alert("You have entered an invalid email address"); // generic error message for now, needs refactoring + return false; + } + + console.log(onRegister) + } + + const validatePassword = (password) => { + const passwordFormat = /^(?=.*?[A-Z])(?=.*?[0-9])(?=.*?[#?!@$%^&*-]).{8,}$/; + if (password.match(passwordFormat)) { + return true; + } + else { + alert("Your password is not in the right format"); // generic error message for now, needs refactoring + return false; + } + } + return (
{ type="email" name="email" label={'Email *'} + required /> { name="password" label={'Password *'} type={'password'} + required />
@@ -52,3 +83,6 @@ const Register = () => { }; export default Register; + +// email: dave@email.com +// password: @Qwert123456 \ No newline at end of file diff --git a/src/service/apiClient.js b/src/service/apiClient.js index 5f3cdbcf..0effc0ca 100644 --- a/src/service/apiClient.js +++ b/src/service/apiClient.js @@ -5,7 +5,7 @@ async function login(email, password) { } async function register(email, password) { - await post('users', { email, password }, false); + await post('signup', { email, password }, false); return await login(email, password); } From 1619055c1a2fbf7a11520a2fe907dbd77adaa319 Mon Sep 17 00:00:00 2001 From: Moueed Ali Date: Wed, 3 Sep 2025 11:38:39 +0200 Subject: [PATCH 02/26] fix/removed_email_and_password --- src/pages/register/index.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/pages/register/index.js b/src/pages/register/index.js index 6947030d..42efbb99 100644 --- a/src/pages/register/index.js +++ b/src/pages/register/index.js @@ -83,6 +83,3 @@ const Register = () => { }; export default Register; - -// email: dave@email.com -// password: @Qwert123456 \ No newline at end of file From d45d3451a332979afd1656d3c51f87ef4a59b32b Mon Sep 17 00:00:00 2001 From: Moueed Ali Date: Wed, 3 Sep 2025 13:44:27 +0200 Subject: [PATCH 03/26] feat/added new feature to perform checks against DB for existing email --- .prettierignore | 2 ++ package-lock.json | 18 ++++++++++++---- package.json | 3 ++- src/pages/register/index.js | 42 ++++++++++++++++++++++++++++++------- 4 files changed, 53 insertions(+), 12 deletions(-) create mode 100644 .prettierignore diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 00000000..08fe6302 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,2 @@ +src/* +src/ \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 6891fbef..efeadd9c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,13 +15,14 @@ "react": "^18.2.0", "react-dom": "^18.2.0", "react-modal": "^3.16.1", + "react-password-checklist": "^1.8.1", "react-router-dom": "^6.8.0", "react-scripts": "5.0.1", "web-vitals": "^3.1.1" }, "devDependencies": { "eslint": "^8.57.1", - "eslint-config-prettier": "^9.1.0", + "eslint-config-prettier": "^9.1.2", "eslint-config-standard": "^17.1.0", "eslint-plugin-import": "^2.31.0", "eslint-plugin-n": "^16.6.2", @@ -7360,9 +7361,9 @@ } }, "node_modules/eslint-config-prettier": { - "version": "9.1.0", - "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-9.1.0.tgz", - "integrity": "sha512-NSWl5BFQWEPi1j4TjVNItzYV7dZXZ+wP6I6ZhrBGpChQhZRUaElihE9uRRkcbRnNb76UMKDF3r+WTmNcGPKsqw==", + "version": "9.1.2", + "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-9.1.2.tgz", + "integrity": "sha512-iI1f+D2ViGn+uvv5HuHVUamg8ll4tN+JRHGc6IJi4TP9Kl976C57fzPXgseXNs8v0iA8aSJpHsTWjDb9QJamGQ==", "dev": true, "license": "MIT", "bin": { @@ -14974,6 +14975,15 @@ "react-dom": "^0.14.0 || ^15.0.0 || ^16 || ^17 || ^18" } }, + "node_modules/react-password-checklist": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/react-password-checklist/-/react-password-checklist-1.8.1.tgz", + "integrity": "sha512-QHIU/OejxoH4/cIfYLHaHLb+yYc8mtL0Vr4HTmULxQg3ZNdI9Ni/yYf7pwLBgsUh4sseKCV/GzzYHWpHqejTGw==", + "license": "MIT", + "peerDependencies": { + "react": ">16.0.0-alpha || >17.0.0-alpha || >18.0.0-alpha" + } + }, "node_modules/react-refresh": { "version": "0.11.0", "resolved": "https://registry.npmjs.org/react-refresh/-/react-refresh-0.11.0.tgz", diff --git a/package.json b/package.json index 249b6b05..320f92bc 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ "react": "^18.2.0", "react-dom": "^18.2.0", "react-modal": "^3.16.1", + "react-password-checklist": "^1.8.1", "react-router-dom": "^6.8.0", "react-scripts": "5.0.1", "web-vitals": "^3.1.1" @@ -43,7 +44,7 @@ }, "devDependencies": { "eslint": "^8.57.1", - "eslint-config-prettier": "^9.1.0", + "eslint-config-prettier": "^9.1.2", "eslint-config-standard": "^17.1.0", "eslint-plugin-import": "^2.31.0", "eslint-plugin-n": "^16.6.2", diff --git a/src/pages/register/index.js b/src/pages/register/index.js index 42efbb99..0efe356c 100644 --- a/src/pages/register/index.js +++ b/src/pages/register/index.js @@ -4,6 +4,7 @@ import TextInput from '../../components/form/textInput'; import useAuth from '../../hooks/useAuth'; import CredentialsCard from '../../components/credentials'; import './register.css'; +import ReactPasswordChecklist from 'react-password-checklist'; const Register = () => { const { onRegister } = useAuth(); @@ -17,14 +18,13 @@ const Register = () => { const validateEmail = (email) => { const mailFormat = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/; if (email.match(mailFormat)) { - return true; // return true if email is in valid format + return true; } else { - alert("You have entered an invalid email address"); // generic error message for now, needs refactoring + alert("You have entered an invalid email address"); return false; } - console.log(onRegister) } const validatePassword = (password) => { @@ -33,10 +33,25 @@ const Register = () => { return true; } else { - alert("Your password is not in the right format"); // generic error message for now, needs refactoring + alert("Your password is not in the right format"); return false; } } + + const checkEmailExists = async (email) => { + try { + const response = await fetch('/api/check-email', { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ email }), + }); + const data = await response.json(); + return data.exists; + } + catch (error) { + return true; + } + }; return (
@@ -65,15 +80,28 @@ const Register = () => { type={'password'} required /> +
From 676d083378b4ebbef5a1898562de225d06021895 Mon Sep 17 00:00:00 2001 From: Linda Do Date: Wed, 3 Sep 2025 13:53:58 +0200 Subject: [PATCH 04/26] updated step one and two --- src/pages/welcome/index.js | 7 ++++++- src/pages/welcome/stepFour/index.js | 19 +++++++++++++++++++ src/pages/welcome/stepOne/index.js | 12 ++++-------- src/pages/welcome/stepTwo/index.js | 25 +++++++++++++++++++++++-- 4 files changed, 52 insertions(+), 11 deletions(-) create mode 100644 src/pages/welcome/stepFour/index.js diff --git a/src/pages/welcome/index.js b/src/pages/welcome/index.js index 85af11ab..377418ad 100644 --- a/src/pages/welcome/index.js +++ b/src/pages/welcome/index.js @@ -3,6 +3,7 @@ import Stepper from '../../components/stepper'; import useAuth from '../../hooks/useAuth'; import StepOne from './stepOne'; import StepTwo from './stepTwo'; +import StepFour from './stepFour'; import './style.css'; const Welcome = () => { @@ -11,7 +12,9 @@ const Welcome = () => { const [profile, setProfile] = useState({ firstName: '', lastName: '', + username: '', githubUsername: '', + mobile: '', bio: '' }); @@ -23,9 +26,10 @@ const Welcome = () => { [name]: value }); }; + const onComplete = () => { - onCreateProfile(profile.firstName, profile.lastName, profile.githubUsername, profile.bio); + onCreateProfile(profile.firstName, profile.lastName, profile.username, profile.githubUsername, profile.mobile, profile.bio); }; return ( @@ -38,6 +42,7 @@ const Welcome = () => { } onComplete={onComplete}> + ); diff --git a/src/pages/welcome/stepFour/index.js b/src/pages/welcome/stepFour/index.js new file mode 100644 index 00000000..8395955c --- /dev/null +++ b/src/pages/welcome/stepFour/index.js @@ -0,0 +1,19 @@ +import Form from '../../../components/form'; + +const StepThree = ({ data, setData }) => { + return ( + <> +
+

Bio

+
+
+
+ +

*Required

+
+
+ + ); +}; + +export default StepThree; diff --git a/src/pages/welcome/stepOne/index.js b/src/pages/welcome/stepOne/index.js index 317940f8..33e5d3de 100644 --- a/src/pages/welcome/stepOne/index.js +++ b/src/pages/welcome/stepOne/index.js @@ -22,15 +22,11 @@ const StepOne = ({ data, setData }) => { onChange={setData} value={data.firstName} name="firstName" - label={'First name'} - /> - - + +

*Required

diff --git a/src/pages/welcome/stepTwo/index.js b/src/pages/welcome/stepTwo/index.js index f40dad3e..3d02952c 100644 --- a/src/pages/welcome/stepTwo/index.js +++ b/src/pages/welcome/stepTwo/index.js @@ -1,14 +1,35 @@ + import Form from '../../../components/form'; +import TextInput from '../../../components/form/textInput'; const StepTwo = ({ data, setData }) => { return ( <>
-

Bio

+

Basic info

- + + +

*Required

From 6687919e96d592b406927abdaf0d4d219d12e607 Mon Sep 17 00:00:00 2001 From: Emanuels Zaurins Date: Wed, 3 Sep 2025 14:22:37 +0200 Subject: [PATCH 05/26] Added password feature and fixed prettier --- .gitignore | 4 +++- .prettierignore | 4 ++++ package-lock.json | 8 ++++---- package.json | 2 +- src/components/form/textInput/index.js | 8 ++++---- 5 files changed, 16 insertions(+), 10 deletions(-) create mode 100644 .prettierignore diff --git a/.gitignore b/.gitignore index 2cd0c01c..c094933b 100644 --- a/.gitignore +++ b/.gitignore @@ -23,4 +23,6 @@ npm-debug.log* yarn-debug.log* yarn-error.log* -.vscode \ No newline at end of file +.vscode +.idea + diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 00000000..a276e2d6 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,4 @@ +# Example .prettierignore content + +src/* +src/ \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 6891fbef..450e1030 100644 --- a/package-lock.json +++ b/package-lock.json @@ -21,7 +21,7 @@ }, "devDependencies": { "eslint": "^8.57.1", - "eslint-config-prettier": "^9.1.0", + "eslint-config-prettier": "^9.1.2", "eslint-config-standard": "^17.1.0", "eslint-plugin-import": "^2.31.0", "eslint-plugin-n": "^16.6.2", @@ -7360,9 +7360,9 @@ } }, "node_modules/eslint-config-prettier": { - "version": "9.1.0", - "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-9.1.0.tgz", - "integrity": "sha512-NSWl5BFQWEPi1j4TjVNItzYV7dZXZ+wP6I6ZhrBGpChQhZRUaElihE9uRRkcbRnNb76UMKDF3r+WTmNcGPKsqw==", + "version": "9.1.2", + "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-9.1.2.tgz", + "integrity": "sha512-iI1f+D2ViGn+uvv5HuHVUamg8ll4tN+JRHGc6IJi4TP9Kl976C57fzPXgseXNs8v0iA8aSJpHsTWjDb9QJamGQ==", "dev": true, "license": "MIT", "bin": { diff --git a/package.json b/package.json index 249b6b05..9f4dcf98 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ }, "devDependencies": { "eslint": "^8.57.1", - "eslint-config-prettier": "^9.1.0", + "eslint-config-prettier": "^9.1.2", "eslint-config-standard": "^17.1.0", "eslint-plugin-import": "^2.31.0", "eslint-plugin-n": "^16.6.2", diff --git a/src/components/form/textInput/index.js b/src/components/form/textInput/index.js index 39da3cae..d85a67e1 100644 --- a/src/components/form/textInput/index.js +++ b/src/components/form/textInput/index.js @@ -1,27 +1,27 @@ import { useState } from 'react'; const TextInput = ({ value, onChange, name, label, icon, type = 'text' }) => { - const [input, setInput] = useState(''); const [showpassword, setShowpassword] = useState(false); + const [typ, setTyp] = useState(type); if (type === 'password') { return (
{ onChange(e); - setInput(e.target.value); }} /> - {showpassword && } + + {isOpen && ( +
    + {normalizedOptions.map((option) => ( +
  • handleOptionClick(option.value)} + style={{ + padding: "0.5rem 1rem", + cursor: "pointer", + backgroundColor: value === option.value ? "#f0f0f0" : "#fff", + }} + > + {option.label} +
  • + ))} +
+ )} +
+ ); +} + +export default DropdownMenu; diff --git a/src/components/dropdown/style.css b/src/components/dropdown/style.css new file mode 100644 index 00000000..9619e527 --- /dev/null +++ b/src/components/dropdown/style.css @@ -0,0 +1,45 @@ +/* Dropdown Button */ +.dropbtn { + background-color: #3498DB; + color: white; + padding: 16px; + font-size: 16px; + border: none; + cursor: pointer; +} + +/* Dropdown button on hover & focus */ +.dropbtn:hover, .dropbtn:focus { + background-color: #2980B9; +} + +/* The container
- needed to position the dropdown content */ +.dropdown { + position: relative; + left: 0; + display: inline-block; +} + +/* Dropdown Content (Hidden by Default) */ +.dropdown-content { + display: none; + position: absolute; + background-color: #f1f1f1; + min-width: 160px; + box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2); + z-index: 1; +} + +/* Links inside the dropdown */ +.dropdown-content a { + color: black; + padding: 12px 16px; + text-decoration: none; + display: block; +} + +/* Change color of dropdown links on hover */ +.dropdown-content a:hover {background-color: #ddd;} + +/* Show the dropdown menu (use JS to add this class to the .dropdown-content container when the user clicks on the dropdown button) */ +.show {display:block;} \ No newline at end of file diff --git a/src/components/stepper/index.js b/src/components/stepper/index.js index c9e5f259..17281815 100644 --- a/src/components/stepper/index.js +++ b/src/components/stepper/index.js @@ -34,7 +34,7 @@ const Stepper = ({ header, children, onComplete }) => {
); - } else { + } else { return (
{label && } @@ -45,7 +45,7 @@ const TextInput = ({ value, onChange, name, label, icon, type = 'text', placehol
); } -}; +} const EyeLogo = () => { return ( diff --git a/src/components/stepper/index.js b/src/components/stepper/index.js index c9e5f259..17a79006 100644 --- a/src/components/stepper/index.js +++ b/src/components/stepper/index.js @@ -4,7 +4,7 @@ import Button from '../button'; import './style.css'; import { useState } from 'react'; -const Stepper = ({ header, children, onComplete }) => { +const Stepper = ({ header, children, onComplete, data }) => { const [currentStep, setCurrentStep] = useState(0); const onBackClick = () => { @@ -22,6 +22,34 @@ const Stepper = ({ header, children, onComplete }) => { setCurrentStep(currentStep + 1); }; + const validateName = (data) => { + if(!data) { + alert("OBSS!!! Please write Firstname and Lastname") + return false + } else { + return true + } + } + + const validateUsername = (data) => { + if(data.username.length < 7) { + alert("Username is too short. Input must be at least 7 characters long") + return false + } else { + return true + } + } + + const validateMobile = (data) => { + if(data.length < 8) { + alert("Mobile number is too short. Input must be at least 8 characters long") + return false + } else { + return true + } + } + + return ( {header} @@ -33,11 +61,31 @@ const Stepper = ({ header, children, onComplete }) => {
); diff --git a/src/pages/welcome/index.js b/src/pages/welcome/index.js index 377418ad..4b660ff6 100644 --- a/src/pages/welcome/index.js +++ b/src/pages/welcome/index.js @@ -25,9 +25,9 @@ const Welcome = () => { ...profile, [name]: value }); + }; - const onComplete = () => { onCreateProfile(profile.firstName, profile.lastName, profile.username, profile.githubUsername, profile.mobile, profile.bio); }; @@ -39,7 +39,7 @@ const Welcome = () => {

Create your profile to get started

- } onComplete={onComplete}> + } onComplete={onComplete}> From f08502bfcd0e7a486b464a1f10a27029bd0803a8 Mon Sep 17 00:00:00 2001 From: Moueed Ali Date: Thu, 4 Sep 2025 19:27:29 +0200 Subject: [PATCH 11/26] feat/added feature for email and password check against database for signup and login --- src/pages/login/index.js | 11 ++++++++++- src/pages/register/index.js | 33 +++++++++++---------------------- src/service/apiClient.js | 6 ++++++ 3 files changed, 27 insertions(+), 23 deletions(-) diff --git a/src/pages/login/index.js b/src/pages/login/index.js index 08df7d5a..1dcb7382 100644 --- a/src/pages/login/index.js +++ b/src/pages/login/index.js @@ -36,7 +36,16 @@ const Login = () => { ); - } else { + } else { return (
{label && } diff --git a/src/context/form.js b/src/context/form.js new file mode 100644 index 00000000..c602786e --- /dev/null +++ b/src/context/form.js @@ -0,0 +1,15 @@ +import React, { createContext, useContext, useState } from 'react'; + +const FormContext = createContext(); + +export const FormProvider = ({ children }) => { + const [formData, setFormData] = useState({ email: '', password: '' }); + + return ( + + {children} + + ); +}; + +export const useFormData = () => useContext(FormContext); diff --git a/src/pages/welcome/index.js b/src/pages/welcome/index.js index 4b660ff6..aaf3eb2a 100644 --- a/src/pages/welcome/index.js +++ b/src/pages/welcome/index.js @@ -5,9 +5,11 @@ import StepOne from './stepOne'; import StepTwo from './stepTwo'; import StepFour from './stepFour'; import './style.css'; +import { useFormData } from '../../context/form'; const Welcome = () => { const { onCreateProfile } = useAuth(); + const { formData } = useFormData(); const [profile, setProfile] = useState({ firstName: '', @@ -25,11 +27,17 @@ const Welcome = () => { ...profile, [name]: value }); - }; - + const onComplete = () => { - onCreateProfile(profile.firstName, profile.lastName, profile.username, profile.githubUsername, profile.mobile, profile.bio); + onCreateProfile( + profile.firstName, + profile.lastName, + profile.username, + profile.mobile, + profile.githubUsername, + profile.bio + ); }; return ( @@ -41,7 +49,7 @@ const Welcome = () => { } onComplete={onComplete}> - + diff --git a/src/pages/welcome/stepTwo/index.js b/src/pages/welcome/stepTwo/index.js index 763fc391..c4f66c35 100644 --- a/src/pages/welcome/stepTwo/index.js +++ b/src/pages/welcome/stepTwo/index.js @@ -3,7 +3,7 @@ import Form from '../../../components/form'; import NumberInput from '../../../components/form/numberInput'; import TextInput from '../../../components/form/textInput'; -const StepTwo = ({ data, setData }) => { +const StepTwo = ({ data, setData, formData }) => { return ( <>
@@ -12,12 +12,12 @@ const StepTwo = ({ data, setData }) => {
{ required /> + value={formData.password} + placeholder={formData.password} + name="password" + label={'Password *'} + type={'password'} + /> + {console.log(formData.password)}

*Required

From 2a8d2c7576ac6e2b82fb26b7799cd49d9893bbb2 Mon Sep 17 00:00:00 2001 From: Linda Do Date: Tue, 9 Sep 2025 15:50:05 +0200 Subject: [PATCH 14/26] fixed missing steps from merge --- src/pages/welcome/index.js | 18 +++++++++-- src/pages/welcome/stepThree/index.js | 45 ++++++++++----------------- src/pages/welcome/stepTwo/index.js | 46 ++++++++++++++++++++++++++++ 3 files changed, 78 insertions(+), 31 deletions(-) create mode 100644 src/pages/welcome/stepTwo/index.js diff --git a/src/pages/welcome/index.js b/src/pages/welcome/index.js index 1cae5cae..34f44d0a 100644 --- a/src/pages/welcome/index.js +++ b/src/pages/welcome/index.js @@ -18,7 +18,12 @@ const Welcome = () => { username: '', githubUsername: '', mobile: '', - bio: '' + bio: '', + role: '', + specialism: '', + cohort: '', + startDate: '', + endDate: '' }); const onChange = (event) => { @@ -37,10 +42,19 @@ const Welcome = () => { profile.username, profile.mobile, profile.githubUsername, - profile.bio + profile.bio, + profile.role, + profile.specialism, + profile.cohort, + profile.startDate, + profile.endDate ); }; + + + + return (
diff --git a/src/pages/welcome/stepThree/index.js b/src/pages/welcome/stepThree/index.js index 8d63811e..ec5b8da4 100644 --- a/src/pages/welcome/stepThree/index.js +++ b/src/pages/welcome/stepThree/index.js @@ -1,17 +1,9 @@ -import { useState } from 'react'; import Form from '../../../components/form'; import TextInput from '../../../components/form/textInput'; -import DropdownMenu from '../../../components/dropdown'; -import { getRoles } from '@testing-library/react'; const StepThree = ({ data, setData }) => { - const [selectedRole, setSelectedRole] = useState(""); - const [selectedSpecialism, setSelectedSpecialism] = useState(""); - const [selectedCohort, setSelectedCohort] = useState(""); - const cohorts = [{value:"c1", label:"c1"}, {value:"c2", label:"c2"}]; - const specialisms = [{value:"s1", label:"s1"}, {value:"s2", label:"s2"}]; return ( <>
@@ -19,35 +11,30 @@ const StepThree = ({ data, setData }) => {
- - -

*Required

diff --git a/src/pages/welcome/stepTwo/index.js b/src/pages/welcome/stepTwo/index.js new file mode 100644 index 00000000..2351e44e --- /dev/null +++ b/src/pages/welcome/stepTwo/index.js @@ -0,0 +1,46 @@ + +import Form from '../../../components/form'; +import NumberInput from '../../../components/form/numberInput'; +import TextInput from '../../../components/form/textInput'; + +const StepTwo = ({ data, setData, formData }) => { + return ( + <> +
+

Basic info

+
+ +
+ + + + {console.log(formData.password)} + +

*Required

+
+ + + ); +}; + +export default StepTwo; \ No newline at end of file From 98b4a9f32383213ad06a351c1e25c6523b46e4b4 Mon Sep 17 00:00:00 2001 From: Linda Do Date: Wed, 10 Sep 2025 13:56:30 +0200 Subject: [PATCH 15/26] Upload profile picture ok --- src/pages/welcome/index.js | 22 ++++++++-- src/pages/welcome/stepOne/index.js | 70 ++++++++++++++++++++++++++++-- src/pages/welcome/style.css | 20 ++++++++- 3 files changed, 105 insertions(+), 7 deletions(-) diff --git a/src/pages/welcome/index.js b/src/pages/welcome/index.js index 34f44d0a..838e37b5 100644 --- a/src/pages/welcome/index.js +++ b/src/pages/welcome/index.js @@ -23,7 +23,8 @@ const Welcome = () => { specialism: '', cohort: '', startDate: '', - endDate: '' + endDate: '', + photo: '' }); const onChange = (event) => { @@ -47,11 +48,26 @@ const Welcome = () => { profile.specialism, profile.cohort, profile.startDate, - profile.endDate + profile.endDate, + profile.photo ); }; + const handleFileChange = (event, close) => { + + const file = event.target.files[0]; + if (file) { + const url = URL.createObjectURL(file) + setProfile(prevProfile => ({ + ...prevProfile, + photo: url + })); + close() + console.log("profile:" + profile.photo) + } + } + @@ -63,7 +79,7 @@ const Welcome = () => {
} onComplete={onComplete}> - + diff --git a/src/pages/welcome/stepOne/index.js b/src/pages/welcome/stepOne/index.js index 5518d4a1..d07a608e 100644 --- a/src/pages/welcome/stepOne/index.js +++ b/src/pages/welcome/stepOne/index.js @@ -1,8 +1,17 @@ +import Popup from 'reactjs-popup'; import ProfileIcon from '../../../assets/icons/profileIcon'; + import Form from '../../../components/form'; import TextInput from '../../../components/form/textInput'; +import Card from '../../../components/card'; + + + + -const StepOne = ({ data, setData }) => { + + +const StepOne = ({ data, setData, handleFileChange }) => { return ( <>
@@ -11,10 +20,65 @@ const StepOne = ({ data, setData }) => {

Photo

+
- -

Add headshot

+ {data.photo ? ( + profile photo + ) : ( )} + + {data.photo ? ( + Replace headshot} modal> + {close => ( + +
+

Upload Photo

+

Choose a file to upload your headshot

+
+ + handleFileChange(e, close)}/> + +
+
+
+ )} +
) : ( + Add headshot} modal> + {close => ( + +
+

Upload Photo

+

Choose a file to upload your headshot

+
+ + handleFileChange(e, close)}/> + +
+ +
+
+ )} +
+ )}
+

Please upload a valid image file

diff --git a/src/pages/welcome/style.css b/src/pages/welcome/style.css index 9f0647cb..798591f7 100644 --- a/src/pages/welcome/style.css +++ b/src/pages/welcome/style.css @@ -55,4 +55,22 @@ .bio-heading { font-size: 25px; -} \ No newline at end of file +} + +.addHeadshot { + height: 55px; + color:#64648c; + display: flex; +} + + + +.upload-label { + background-color: var(--color-blue); + color: white; + padding: 14px 24px; + border-radius: 4px; + cursor: pointer; + text-align: center; + font-size: 20px; +} From 17837c53ab60562107dd47d865feeed5dcfdd6cb Mon Sep 17 00:00:00 2001 From: Linda Do Date: Wed, 10 Sep 2025 13:57:35 +0200 Subject: [PATCH 16/26] missing form context --- src/App.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/App.js b/src/App.js index 136c3a15..5c2221ed 100644 --- a/src/App.js +++ b/src/App.js @@ -8,11 +8,13 @@ import Verification from './pages/verification'; import { AuthProvider, ProtectedRoute } from './context/auth'; import { ModalProvider } from './context/modal'; import Welcome from './pages/welcome'; +import { FormProvider } from './context/form'; const App = () => { return ( <> + } /> @@ -38,6 +40,7 @@ const App = () => { /> + ); From 0ddf2e0b10c66053545dec3f8d8ef499349ccdcc Mon Sep 17 00:00:00 2001 From: Linda Do Date: Wed, 10 Sep 2025 14:03:48 +0200 Subject: [PATCH 17/26] refactor --- src/pages/welcome/stepOne/index.js | 79 ++++++++++++------------------ 1 file changed, 32 insertions(+), 47 deletions(-) diff --git a/src/pages/welcome/stepOne/index.js b/src/pages/welcome/stepOne/index.js index d07a608e..0d5daaff 100644 --- a/src/pages/welcome/stepOne/index.js +++ b/src/pages/welcome/stepOne/index.js @@ -29,54 +29,39 @@ const StepOne = ({ data, setData, handleFileChange }) => { className="welcome-form-profileimg-input" style={{ width: '80px', marginTop: '10px'}}/> ) : ( )} + + {data.photo ? "Replace headshot" : "Add headshot"} + } modal> + {close => ( + +
+

+ {data.photo ? "Replace Photo" : "Upload Photo"} +

+

Choose a file to upload your headshot

+ +
+ + + handleFileChange(e, close)} + /> + +
+
+
+ )} +
- {data.photo ? ( - Replace headshot} modal> - {close => ( - -
-

Upload Photo

-

Choose a file to upload your headshot

-
- - handleFileChange(e, close)}/> - -
-
-
- )} -
) : ( - Add headshot} modal> - {close => ( - -
-

Upload Photo

-

Choose a file to upload your headshot

-
- - handleFileChange(e, close)}/> - -
- -
-
- )} -
- )}

Please upload a valid image file

From 1c8613bb7eabd1c82a05697e8751d02f0c689234 Mon Sep 17 00:00:00 2001 From: Marie Helene Hansen Date: Wed, 10 Sep 2025 14:36:24 +0200 Subject: [PATCH 18/26] add file structure and route for Student View Cohort page --- src/App.js | 10 +++++++++- src/components/navigation/index.js | 2 +- src/context/auth.js | 2 +- src/pages/cohort/cohort.css | 0 src/pages/cohort/exercises/index.js | 7 +++++++ src/pages/cohort/index.js | 7 +++++++ src/pages/cohort/students/index.js | 7 +++++++ src/pages/cohort/teachers/index.js | 7 +++++++ src/pages/register/index.js | 2 +- 9 files changed, 40 insertions(+), 4 deletions(-) create mode 100644 src/pages/cohort/cohort.css create mode 100644 src/pages/cohort/exercises/index.js create mode 100644 src/pages/cohort/index.js create mode 100644 src/pages/cohort/students/index.js create mode 100644 src/pages/cohort/teachers/index.js diff --git a/src/App.js b/src/App.js index 136c3a15..46f9b549 100644 --- a/src/App.js +++ b/src/App.js @@ -8,6 +8,7 @@ import Verification from './pages/verification'; import { AuthProvider, ProtectedRoute } from './context/auth'; import { ModalProvider } from './context/modal'; import Welcome from './pages/welcome'; +import Cohort from './pages/cohort'; const App = () => { return ( @@ -19,7 +20,6 @@ const App = () => { } /> } /> } /> - { } /> + + + + } + /> diff --git a/src/components/navigation/index.js b/src/components/navigation/index.js index b31393a8..10eec500 100644 --- a/src/components/navigation/index.js +++ b/src/components/navigation/index.js @@ -28,7 +28,7 @@ const Navigation = () => {
  • - +

    Cohort

    diff --git a/src/context/auth.js b/src/context/auth.js index 47cd66c9..a64a46ab 100644 --- a/src/context/auth.js +++ b/src/context/auth.js @@ -19,7 +19,7 @@ const AuthProvider = ({ children }) => { useEffect(() => { const storedToken = localStorage.getItem('token'); - if (storedToken) { + if (storedToken && !token) { setToken(storedToken); navigate(location.state?.from?.pathname || '/'); } diff --git a/src/pages/cohort/cohort.css b/src/pages/cohort/cohort.css new file mode 100644 index 00000000..e69de29b diff --git a/src/pages/cohort/exercises/index.js b/src/pages/cohort/exercises/index.js new file mode 100644 index 00000000..d3dc4109 --- /dev/null +++ b/src/pages/cohort/exercises/index.js @@ -0,0 +1,7 @@ +function Exercises() { + return ( + <> + ) +} + +export default Exercises; \ No newline at end of file diff --git a/src/pages/cohort/index.js b/src/pages/cohort/index.js new file mode 100644 index 00000000..6093e0b4 --- /dev/null +++ b/src/pages/cohort/index.js @@ -0,0 +1,7 @@ +const Cohort = () => { + return ( +

    + ) +} + +export default Cohort; \ No newline at end of file diff --git a/src/pages/cohort/students/index.js b/src/pages/cohort/students/index.js new file mode 100644 index 00000000..1a0b5886 --- /dev/null +++ b/src/pages/cohort/students/index.js @@ -0,0 +1,7 @@ +function Students() { + return ( + <> + ) +} + +export default Students; \ No newline at end of file diff --git a/src/pages/cohort/teachers/index.js b/src/pages/cohort/teachers/index.js new file mode 100644 index 00000000..7c0e3373 --- /dev/null +++ b/src/pages/cohort/teachers/index.js @@ -0,0 +1,7 @@ +function Teachers() { + return ( + <> + ) +} + +export default Teachers; \ No newline at end of file diff --git a/src/pages/register/index.js b/src/pages/register/index.js index 14d3bac5..c434a916 100644 --- a/src/pages/register/index.js +++ b/src/pages/register/index.js @@ -16,7 +16,7 @@ const Register = () => { }; const validateEmail = (email) => { - const mailFormat = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/; + const mailFormat = /^\w+([.-]?\w+)*@\w+([.-]?\w+)*(\.\w{2,3})+$/; if (email.match(mailFormat)) { return true; } From 9bebb8aa940db5bf784e2716328a6964631eb0b3 Mon Sep 17 00:00:00 2001 From: Linda Do Date: Thu, 11 Sep 2025 09:33:19 +0200 Subject: [PATCH 19/26] fixed issues from merge --- package-lock.json | 14 ++++++++++++++ package.json | 1 + src/components/form/textInput/index.js | 9 +++++---- src/pages/register/index.js | 4 ++-- 4 files changed, 22 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index efeadd9c..d9caa348 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18,6 +18,7 @@ "react-password-checklist": "^1.8.1", "react-router-dom": "^6.8.0", "react-scripts": "5.0.1", + "reactjs-popup": "^2.0.6", "web-vitals": "^3.1.1" }, "devDependencies": { @@ -15094,6 +15095,19 @@ } } }, + "node_modules/reactjs-popup": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/reactjs-popup/-/reactjs-popup-2.0.6.tgz", + "integrity": "sha512-A+tt+x9wdgZiZjv0e2WzYLD3IfFwJALaRaqwrCSXGjo0iQdsry/EtBEbQXRSmQs7cHmOi5eytCiSlOm8k4C+dg==", + "license": "MIT", + "engines": { + "node": ">=10" + }, + "peerDependencies": { + "react": ">=16", + "react-dom": ">=16" + } + }, "node_modules/read-cache": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/read-cache/-/read-cache-1.0.0.tgz", diff --git a/package.json b/package.json index 320f92bc..1825e548 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,7 @@ "react-password-checklist": "^1.8.1", "react-router-dom": "^6.8.0", "react-scripts": "5.0.1", + "reactjs-popup": "^2.0.6", "web-vitals": "^3.1.1" }, "scripts": { diff --git a/src/components/form/textInput/index.js b/src/components/form/textInput/index.js index 9ae3516b..06d7feb5 100644 --- a/src/components/form/textInput/index.js +++ b/src/components/form/textInput/index.js @@ -2,27 +2,28 @@ import { useState } from 'react'; const TextInput = ({ value, onChange, name, label, icon, type = 'text', placeholder }) => { const [showpassword, setShowpassword] = useState(false); - const [typ, setTyp] = useState(type); + const [input, setInput] = useState(value); if (type === 'password') { return (
    { onChange(e); + setInput(e.target.value) }} /> + {showpassword && } + + ) } diff --git a/src/pages/cohort/index.js b/src/pages/cohort/index.js index 6093e0b4..c26be881 100644 --- a/src/pages/cohort/index.js +++ b/src/pages/cohort/index.js @@ -1,6 +1,15 @@ +import Exercises from "./exercises"; + const Cohort = () => { return ( -

    + <> +
    + +
    + + ) } From ee6799a4373d964ded0bd02c9c0aed19f3e725e2 Mon Sep 17 00:00:00 2001 From: Isabell Date: Thu, 11 Sep 2025 11:04:57 +0200 Subject: [PATCH 22/26] Added component for view all teachers --- src/App.css | 5 ++++ src/components/profile-icon/index.js | 24 ++++++++++++++++++ src/components/profile-icon/style.css | 35 +++++++++++++++++++++++++++ src/pages/cohort/index.js | 12 ++++++--- src/pages/cohort/teachers/index.js | 21 +++++++++++++--- src/pages/cohort/teachers/style.css | 8 ++++++ 6 files changed, 97 insertions(+), 8 deletions(-) create mode 100644 src/components/profile-icon/index.js create mode 100644 src/components/profile-icon/style.css create mode 100644 src/pages/cohort/teachers/style.css diff --git a/src/App.css b/src/App.css index ec62bd1a..1222108c 100644 --- a/src/App.css +++ b/src/App.css @@ -14,3 +14,8 @@ .ReactModal__Html--open { overflow: hidden; } + +.border-line { + border-bottom: 1px solid var(--color-blue5); + padding: 20px 10px; +} diff --git a/src/components/profile-icon/index.js b/src/components/profile-icon/index.js new file mode 100644 index 00000000..d09ee716 --- /dev/null +++ b/src/components/profile-icon/index.js @@ -0,0 +1,24 @@ +import './style.css'; + +const UserIcon = ({initials, name, role}) => { + + return ( +
    +
    +
    +

    {initials}

    +
    +
    +
    +

    {name}

    +

    {role}

    +
    +
    +

    ...

    +
    +
    + + ); +} + +export default UserIcon; \ No newline at end of file diff --git a/src/components/profile-icon/style.css b/src/components/profile-icon/style.css new file mode 100644 index 00000000..52767713 --- /dev/null +++ b/src/components/profile-icon/style.css @@ -0,0 +1,35 @@ +.user { + display: flex; + flex-direction: row; + align-items: center; + gap: 12px; + width: 100%; + padding: 20px 10px; +} + +/* sirkel */ +.profile-circle{ + min-width: 40px; + height: 40px; + border-radius: 50%; + display: flex; + align-items: center; + justify-content: center; + background: #4cc0e5; +} + + +.user-name { + margin: 0; + white-space: nowrap; /* hindrer at navnet brytes om du vil */ + padding-top: 4px; + font-weight: 600; + font-size: 1.1rem; +} + +/* tre prikker helt til høyre */ +.edit-name { + margin-left: auto; /* skyver dette elementet til høyre */ +} + + diff --git a/src/pages/cohort/index.js b/src/pages/cohort/index.js index 6093e0b4..2763ded6 100644 --- a/src/pages/cohort/index.js +++ b/src/pages/cohort/index.js @@ -1,7 +1,11 @@ +import Teachers from './teachers'; + const Cohort = () => { - return ( -

    - ) + return( + <> + + + ); } -export default Cohort; \ No newline at end of file +export default Cohort; diff --git a/src/pages/cohort/teachers/index.js b/src/pages/cohort/teachers/index.js index 7c0e3373..b5c04927 100644 --- a/src/pages/cohort/teachers/index.js +++ b/src/pages/cohort/teachers/index.js @@ -1,7 +1,20 @@ -function Teachers() { +import Card from "../../../components/card"; +import './style.css'; +import UserIcon from "../../../components/profile-icon"; + +const Teachers = () => { + return ( - <> - ) + <> + +

    Teachers

    +
    + + +
    +
    + + ); } -export default Teachers; \ No newline at end of file +export default Teachers; diff --git a/src/pages/cohort/teachers/style.css b/src/pages/cohort/teachers/style.css new file mode 100644 index 00000000..9323386a --- /dev/null +++ b/src/pages/cohort/teachers/style.css @@ -0,0 +1,8 @@ +.card { + background: white; + padding: 24px; + border-radius: 8px; + width: 50%; + margin-bottom: 25px; + border: 1px #e6ebf5 solid; +} \ No newline at end of file From afbbbaafa3a76c603ead5155f253c685f720590b Mon Sep 17 00:00:00 2001 From: Moueed Ali Date: Thu, 11 Sep 2025 11:15:48 +0200 Subject: [PATCH 23/26] fix/fixed issue from Daves last comment --- src/pages/cohort/exercises/exercises.css | 23 ++++++++++++++++++++-- src/pages/cohort/exercises/index.js | 25 ++++++++++++++++++------ 2 files changed, 40 insertions(+), 8 deletions(-) diff --git a/src/pages/cohort/exercises/exercises.css b/src/pages/cohort/exercises/exercises.css index 37f3357f..e8764745 100644 --- a/src/pages/cohort/exercises/exercises.css +++ b/src/pages/cohort/exercises/exercises.css @@ -1,8 +1,27 @@ -.paragraph-text { +.value { + color: var(--color-blue1); + margin-bottom: 15px; +} + +.label { color: var(--color-blue1); margin-bottom: 15px; } .see-more-button { background-color: var(--color-blue5); -} \ No newline at end of file +} + +.exercise-row { + display: flex; + justify-content: space-between; + margin-bottom: 8px; +} + +.label { + font-weight: 500; +} + +.value { + color: var(--color-blue1); +} diff --git a/src/pages/cohort/exercises/index.js b/src/pages/cohort/exercises/index.js index 569953c7..e1b6a573 100644 --- a/src/pages/cohort/exercises/index.js +++ b/src/pages/cohort/exercises/index.js @@ -5,12 +5,25 @@ const Exercises = () => { return ( <> -

    My Exercises

    -
    -

    Modules:     2/7 completed

    -

    Units:          4/10 completed

    -

    Exercise:     34/58 completed

    - +

    My Exercises

    +
    + +
    + Modules: + 2/7 completed +
    + +
    + Units: + 4/10 completed +
    + +
    + Exercise: + 34/58 completed +
    + +
    ) From 3e710c1842660ac9eec820db57fc02b5b7614609 Mon Sep 17 00:00:00 2001 From: Isabell Date: Thu, 11 Sep 2025 13:55:31 +0200 Subject: [PATCH 24/26] Added function to three dots --- src/components/profile-icon/index.js | 25 +++++++++++----- src/components/profile-icon/style.css | 43 +++++++++++++++------------ src/components/seeProfile/index.js | 37 +++++++++++++++++++++++ src/components/seeProfile/style.css | 5 ++++ src/pages/cohort/teachers/index.js | 3 +- src/pages/welcome/stepOne/index.js | 5 ---- 6 files changed, 84 insertions(+), 34 deletions(-) create mode 100644 src/components/seeProfile/index.js create mode 100644 src/components/seeProfile/style.css diff --git a/src/components/profile-icon/index.js b/src/components/profile-icon/index.js index d09ee716..02eaf3cf 100644 --- a/src/components/profile-icon/index.js +++ b/src/components/profile-icon/index.js @@ -1,6 +1,8 @@ import './style.css'; +import SeeProfile from '../seeProfile'; +import Popup from 'reactjs-popup'; -const UserIcon = ({initials, name, role}) => { +const UserIcon = ({initials, firstname, lastname, role}) => { return (
    @@ -10,15 +12,22 @@ const UserIcon = ({initials, name, role}) => {
    -

    {name}

    +

    {firstname} {lastname}

    {role}

    -
    -

    ...

    -
    -
  • - - ); + +

    ...

    } position="right center" + closeOnDocumentClick + arrow={false}> + + +
    + ) } export default UserIcon; \ No newline at end of file diff --git a/src/components/profile-icon/style.css b/src/components/profile-icon/style.css index 52767713..a0dcbd6c 100644 --- a/src/components/profile-icon/style.css +++ b/src/components/profile-icon/style.css @@ -1,13 +1,17 @@ .user { - display: flex; - flex-direction: row; - align-items: center; - gap: 12px; - width: 100%; - padding: 20px 10px; + display: flex; + align-items: center; + padding: 8px 12px; + gap: 12px; +} + +.user-info { + display: flex; + flex-direction: column; + flex: 1 1 auto; + min-width: 0; } -/* sirkel */ .profile-circle{ min-width: 40px; height: 40px; @@ -20,16 +24,17 @@ .user-name { - margin: 0; - white-space: nowrap; /* hindrer at navnet brytes om du vil */ - padding-top: 4px; - font-weight: 600; - font-size: 1.1rem; -} - -/* tre prikker helt til høyre */ -.edit-name { - margin-left: auto; /* skyver dette elementet til høyre */ -} - + margin: 0; + font-weight: 600; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; +} +.pop-up { + position: absolute; + top: 100%; /* under .edit-icon */ + right: 0; /* høyrejustert med ikonet */ + margin-top: 8px; + z-index: 100; +} \ No newline at end of file diff --git a/src/components/seeProfile/index.js b/src/components/seeProfile/index.js new file mode 100644 index 00000000..bc8888df --- /dev/null +++ b/src/components/seeProfile/index.js @@ -0,0 +1,37 @@ +import Card from '../card'; +import './style.css'; +import { NavLink } from 'react-router-dom'; +import ProfileIcon from '../../assets/icons/profileIcon'; + +const SeeProfile = ({initials, firstname, lastname, role}) => { + + return ( +
    + +
    +
    +

    {initials}

    +
    + +
    +

    {firstname} {lastname}

    + {role}, Cohort 3 +
    +
    + +
    +
      +
    • + +

      Profile

      +
      +
    • +
    +
    +
    +
    + ) + +} + +export default SeeProfile; \ No newline at end of file diff --git a/src/components/seeProfile/style.css b/src/components/seeProfile/style.css new file mode 100644 index 00000000..0b4797a9 --- /dev/null +++ b/src/components/seeProfile/style.css @@ -0,0 +1,5 @@ + + +.card { + width: 450px; +} \ No newline at end of file diff --git a/src/pages/cohort/teachers/index.js b/src/pages/cohort/teachers/index.js index b5c04927..ea621275 100644 --- a/src/pages/cohort/teachers/index.js +++ b/src/pages/cohort/teachers/index.js @@ -9,8 +9,7 @@ const Teachers = () => {

    Teachers

    - - +
    diff --git a/src/pages/welcome/stepOne/index.js b/src/pages/welcome/stepOne/index.js index 0d5daaff..bc39174b 100644 --- a/src/pages/welcome/stepOne/index.js +++ b/src/pages/welcome/stepOne/index.js @@ -6,11 +6,6 @@ import TextInput from '../../../components/form/textInput'; import Card from '../../../components/card'; - - - - - const StepOne = ({ data, setData, handleFileChange }) => { return ( <> From 61fa1deb6301efc942b2e1e98499cb4c4585fb68 Mon Sep 17 00:00:00 2001 From: Linda Do Date: Fri, 12 Sep 2025 10:02:23 +0200 Subject: [PATCH 25/26] fixed issues with submit profile --- src/components/posts/index.js | 2 +- src/components/stepper/index.js | 9 ++++----- src/context/auth.js | 8 +++++--- src/pages/welcome/index.js | 26 +++++++++++++------------- src/pages/welcome/stepOne/index.js | 12 ++++++------ src/pages/welcome/stepThree/index.js | 4 ++-- src/pages/welcome/stepTwo/index.js | 2 -- src/service/apiClient.js | 10 ++++++++-- src/service/mockData.js | 12 ++++++------ 9 files changed, 45 insertions(+), 40 deletions(-) diff --git a/src/components/posts/index.js b/src/components/posts/index.js index 79756c41..675ca64b 100644 --- a/src/components/posts/index.js +++ b/src/components/posts/index.js @@ -15,7 +15,7 @@ const Posts = () => { return ( { const validateName = (data) => { if(!data) { - alert("OBSS!!! Please write Firstname and Lastname") + alert("OBSS!!! Please write first_name and last_name") return false } else { return true } } - + const validateUsername = (data) => { if(data.username.length < 7) { alert("Username is too short. Input must be at least 7 characters long") @@ -49,7 +49,6 @@ const Stepper = ({ header, children, onComplete, data }) => { } } - return ( {header} @@ -66,7 +65,7 @@ const Stepper = ({ header, children, onComplete, data }) => { text={currentStep === children.length - 1 ? 'Submit' : 'Next'} classes="blue" onClick={() => { - if (validateName(data.firstName) && validateName(data.lastName) &&validateUsername(data)) { + if (validateName(data.first_name) && validateName(data.last_name) &&validateUsername(data)) { onNextClick(); } }} @@ -91,4 +90,4 @@ const Stepper = ({ header, children, onComplete, data }) => { ); }; -export default Stepper; +export default Stepper; \ No newline at end of file diff --git a/src/context/auth.js b/src/context/auth.js index d1becd97..94f6fe94 100644 --- a/src/context/auth.js +++ b/src/context/auth.js @@ -45,15 +45,17 @@ const AuthProvider = ({ children }) => { const handleRegister = async (email, password) => { const res = await register(email, password); - setToken(res.data.token); + + localStorage.setItem('token', res.data.token); + setToken(res.data.token); navigate('/verification'); }; - const handleCreateProfile = async (firstName, lastName, githubUrl, bio) => { + const handleCreateProfile = async (first_name, last_name, username, github_username, mobile, bio, role, specialism, cohort, start_date, end_date, photo) => { const { userId } = jwt_decode(token); - await createProfile(userId, firstName, lastName, githubUrl, bio); + await createProfile(userId, first_name, last_name, username, github_username, mobile, bio, role, specialism, cohort, start_date, end_date, photo); localStorage.setItem('token', token); navigate('/'); diff --git a/src/pages/welcome/index.js b/src/pages/welcome/index.js index 838e37b5..cd6175ff 100644 --- a/src/pages/welcome/index.js +++ b/src/pages/welcome/index.js @@ -13,17 +13,17 @@ const Welcome = () => { const { formData } = useFormData(); const [profile, setProfile] = useState({ - firstName: '', - lastName: '', + first_name: '', + last_name: '', username: '', - githubUsername: '', + github_username: '', mobile: '', bio: '', - role: '', - specialism: '', - cohort: '', - startDate: '', - endDate: '', + role: 'ROLE_STUDENT', + specialism: 'Software Development', + cohort: 1, + start_date: '2025-09-14', + end_date: '2025-10-15', photo: '' }); @@ -38,17 +38,17 @@ const Welcome = () => { const onComplete = () => { onCreateProfile( - profile.firstName, - profile.lastName, + profile.first_name, + profile.last_name, profile.username, profile.mobile, - profile.githubUsername, + profile.github_username, profile.bio, profile.role, profile.specialism, profile.cohort, - profile.startDate, - profile.endDate, + profile.start_date, + profile.end_date, profile.photo ); }; diff --git a/src/pages/welcome/stepOne/index.js b/src/pages/welcome/stepOne/index.js index 0d5daaff..f2f00bbc 100644 --- a/src/pages/welcome/stepOne/index.js +++ b/src/pages/welcome/stepOne/index.js @@ -69,16 +69,16 @@ const StepOne = ({ data, setData, handleFileChange }) => {
    @@ -92,8 +92,8 @@ const StepOne = ({ data, setData, handleFileChange }) => { /> diff --git a/src/pages/welcome/stepThree/index.js b/src/pages/welcome/stepThree/index.js index ec5b8da4..de8daf58 100644 --- a/src/pages/welcome/stepThree/index.js +++ b/src/pages/welcome/stepThree/index.js @@ -27,12 +27,12 @@ const StepThree = ({ data, setData }) => { value={'Cohort 4'} /> diff --git a/src/pages/welcome/stepTwo/index.js b/src/pages/welcome/stepTwo/index.js index 2351e44e..e6073fb7 100644 --- a/src/pages/welcome/stepTwo/index.js +++ b/src/pages/welcome/stepTwo/index.js @@ -34,8 +34,6 @@ const StepTwo = ({ data, setData, formData }) => { label={'Password *'} type={'password'} /> - {console.log(formData.password)} -

    *Required

    diff --git a/src/service/apiClient.js b/src/service/apiClient.js index df36acac..c5870203 100644 --- a/src/service/apiClient.js +++ b/src/service/apiClient.js @@ -9,8 +9,14 @@ async function register(email, password) { return await login(email, password); } -async function createProfile(userId, firstName, lastName, githubUrl, bio) { - return await patch(`users/${userId}`, { firstName, lastName, githubUrl, bio }); +async function createProfile(userId, first_name, last_name, username, github_username, mobile, bio, role, specialism, cohort, start_date, end_date, photo) { + console.log(userId, first_name, last_name, username, github_username, mobile, bio, role, specialism, cohort, start_date, end_date, photo) + + cohort = parseInt(cohort) + photo = JSON.stringify(photo) + + await post(`profiles`, { userId, first_name, last_name, username, github_username, mobile, bio, role, specialism, cohort, start_date, end_date, photo }); + return await patch(`users/${userId}`, {}) } async function getPosts() { diff --git a/src/service/mockData.js b/src/service/mockData.js index d49e98a4..6b93d5f8 100644 --- a/src/service/mockData.js +++ b/src/service/mockData.js @@ -5,8 +5,8 @@ const user = { email: 'test@email.com', cohortId: 1, role: 'STUDENT', - firstName: 'Joe', - lastName: 'Bloggs', + first_name: 'Joe', + last_name: 'Bloggs', bio: 'Lorem ipsum dolor sit amet.', githubUrl: 'https://github.com/vherus' } @@ -23,8 +23,8 @@ const posts = [ id: 1, cohortId: 1, role: 'STUDENT', - firstName: 'Sam', - lastName: 'Fletcher', + first_name: 'Sam', + last_name: 'Fletcher', bio: 'Lorem ipsum dolor sit amet.', githubUrl: 'https://github.com/vherus' } @@ -39,8 +39,8 @@ const posts = [ id: 2, cohortId: 1, role: 'STUDENT', - firstName: 'Dolor', - lastName: 'Lobortis', + first_name: 'Dolor', + last_name: 'Lobortis', bio: 'Lorem ipsum dolor sit amet.', githubUrl: 'https://github.com/vherus' }, From 09511d21320e589e09af3a3d14fa2c2b5c6814a3 Mon Sep 17 00:00:00 2001 From: Emanuels Zaurins Date: Fri, 12 Sep 2025 15:58:43 +0200 Subject: [PATCH 26/26] fixed so that we see posts --- src/components/posts/index.js | 21 ++++++++++++++++++--- src/service/apiClient.js | 1 + 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/components/posts/index.js b/src/components/posts/index.js index 675ca64b..f68a3450 100644 --- a/src/components/posts/index.js +++ b/src/components/posts/index.js @@ -6,17 +6,32 @@ const Posts = () => { const [posts, setPosts] = useState([]); useEffect(() => { - getPosts().then(setPosts); + async function fetchPosts() { + try { + const posts = await getPosts(); + setPosts(posts); + } catch (error) { + console.error('Error fetching posts:', error); + setPosts([]); + } + } + fetchPosts(); }, []); + return ( <> {posts.map((post) => { + // Handle missing author gracefully + const authorName = post.author + ? `${post.author.first_name || 'Unknown'} ${post.author.last_name || 'User'}` + : 'Unknown User'; + return ( diff --git a/src/service/apiClient.js b/src/service/apiClient.js index c5870203..bd58f1e1 100644 --- a/src/service/apiClient.js +++ b/src/service/apiClient.js @@ -21,6 +21,7 @@ async function createProfile(userId, first_name, last_name, username, github_use async function getPosts() { const res = await get('posts'); + console.log(res.data.posts + " <- this is from apiClient.js"); return res.data.posts; }