diff --git a/01-frontend/src/helper/FilterItem.tsx b/01-frontend/src/helper/FilterItem.tsx new file mode 100644 index 0000000..0f06a6c --- /dev/null +++ b/01-frontend/src/helper/FilterItem.tsx @@ -0,0 +1,40 @@ +import { FormControl, FormControlLabel, Radio, RadioGroup, Rating } from "@mui/material"; +import React from "react"; + +export default function FilterItem({ + filterName, + filterItems, +}: { + filterName: string; + filterItems: any[]; +}) { + const [value, setValue] = React.useState(filterItems[0]); + + const handleChange = (event: React.ChangeEvent) => { + setValue(event.target.value); + }; + + return ( +
+

{filterName}

+ + + {filterItems.map((item, idx) => ( + } + label={ + filterName === "Rating" ? ( + + ) : ( + item + ) + } + /> + ))} + + +
+ ); +} \ No newline at end of file diff --git a/01-frontend/src/pages/Home.tsx b/01-frontend/src/pages/Home.tsx index d5635ef..c1e1776 100644 --- a/01-frontend/src/pages/Home.tsx +++ b/01-frontend/src/pages/Home.tsx @@ -1,6 +1,7 @@ import { Box, Pagination } from "@mui/material"; import { useEffect, useState } from "react"; import Item from "../components/Item"; +import FilterItem from "../helper/FilterItem"; import ItemCard from "../helper/ItemCard"; import "./pages.css"; // Import der CSS-Datei @@ -129,6 +130,18 @@ export default function Home() { // Weitere Items hinzufügen ]; + const categoriesFilter: string[] = [ + "Seeds", + "Fertilizers", + "Technical Components" + ]; + const priceFilter: string[] = [ + "< 10", + "< 20", + "> 20" + ]; + const ratingFilter: number[] = [1, 2, 3, 4, 5]; + 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 @@ -147,7 +160,7 @@ export default function Home() { const startIndex = (currentPage - 1) * newItemsPerPage; setVisibleItems(items.slice(startIndex, startIndex + newItemsPerPage)); }; - + updateItems(); // Initialer Aufruf window.addEventListener("resize", updateItems); // Event-Listener hinzufügen return () => window.removeEventListener("resize", updateItems); // Event-Listener entfernen @@ -164,21 +177,29 @@ export default function Home() { }; return ( -
- - {visibleItems.map((item) => ( - - ))} - - - +
+
+ + + +
+
+ + {visibleItems.map((item) => ( + + ))} + + + +
+ ); } diff --git a/01-frontend/src/pages/pages.css b/01-frontend/src/pages/pages.css index 36ce974..6b926f6 100644 --- a/01-frontend/src/pages/pages.css +++ b/01-frontend/src/pages/pages.css @@ -65,6 +65,7 @@ overflow: hidden; padding: 20px 0; /* Abstand oben und unten */ box-sizing: border-box; /* Stellt sicher, dass Padding in die Höhe einbezogen wird */ + width: 100%; /* Damit der Hintergrund die gesamte Breite abdeckt */ } .pagination { @@ -121,4 +122,17 @@ justify-content: space-between; padding: 20px 0; /* Abstand oben und unten */ box-sizing: border-box; /* Stellt sicher, dass Padding in die Höhe einbezogen wird */ +} + +.home-page-background { + display: flex; + align-items: center; + width: 100%; +} + +.filter-container { + width: 10%; + display: grid; + margin-left: 20px; + margin-right: -20px; } \ No newline at end of file