Skip to content
Snippets Groups Projects
Commit cfa431f7 authored by Blersch Lara's avatar Blersch Lara
Browse files

#16 working on the filter menu

parent c3f30c18
No related branches found
No related tags found
1 merge request!41Wishlist frontend
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 (
......
......@@ -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>
......
......@@ -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);
};
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment