Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reverted to old change #91

Merged
merged 3 commits into from
Jul 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 13 additions & 12 deletions src/app/projects/page.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use client';

import { Grid, Column, Search, FilterableMultiSelect, Row } from "@carbon/react";
import React, { useState, useEffect } from "react";
import React, { useState } from "react";
import ProjectsTiles from "./ProjectsTiles";

import data from "../../../repoData.json";
Expand All @@ -17,8 +17,13 @@ repoData.forEach((node) => {
});
const topicsArray = Array.from(topics);

// Parse URL parameters outside the component
const urlParams = new URLSearchParams(window.location.search);
const topic = urlParams.get('topic');
const initialSelectedTopics = topic ? [topic] : [];

function ProjectsPage() {
const [selectedTopics, setSelectedTopics] = useState([]);
const [selectedTopics, setSelectedTopics] = useState(initialSelectedTopics);

// Define the renderProjects function
let renderProjects = () => {
Expand All @@ -34,17 +39,13 @@ function ProjectsPage() {
};

//this function calls renderProjects initially to reflect initial selection
useEffect(() => {
if (typeof window !== "undefined") {
const urlParams = new URLSearchParams(window.location.search);
const topic = urlParams.get('topic');
if (topic) {
setSelectedTopics([topic]);
filterProjectsByTag(topic);
}
React.useEffect(() => {
if (topic) {
filterProjectsByTopic(topic);
}
}, []);


let searchProjects = (e) => {
const inputText = e.target.value.toLowerCase();
repoData.forEach((node) => {
Expand Down Expand Up @@ -86,8 +87,8 @@ function ProjectsPage() {
renderProjects();
};

// Define the filterProjectsByTag function
let filterProjectsByTag = (topic) => {
// Define the filterProjectsByTopic function
let filterProjectsByTopic = (topic) => {
repoData.forEach((node) => {
var nodeTopics = node.repositoryTopics.nodes.map((topic) => topic.topic.name);
var inRepo = nodeTopics.includes(topic);
Expand Down
Loading