Skip to content

Commit

Permalink
Merge pull request #78 from RbAvci/RbAvci-Frontend---Display-all-user…
Browse files Browse the repository at this point in the history
…s-for-Mentor-/-recruiter

#68-Frontend - Display all users for Mentor / recruiter- Rabia Avci
  • Loading branch information
taiwo2 authored Aug 1, 2024
2 parents 8f3b758 + b9ac5d1 commit a08b287
Show file tree
Hide file tree
Showing 9 changed files with 313 additions and 8 deletions.
35 changes: 28 additions & 7 deletions client/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -22,12 +22,33 @@ const App = () => (
<Route path="/about/this/site" element={<About />} />
<Route path="/signup" element={<SignUp />} />
<Route path="/signIn" element={<SignIn />} />
<Route path="/info/:id" element={<InfoPage />} />
<Route path="/profile/:id" element={<Profile />} />

{/* <Route path="/unauthorized" element={<Unauthorized />} /> */}
{/* <Route path="/grad-dashboard" element={<Protected element={GradDashboard} roles={["graduate", "mentor", "recruiter"]} />} /> */}

<Route
path="/info/:id"
element={
<Protected
element={InfoPage}
roles={["graduate", "mentor", "recruiter"]}
/>
}
/>
<Route
path="/profile/:id"
element={
<Protected
element={Profile}
roles={["graduate", "mentor", "recruiter"]}
/>
}
/>
<Route
path="/mentor-dashboard"
element={
<Protected
element={MentorDashboard}
roles={["mentor", "recruiter"]}
/>
}
/>
<Route path="/unauthorised" element={<Unauthorised />} />

<Route
Expand Down
42 changes: 42 additions & 0 deletions client/src/components/GradsCards/GradCard.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
.grad-card {
border: 1px solid #DEDEDE;
text-align: center;
width: 220px;
text-decoration: none;
color: #333333;
transition: box-shadow 0.3s ease;
border-radius: 3rem;
box-shadow: 0 5px 20px 10px rgba(0, 0, 0, 0.1);
margin: 2rem;
padding: 1rem;
display: flex;
flex-direction: column;
align-items: center;
}

.grad-card img {
border-radius: 50%;
width: 150px;
height: 150px;
margin-bottom: 10px;
}

.grad-card h3 {
margin: 10px 0;
font-size: 1.2em;
color: #333333;
}

.grad-card p {
margin: 5px 0;
color: #888888;
}

.grad-card:hover {
box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
}

.grad-card a {
text-decoration: none;
color: #333333;
}
18 changes: 18 additions & 0 deletions client/src/components/GradsCards/GradCard.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import React from "react";
import { Link } from "react-router-dom";
import "./GradCard.css";

const GradCard = ({ grad }) => {
return (
<Link to={`/profile/${grad.id}`} className="grad-card" key={grad.id}>
<img
src={`https://github.com/${grad.github_username}.png`}
alt={`${grad.username}'s Avatar`}
/>
<h3>{grad.username}</h3>
<p>Activity Score: </p>
</Link>
);
};

export default GradCard;
8 changes: 8 additions & 0 deletions client/src/index.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
<!doctype html>
<html lang="en">
<head>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css">

<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=Lato:ital,wght@0,100;0,300;0,400;0,700;0,900;1,100;1,300;1,400;1,700;1,900&family=Raleway:ital,wght@0,100..900;1,100..900&family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap"
rel="stylesheet"
/>
<meta charset="UTF-8" />
<meta name="viewport" content="initial-scale=1, width=device-width" />
<title>Read me Hire me</title>
Expand Down
135 changes: 135 additions & 0 deletions client/src/pages/MentorDashboard.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
.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;
}

.header-links a:hover {
text-decoration: underline;
color: #333333;
}

#filter-search {
display: flex;
align-items: center;
justify-content: center;
gap: 10px;
padding: 1rem;
border-radius: 1rem;
box-shadow: 0 5px 20px 10px rgba(0, 0, 0, 0.2);
margin-bottom: 20px;
}

#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;
padding-left: 50px;
}

#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;
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);
}

#show-all-grads {
padding: 10px 15px;
background-color: #EE4434;
color: white;
font-weight: bold;
border: none;
border-radius: 5px;
cursor: pointer;
}

#show-all-grads:hover {
background-color: #d32f2f;
}

.search-container {
position: relative;
}

.search-icon {
position: absolute;
top: 50%;
left: 10px;
transform: translateY(-50%);
color: #888888;
pointer-events: none;
}

#search {
padding-left: 30px;
}
67 changes: 67 additions & 0 deletions client/src/pages/MentorDashboard.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import React, { useState, useEffect } from "react";
import "./MentorDashboard.css";
import GradCard from "../components/GradsCards/GradCard";
import "@fortawesome/fontawesome-free/css/all.min.css";

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 (
<div className="mentor-dashboard">
<header>
<h1>Welcome Mentor</h1>
<div className="header-links">
<a href="/settings">Settings</a>
<a href="/logout">Logout</a>
</div>
</header>

<section id="filter-search">
<div className="search-container">
<i className="fas fa-search search-icon"></i>
<input
type="text"
id="search"
placeholder="Search by name & skill..."
/>
</div>
<input type="text" id="skill-filter" placeholder="Filter by skill..." />
<div className="sort-select-container">
<select id="sort-order">
<option value="">Sort by activity score</option>
<option value="asc">Ascending</option>
<option value="desc">Descending</option>
</select>
</div>
<button id="show-all-grads">Show All Grads</button>
</section>

<section id="grads-cards">
{grads.map((grad) => (
<GradCard grad={grad} key={grad.id} />
))}
</section>
</div>
);
};

export default MentorDashboard;
6 changes: 5 additions & 1 deletion client/src/pages/SignIn.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`);
}
Expand Down
9 changes: 9 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit a08b287

Please sign in to comment.