From f1f1a7fa683eca8c49c0ee44fd9acfe75cba7990 Mon Sep 17 00:00:00 2001 From: CanbiZ <47820557+MickLesk@users.noreply.github.com> Date: Thu, 23 Jan 2025 09:27:58 +0100 Subject: [PATCH] dev: add category view --- frontend/src/app/category-view/index.tsx | 66 ++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 frontend/src/app/category-view/index.tsx diff --git a/frontend/src/app/category-view/index.tsx b/frontend/src/app/category-view/index.tsx new file mode 100644 index 00000000..23178b11 --- /dev/null +++ b/frontend/src/app/category-view/index.tsx @@ -0,0 +1,66 @@ +// Folder: category-view +// File: index.tsx + +import React, { useState } from 'react'; +import { Card, CardContent, CardHeader } from '@/components/ui/card'; +import { Button } from '@/components/ui/button'; +import { Grid } from '@/components/ui/grid'; +import routes from '@/routes'; // Assuming your route.ts file is at this location + +const CategoryView = () => { + const [selectedCategory, setSelectedCategory] = useState(null); + + const handleCategoryClick = (category) => { + setSelectedCategory(category); + }; + + const handleBackClick = () => { + setSelectedCategory(null); + }; + + const categories = routes.map((route) => ({ + name: route.category, + scripts: route.scripts.map((script) => ({ + name: script.name, + date: script.date || 'N/A', // Assuming scripts have a `date` field + })), + })); + + return ( +
+ {selectedCategory ? ( +
+ +

{selectedCategory.name}

+ + {selectedCategory.scripts + .sort((a, b) => a.name.localeCompare(b.name)) + .map((script) => ( + + +

{script.name}

+

{script.date}

+
+
+ ))} +
+
+ ) : ( +
+

Categories

+ + {categories.map((category) => ( + handleCategoryClick(category)} className="cursor-pointer hover:shadow-lg"> + + + ))} + +
+ )} +
+ ); +}; + +export default CategoryView; \ No newline at end of file