From 77365b16cd2b51300058f85ff12bc67fc6421c38 Mon Sep 17 00:00:00 2001
From: Advait Rajaram Patole
Date: Fri, 12 Apr 2024 08:26:04 +0530
Subject: [PATCH] Added filters for projects
---
frontend/src/components/ProjectCard.js | 4 +-
frontend/src/pages/Projects.jsx | 119 ++++++++++++++++++++-----
2 files changed, 97 insertions(+), 26 deletions(-)
diff --git a/frontend/src/components/ProjectCard.js b/frontend/src/components/ProjectCard.js
index c257e56..a5dcf65 100644
--- a/frontend/src/components/ProjectCard.js
+++ b/frontend/src/components/ProjectCard.js
@@ -18,9 +18,9 @@ function ProjectCard(props) {
{props.title}
-
+ {/*
{props.description}
-
+
*/}
diff --git a/frontend/src/pages/Projects.jsx b/frontend/src/pages/Projects.jsx
index 838422b..c26d53d 100644
--- a/frontend/src/pages/Projects.jsx
+++ b/frontend/src/pages/Projects.jsx
@@ -2,6 +2,7 @@ import ProjectCard from "../components/ProjectCard"
import axios from "axios";
import { useEffect } from "react";
import { useState } from "react";
+import { useMemo } from "react";
import "../components/ProjectCard.css";
import {Outlet} from 'react-router-dom'
@@ -22,34 +23,104 @@ export default function Projects() {
});
}, []);
- return (
+// const details = [
+// {
+// "id": 1,
+// "title": "Speech emotion recognition",
+// "general_category": "ML",
+// "banner_image": "http://127.0.0.1:8000/media/projects/emotion_detection.png"
+// },
+// {
+// "id": 2,
+// "title": "Test Project",
+// "general_category": "Development",
+// "banner_image": "http://127.0.0.1:8000/media/projects/For_his_participation_in_the_5-day_Grand_Entrepreneur_Workshop_held_by_Liceria__Co..png"
+// },
+// {
+// "id": 3,
+// "title": "Speech emotion recognition",
+// "general_category": "Blockchain",
+// "banner_image": "http://127.0.0.1:8000/media/projects/emotion_detection.png"
+// },
+// {
+// "id": 4,
+// "title": "Test Project",
+// "general_category": "CP",
+// "banner_image": "http://127.0.0.1:8000/media/projects/For_his_participation_in_the_5-day_Grand_Entrepreneur_Workshop_held_by_Liceria__Co..png"
+// },
+// {
+// "id": 5,
+// "title": "Test Project",
+// "general_category": "Others",
+// "banner_image": "http://127.0.0.1:8000/media/projects/For_his_participation_in_the_5-day_Grand_Entrepreneur_Workshop_held_by_Liceria__Co..png"
+// }
+// ]
+
+// GeneralCategoryChoices = (
+// ('ML', 'ML'),
+// ('Developement', 'Development'),
+// ('Blockchain', 'Blockchain'),
+// ('CP', 'CP'),
+// ('Others', 'Others'),
+// )
+
+
+
+ const [filterValue, setFilterValue] = useState('All');
+
+ const filteredProjects = useMemo(() => {
+ return details.filter(project => project.general_category.includes(filterValue) || filterValue==="All");
+ }, [details, filterValue]);
+
+ const handleFilterChange = (value) => {
+ setFilterValue(value);
+ };
+
+ const [active, setActive] = useState('b1');
+
+
+ return (
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+ {/*
*/}
- {details.map((details, index) => (
+ {/* {details.map((details, index) => (
+
+ ))} */}
+ {filteredProjects.map((project, index) =>(
))}