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

#15 fixed bug with clear buttons and on wishlist filter

parent 45cb2bcf
No related branches found
No related tags found
1 merge request!41Wishlist frontend
import { useState } from "react";
import { propsDropDownFilter } from "../utils/commonTypes";
import "../stylesheets/DropDownFilter.css";
import "../pages/Wunschliste.tsx";
......
......@@ -27,16 +27,12 @@ function Garten() {
const handleClearGarden = async () => {
if (confirm("Möchtest du wirklich alle Pflanzen aus deinem Garten entfernen?" + "\n" +
"Diese Aktion kann nicht rückgängig gemacht werden.")) {
useEffect(() => {
(async () => {
const result = await bc.clearGarden();
if (result.err) {
setError(result.err);
} else {
setPlantsInGarden(result.value!);
}
})();
}, []);
const result = await bc.clearGarden();
if (result.err) {
setError(result.err);
} else {
setPlantsInGarden([]);
}
}
}
......@@ -77,31 +73,31 @@ function Garten() {
}
/*return (
<>
<div>
<h2>Deine Wunschliste</h2>
<DropDownFilter
topic={"Sortierung der Pflanzen im Garten"}
options={[
"neueste zuerst",
"als nächstes anpflanzbar",
"als nächstes erntbar",
]}
filterOnChange={handleSortOptions}
/>
<button onClick={handleClearGarden}>Garten leeren</button>
</div>
{error ? (
<p>Error fetching data</p>
) : (
<ul style={{display: "flex", gap: "1rem", width: "100%"}}>
{plants?.map((plant) => (
<PlantCard plant={plant} key={plant.id}/>
))}
</ul>
)}
</>
);*/
/*return (
<>
<div>
<h2>Deine Wunschliste</h2>
<DropDownFilter
topic={"Sortierung der Pflanzen im Garten"}
options={[
"neueste zuerst",
"als nächstes anpflanzbar",
"als nächstes erntbar",
]}
filterOnChange={handleSortOptions}
/>
<button onClick={handleClearGarden}>Garten leeren</button>
</div>
{error ? (
<p>Error fetching data</p>
) : (
<ul style={{display: "flex", gap: "1rem", width: "100%"}}>
{plants?.map((plant) => (
<PlantCard plant={plant} key={plant.id}/>
))}
</ul>
)}
</>
);*/
export default Garten;
\ No newline at end of file
......@@ -15,6 +15,7 @@ function Wunschliste() {
useEffect(() => {
(async () => {
console.log("abc")
const result = await bc.getWishlistEntries(currentSort);
if (result.err) {
setError(result.err);
......@@ -27,17 +28,13 @@ function Wunschliste() {
const handleClearWishList = async () => {
if (confirm("Möchtest du wirklich alle Pflanzen aus deiner Wunschliste entfernen?" + "\n" +
"Diese Aktion kann nicht rückgängig gemacht werden.")) {
useEffect(() => {
(async () => {
const result = await bc.clearWishlist();
if (result.err) {
setError(result.err);
} else {
setPlantsInWishlist(result.value!);
}
})();
}, []);
}
const result = await bc.clearWishlist();
if (result.err) {
setError(result.err);
} else {
setPlantsInWishlist([]);
}
}
}
const handleSortOptions = async (selectedOption: string) => {
......@@ -48,7 +45,7 @@ function Wunschliste() {
case "als nächstes anpflanzbar":
setCurrentSort("plantDate");
break;
case "als nächstes erntbar":
case "gerade anpflanzbar":
setCurrentSort("currentPlantable");
break;
default:
......
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