diff --git a/growbros-frontend/src/components/DropDownFilter.tsx b/growbros-frontend/src/components/DropDownFilter.tsx index 78af84079e1420837925a7f001e19fb060c77759..801cc1b9ffed9c9e4a04bab38afc88bbd60aa013 100644 --- a/growbros-frontend/src/components/DropDownFilter.tsx +++ b/growbros-frontend/src/components/DropDownFilter.tsx @@ -1,4 +1,4 @@ -import React from 'react' + import { useState } from "react"; function DropDownFilter(props: PropsDropDownFilter) { @@ -6,11 +6,9 @@ function DropDownFilter(props: PropsDropDownFilter) { const options = props.options; const topic = props.topic; const [selectedOption, setSelectedOption] = useState(""); - //todo: add another const here for holding the url and sort parameter to filter the plants const handleOptionChange = (event: any) => { setSelectedOption(event.target.value); - //todo: implement a fetch here to get the filtered plants }; return ( diff --git a/growbros-frontend/src/pages/Wunschliste.tsx b/growbros-frontend/src/pages/Wunschliste.tsx index b8b08794fae38335b6e633af656439e3556417b8..8c9fd64454b29f90cdab176003324ab2906784f9 100644 --- a/growbros-frontend/src/pages/Wunschliste.tsx +++ b/growbros-frontend/src/pages/Wunschliste.tsx @@ -6,8 +6,14 @@ function Wunschliste() { const [plants, setPlants] = useState<any[]>([]); const [error, setError] = useState(); + let sort = "" + useEffect(() => { - fetch("http://localhost:8080/api/v1/wishlist") + fetch("http://localhost:8080/api/v1/wishlist", + { + method: 'GET', + body: sort + }) .then((res) => res.json()) .then((plants) => setPlants(plants)) .catch((err) => setError(err)); @@ -25,6 +31,11 @@ function Wunschliste() { } } + /*const handleSortOptions = async () => { + //sort = DropDownFilter.options.value; + //todo: how to get current selected option? + }*/ + return ( <> @@ -37,6 +48,7 @@ function Wunschliste() { "als nächstes anpflanzbar", "jetzt anpflanzbar", ]} + // onChange={handleSortOptions()} todo: how?s /> <button onClick={handleClearWishList}>Wunschliste leeren</button> </div> diff --git a/src/main/java/hdm/mi/growbros/service/WishListService.java b/src/main/java/hdm/mi/growbros/service/WishListService.java index 0d832d672cd617de3053b346178779ed0c847c68..faaccbc65a201db06498718377a15a84ccf0e949 100644 --- a/src/main/java/hdm/mi/growbros/service/WishListService.java +++ b/src/main/java/hdm/mi/growbros/service/WishListService.java @@ -28,6 +28,7 @@ public class WishListService { case "createdAt" -> getAllPlantsOrderedByCreatedDate(user); case "plantDate" -> getAllPlantsOrderedByNextPossiblePlantDate(user); case "currentPlantable" -> getCurrentPlantablePlants(user); + case "" -> getAllPlantsOrderedByName(user); //todo: better way to do this? default -> getAllPlantsOrderedByName(user); }; }