diff --git a/01-frontend/src/helper/homepage/FilterItem.tsx b/01-frontend/src/helper/homepage/FilterItem.tsx index 0f06a6c..b940ea4 100644 --- a/01-frontend/src/helper/homepage/FilterItem.tsx +++ b/01-frontend/src/helper/homepage/FilterItem.tsx @@ -1,17 +1,25 @@ import { FormControl, FormControlLabel, Radio, RadioGroup, Rating } from "@mui/material"; import React from "react"; +type FilterItemProps = { + filterName: string; + filterItems: any[]; + value?: string | null; + onChange?: (value: string) => void; +}; + export default function FilterItem({ filterName, filterItems, -}: { - filterName: string; - filterItems: any[]; -}) { - const [value, setValue] = React.useState(filterItems[0]); + value, + onChange +}: FilterItemProps) { + if(!value) { + value = filterItems[0]; + } const handleChange = (event: React.ChangeEvent) => { - setValue(event.target.value); + value = (event.target.value); }; return ( diff --git a/01-frontend/src/pages/Category.tsx b/01-frontend/src/pages/Category.tsx index 926e3a6..1bd40b7 100644 --- a/01-frontend/src/pages/Category.tsx +++ b/01-frontend/src/pages/Category.tsx @@ -1,34 +1,68 @@ -import { Box, Typography, Button } from "@mui/material"; +import CategoryIcon from "@mui/icons-material/Category"; +import PrecisionManufacturingIcon from "@mui/icons-material/PrecisionManufacturing"; +import ScienceIcon from "@mui/icons-material/Science"; +import SpaIcon from "@mui/icons-material/Spa"; +import { Box, Card, CardActionArea, CardContent, Grid, Typography } from "@mui/material"; import { useNavigate } from "react-router-dom"; import "./pages.css"; +const categories = [ + { + name: "Seeds", + icon: , + filter: "Seeds" + }, + { + name: "Fertilizers", + icon: , + filter: "Fertilizers" + }, + { + name: "Technical Components", + icon: , + filter: "Technical Components" + }, + { + name: "Sonstiges", + icon: , + filter: "Other" + } +]; + export default function Category() { const navigate = useNavigate(); - const handleGoHome = () => { - navigate("/"); + const handleCategoryClick = (filter: string) => { + // Navigiere zur Home-Seite und übergebe die gewählte Kategorie als Query-Parameter + navigate(`/?category=${encodeURIComponent(filter)}`); }; return ( - - - Category + + + Kategorien entdecken - - Oops! The page you're looking for doesn't exist. + + Wähle eine Kategorie, um passende Produkte zu entdecken. - - It seems you may have taken a wrong turn. Let's get you back on track. - - + + {categories.map((cat) => ( + + + handleCategoryClick(cat.filter)}> + + {cat.icon} + + + {cat.name} + + + + + + + ))} + ); } \ No newline at end of file diff --git a/01-frontend/src/pages/Home.tsx b/01-frontend/src/pages/Home.tsx index b718640..7eda3e6 100644 --- a/01-frontend/src/pages/Home.tsx +++ b/01-frontend/src/pages/Home.tsx @@ -4,6 +4,7 @@ import Item from "../components/Item"; import FilterItem from "../helper/homepage/FilterItem"; import ItemCard from "../helper/homepage/ItemCard"; import "./pages.css"; // Import der CSS-Datei +import { useLocation } from "react-router-dom"; export default function Home() { const items: Item[] = [ @@ -145,6 +146,22 @@ export default function Home() { const [currentPage, setCurrentPage] = useState(1); // Zustand für die aktuelle Seite const [itemsPerPage, setItemsPerPage] = useState(9); // Dynamische Anzahl der Items pro Seite const [visibleItems, setVisibleItems] = useState([]); // Zustand für die sichtbaren Items + const [selectedCategory, setSelectedCategory] = useState(null); + + const location = useLocation(); + useEffect(() => { + const params = new URLSearchParams(location.search); + const category = params.get("category"); + if (category && categoriesFilter.includes(category)) { + setSelectedCategory(category); + } + }, [location.search]); + + const handleCategoryChange = (category: string) => { + setSelectedCategory(category); + // Optional: URL aktualisieren + // navigate(`/?category=${encodeURIComponent(category)}`); + }; // Handler für die Pagination @@ -179,7 +196,12 @@ export default function Home() { return (
- +