From 63de8eed79910fbf32a65a779e6de3477781e297 Mon Sep 17 00:00:00 2001 From: RbAvci Date: Wed, 31 Jul 2024 20:59:07 +0100 Subject: [PATCH 1/3] add getAllGradUsers endpoint --- server/api.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/server/api.js b/server/api.js index dcce01b0..834c8dae 100644 --- a/server/api.js +++ b/server/api.js @@ -203,5 +203,26 @@ router.put( } } ); + + +router.get( + "/getAllGradUsers", + roleBasedAuth ("mentor", "recruiter"), + async (_, res) => { + try { + const result = await db.query( + "SELECT id, username, github_username FROM users WHERE user_type = 'graduate'" + ); + res.status(200).json({ success: true, data: result.rows }); + } catch (error) { + res.status(500).json({ + success: false, + error: "Failed to fetch User from the database", + }); + } + } +); + + router.use("/info", infoRouter); export default router; From 465a6734ec9d6273cd1dec7b97bcdecf0ceaebf3 Mon Sep 17 00:00:00 2001 From: RbAvci Date: Thu, 1 Aug 2024 01:07:06 +0100 Subject: [PATCH 2/3] created mentor dashboard --- client/src/App.js | 35 ++++-- client/src/components/GradsCards/GradCard.css | 42 +++++++ client/src/components/GradsCards/GradCard.js | 18 +++ client/src/index.html | 6 + client/src/pages/MentorDashboard.css | 105 ++++++++++++++++++ client/src/pages/MentorDashboard.js | 60 ++++++++++ client/src/pages/SignIn.js | 6 +- 7 files changed, 264 insertions(+), 8 deletions(-) create mode 100644 client/src/components/GradsCards/GradCard.css create mode 100644 client/src/components/GradsCards/GradCard.js create mode 100644 client/src/pages/MentorDashboard.css create mode 100644 client/src/pages/MentorDashboard.js diff --git a/client/src/App.js b/client/src/App.js index d4f6ff42..7beda937 100644 --- a/client/src/App.js +++ b/client/src/App.js @@ -9,7 +9,7 @@ import SignIn from "./pages/SignIn"; import UpdatePasswordForm from "./pages/UpdatePasswordForm"; import InfoPage from "./components/Info/InfoPage"; import Profile from "./components/Profile/Profile"; -// import { Protected } from "./pages/Protected"; +import MentorDashboard from "./pages/MentorDashboard"; import { Protected } from "./components/Protected"; import Unauthorised from "./pages/Unauthorised"; @@ -22,12 +22,33 @@ const App = () => ( } /> } /> } /> - } /> - } /> - - {/* } /> */} - {/* } /> */} - + + } + /> + + } + /> + + } + /> } /> { + return ( + + {`${grad.username}'s +

{grad.username}

+

Activity Score:

+ + ); +}; + +export default GradCard; diff --git a/client/src/index.html b/client/src/index.html index 15db5ed9..3111bff6 100644 --- a/client/src/index.html +++ b/client/src/index.html @@ -1,6 +1,12 @@ + + + Read me Hire me diff --git a/client/src/pages/MentorDashboard.css b/client/src/pages/MentorDashboard.css new file mode 100644 index 00000000..27493ccd --- /dev/null +++ b/client/src/pages/MentorDashboard.css @@ -0,0 +1,105 @@ +.mentor-dashboard { + font-family: 'Arial', sans-serif; + padding: 20px; + background-color: #F9F9F9; + min-height: 100vh; +} + +.mentor-dashboard header { + display: flex; + justify-content: space-between; + align-items: center; + padding: 20px; + margin-top: 75px + ; +} + +.mentor-dashboard header h1 { + font-family: "Lato", sans-serif; + font-weight: 300; + color: #333333; + text-decoration: none; +} + +.header-links a { + margin-left: 20px; + text-decoration: none; + color: #333333; + font-size: 16px; + font-family: "Lato", sans-serif; + font-weight: 400; + font-style: normal; + +} + +.header-links a:hover { + text-decoration: underline; + color: #333333; +} + +#filter-search { + display: flex; + align-items: center; + justify-content: center; + gap: 3rem; + padding: 1rem; + border-radius: 1rem; + box-shadow: 0 5px 20px 10px rgba(0, 0, 0, 0.2); +} + +#filter-search input, +#filter-search select { + width: 100%; + max-width: 300px; + padding: 10px; + margin: 10px 0; + border: 1px solid #A9A9A9; + border-radius: 4px; + box-sizing: border-box; +} + +#filter-search input:focus, +#filter-search select:focus { + border-color: #EE4434; +} + +#grads-cards { + display: flex; + flex-wrap: wrap; + justify-content: center; + gap: 20px; +} + +.grad-card { + display: block; + background-color: #ffffff; + padding: 20px; + border: 1px solid #DEDEDE; + border-radius: 10px; + box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); + text-align: center; + width: 220px; + text-decoration: none; + color: #333333; + transition: box-shadow 0.3s ease; +} + +.grad-card img { + border-radius: 50%; + width: 100px; + height: 100px; + margin-bottom: 10px; } + +.grad-card h3 { + margin: 10px 0; + font-size: 1.2em; +} + +.grad-card p { + margin: 5px 0; + color: #888888; +} + +.grad-card:hover { + box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2); +} \ No newline at end of file diff --git a/client/src/pages/MentorDashboard.js b/client/src/pages/MentorDashboard.js new file mode 100644 index 00000000..7c13943f --- /dev/null +++ b/client/src/pages/MentorDashboard.js @@ -0,0 +1,60 @@ +import React, { useState, useEffect } from "react"; +import "./MentorDashboard.css"; +import GradCard from "../components/GradsCards/GradCard"; + +const MentorDashboard = () => { + const [grads, setGrads] = useState([]); + + useEffect(() => { + fetch("api/getAllGradUsers", { + headers: { + "Content-Type": "application/json", + Authorization: `Bearer ${localStorage.getItem("token")}`, + }, + }) + .then((response) => response.json()) + .then((data) => { + console.log(JSON.stringify(data)); + if (data.success) { + setGrads(data.data); + } else { + console.error("Failed to fetch graduate users"); + } + }) + .catch((error) => console.error("Error fetching graduate users:", error)); + }, []); + + return ( +
+
+

Welcome Mentor

+ +
+ + + +
+ {grads.map((grad) => ( + + ))} +
+
+ ); +}; + +export default MentorDashboard; diff --git a/client/src/pages/SignIn.js b/client/src/pages/SignIn.js index a8a9804a..3dbf574a 100644 --- a/client/src/pages/SignIn.js +++ b/client/src/pages/SignIn.js @@ -41,7 +41,11 @@ const SignIn = () => { if (result.success) { localStorage.setItem("token", result.data.user.token); - navigate(`/info/${result.data.id}`); + if (result.data.user.user_type === "mentor") { + navigate("/mentor-dashboard"); + } else if (result.data.user.user_type === "graduate") { + navigate(`/info/${result.data.id}`); + } } else { setMessage(`Error: ${result.message}`); } From b9ac5d17b380f21943850396b134c6ed6903c71a Mon Sep 17 00:00:00 2001 From: RbAvci Date: Thu, 1 Aug 2024 11:10:02 +0100 Subject: [PATCH 3/3] add show all grads button & some css --- client/src/index.html | 2 ++ client/src/pages/MentorDashboard.css | 50 ++++++++++++++++++++++------ client/src/pages/MentorDashboard.js | 27 +++++++++------ package-lock.json | 9 +++++ package.json | 1 + 5 files changed, 69 insertions(+), 20 deletions(-) diff --git a/client/src/index.html b/client/src/index.html index 3111bff6..b0bd1751 100644 --- a/client/src/index.html +++ b/client/src/index.html @@ -1,6 +1,8 @@ + + { const [grads, setGrads] = useState([]); @@ -35,17 +36,23 @@ const MentorDashboard = () => {
diff --git a/package-lock.json b/package-lock.json index 56c78dd7..d37162bc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,6 +10,7 @@ "license": "ISC", "dependencies": { "@babel/runtime": "^7.22.15", + "@fortawesome/fontawesome-free": "^6.6.0", "dotenv": "^16.3.1", "express": "^4.18.2", "helmet": "^7.0.0", @@ -2064,6 +2065,14 @@ "node": "^12.22.0 || ^14.17.0 || >=16.0.0" } }, + "node_modules/@fortawesome/fontawesome-free": { + "version": "6.6.0", + "resolved": "https://registry.npmjs.org/@fortawesome/fontawesome-free/-/fontawesome-free-6.6.0.tgz", + "integrity": "sha512-60G28ke/sXdtS9KZCpZSHHkCbdsOGEhIUGlwq6yhY74UpTiToIh8np7A8yphhM4BWsvNFtIvLpi4co+h9Mr9Ow==", + "engines": { + "node": ">=6" + } + }, "node_modules/@hapi/hoek": { "version": "9.3.0", "resolved": "https://registry.npmjs.org/@hapi/hoek/-/hoek-9.3.0.tgz", diff --git a/package.json b/package.json index ec277860..7d380513 100644 --- a/package.json +++ b/package.json @@ -73,6 +73,7 @@ }, "dependencies": { "@babel/runtime": "^7.22.15", + "@fortawesome/fontawesome-free": "^6.6.0", "dotenv": "^16.3.1", "express": "^4.18.2", "helmet": "^7.0.0",