();
+
+ const [pageSize, setPageSize] = useState(20);
+ const [previousData, setPreviousData] = useState<{
+ items: TagDetails[];
+ totalItems: number;
+ }>({ items: [], totalItems: 0 });
+
+ const {
+ data: tagSearchData,
+ isLoading,
+ error,
+ } = useSearchTags(
+ {
+ queryParams: { q: "", pageSize },
+ },
+ { enabled: true },
+ );
+
+ useEffect(() => {
+ if (tagSearchData?.data) {
+ const availableTags = (tagSearchData.data as { items: TagDetails[] })
+ .items;
+
+ // Filter tags by the typeId
+ const filteredTags = availableTags.filter(
+ (tag) => tag.tagType === typeId,
+ );
+
+ setTags(filteredTags);
+
+ // Set the tag type name and description
+ if (filteredTags.length > 0) {
+ setTagTypeId(typeId);
+ //setTagDescription(`Description for ${typeId} tags.`); // Replace with actual description if available
+ } else {
+ setTagTypeId("Unknown Tag Type");
+ //setTagDescription("No description available for this tag type.");
+ }
+ }
+ }, [tagSearchData, typeId]);
+
+ useEffect(() => {
+ if (tagSearchData?.data && !isLoading) {
+ setPreviousData(tagSearchData.data as typeof previousData);
+ }
+ }, [tagSearchData, isLoading]);
+
+ const searchResultData =
+ (tagSearchData?.data as {
+ items?: TagDetails[];
+ totalItems?: number;
+ }) || previousData;
+
+ const next = () => {
+ setPageSize(pageSize + 20);
+ };
+
+ //descriptions for the tag types
+ const getDescription = (TypeId: string) => {
+ switch (TypeId) {
+ case "Programming Language":
+ return (
+
+ A programming language is a formal system used to communicate
+ instructions to a machine, particularly a computer. It consists of
+ syntax, semantics, and rules that allow developers to write software
+ and algorithms. Programming languages enable the creation of
+ programs that can execute tasks ranging from simple calculations to
+ complex data processing and system management. Well-known examples
+ include Python, Java, and C++.
+
+ );
+ case "Programming Paradigm":
+ return (
+
+ A programming paradigm refers to a fundamental style or approach to
+ programming that influences how software is structured and
+ developed. It encompasses the methodologies and principles that
+ guide the design and implementation of programs, including
+ object-oriented programming, functional programming, and procedural
+ programming. Different paradigms offer distinct ways of thinking
+ about and solving problems in software development.
+
+ );
+ case "Computer Science Term":
+ return (
+
+ A computer science term is a word or phrase that is part of the
+ technical vocabulary of computer science. These terms represent
+ concepts, theories, tools, or techniques that are essential to
+ understanding the field. Examples include terms like algorithm, data
+ structure, machine learning, and artificial intelligence. These
+ terms form the foundation of communication and learning within the
+ computer science discipline.
+
+ );
+ case "Software Library":
+ return (
+
+ A software library is a collection of pre-written code, functions,
+ and resources that developers can use to perform common tasks
+ without having to write code from scratch. Libraries are designed to
+ provide reusable components for tasks such as data manipulation,
+ user interface design, and network communication. Popular software
+ libraries include jQuery for web development, TensorFlow for machine
+ learning, and NumPy for numerical computations.
+
+ );
+ }
+ };
+
+ const description = typeId ? (
+ getDescription(typeId)
+ ) : (
+ Loading description...
+ );
+
+ if (error) {
+ return ;
+ }
+
+ return (
+
+ {isLoading ? (
+
+
+
+ ) : (
+ <>
+ {/* Header */}
+
{tagTypeId}
+
+ {/* Render the description based on typeId */}
+
{description}
+
+ {/* Tags in this Category Section */}
+
+ Tags in This Category:
+
+
+ {/* Infinite Scroll for displaying Related Tags */}
+
+
pageSize
+ : false
+ }
+ isLoading={isLoading}
+ >
+ {tags.length > 0 ? (
+ tags.map((tag) => )
+ ) : (
+
+ No related tags found for this tag type.
+
+ )}
+
+
+ >
+ )}
+
+ );
+}
diff --git a/frontend/src/routes/glossary.tsx b/frontend/src/routes/glossary.tsx
new file mode 100644
index 0000000..d05b245
--- /dev/null
+++ b/frontend/src/routes/glossary.tsx
@@ -0,0 +1,89 @@
+import { TagSubtypeCard } from "@/components/SubtypeCard";
+import { useSearchTags } from "@/services/api/programmingForumComponents";
+import { TagDetails } from "@/services/api/programmingForumSchemas";
+import { Loader2 } from "lucide-react";
+import { useEffect, useState } from "react";
+import ErrorAlert from "@/components/ErrorAlert";
+
+export default function GlossaryPage() {
+ const [tagCounts, setTagCounts] = useState<
+ { typeId: string; tagCount: number; description: string }[] // Added description field
+ >([]);
+ const [, setAvailableTags] = useState([]);
+
+ const {
+ data: tagSearchData,
+ isLoading,
+ error,
+ } = useSearchTags(
+ { queryParams: { q: "", pageSize: 400 } },
+ { enabled: true },
+ );
+
+ useEffect(() => {
+ if (tagSearchData?.data) {
+ // Extract available tags
+ const tags = (tagSearchData.data as { items: TagDetails[] }).items;
+ setAvailableTags(tags);
+
+ // Define the 4 tag types with descriptions from wikidata
+ const tagTypes = [
+ {
+ typeId: "Programming Language",
+ description: "language for communicating instructions to a machine",
+ },
+ {
+ typeId: "Software Library",
+ description:
+ "collection of non-volatile resources used by computer programs, often for software development",
+ },
+ {
+ typeId: "Programming Paradigm",
+ description:
+ "category of programming languages according to what methodology of designing and implementing programs their features support",
+ },
+ {
+ typeId: "Computer Science Topic",
+ description:
+ "technical term; word or phrase that is part of computer science terminology",
+ },
+ ];
+
+ // group and count tags by tagType
+ const counts = tagTypes.map((type) => {
+ const filteredTags = tags.filter((tag) => tag.tagType === type.typeId);
+ return {
+ typeId: type.typeId,
+ tagCount: filteredTags.length,
+ description: type.description,
+ };
+ });
+
+ setTagCounts(counts);
+ }
+ }, [tagSearchData]);
+
+ if (error) {
+ return ;
+ }
+
+ return (
+
+
Explore Various Tag Types
+
+ {tagCounts.map((tagCount) => (
+
+ ))}
+
+ {isLoading && (
+
+
+
+ )}
+
+
+ );
+}
diff --git a/frontend/src/routes/index.tsx b/frontend/src/routes/index.tsx
index cc042e4..a89fddd 100644
--- a/frontend/src/routes/index.tsx
+++ b/frontend/src/routes/index.tsx
@@ -13,6 +13,8 @@ import { Search } from "./search";
import Signup from "./signup";
import TagPage from "./tag";
import { BookmarkedQuestions } from "@/routes/bookmarks";
+import Glossary from "./glossary";
+import TagTypePage from "@/components/TagType";
export const routes: RouteObject[] = [
{
@@ -66,6 +68,14 @@ export const routes: RouteObject[] = [
path: "/tags/new",
Component: CreateTagPage,
},
+ {
+ path: "/glossary",
+ Component: Glossary,
+ },
+ {
+ path: "/tagtype/:typeId",
+ Component: TagTypePage,
+ },
];
export const routeConfig: RouteObject[] = [
diff --git a/frontend/src/routes/tag.test.tsx b/frontend/src/routes/tag.test.tsx
index 38ce66b..a19b049 100644
--- a/frontend/src/routes/tag.test.tsx
+++ b/frontend/src/routes/tag.test.tsx
@@ -100,14 +100,14 @@ describe("TagPage", () => {
token: "mock-token",
});
- render(
-
-
- } />
-
- ,
- );
+ render(
+
+
+ } />
+
+ ,
+ );
- expect(screen.getByRole("button", { name: /follow/i })).toBeInTheDocument();
- });
+ expect(screen.getByRole("button", { name: /follow/i })).toBeInTheDocument();
+ });
});
diff --git a/frontend/src/routes/tag.tsx b/frontend/src/routes/tag.tsx
index 6604933..0fe839a 100644
--- a/frontend/src/routes/tag.tsx
+++ b/frontend/src/routes/tag.tsx
@@ -106,7 +106,8 @@ export default function TagPage() {
tagId: tagId!,
following: tag.following,
}}
- />)}
+ />
+ )}