From 6506d6817bb7de9a113eab78a94b92175816fc91 Mon Sep 17 00:00:00 2001 From: Victor Date: Mon, 13 May 2024 00:59:33 +0200 Subject: [PATCH] fix date reset --- src/components/item/ItemPage.jsx | 56 ++++++++++++++++++++++++++++++-- 1 file changed, 54 insertions(+), 2 deletions(-) diff --git a/src/components/item/ItemPage.jsx b/src/components/item/ItemPage.jsx index 0104601..4a9f9cf 100644 --- a/src/components/item/ItemPage.jsx +++ b/src/components/item/ItemPage.jsx @@ -68,9 +68,13 @@ export const ItemPage = () => { (filterPriceMin === "" || item.price >= parseFloat(filterPriceMin)) && (filterPriceMax === "" || item.price <= parseFloat(filterPriceMax)); const matchesDate = + !filterDateRange || filterDateRange.length === 0 || - (new Date(item.purchaseDate) >= filterDateRange[0] && + (filterDateRange[0] && + filterDateRange[1] && + new Date(item.purchaseDate) >= filterDateRange[0] && new Date(item.purchaseDate) <= filterDateRange[1]); + return matchesRoom && matchesName && matchesPrice && matchesDate; }); setFilteredItems(filtered); @@ -106,7 +110,55 @@ export const ItemPage = () => { return (
-
{/* Filters here */}
+
+
+ + +
+
+ + setFilterName(e.target.value)} + /> +
+
+ + setFilterPriceMin(value)} + /> + - + setFilterPriceMax(value)} + /> +
+
+ + setFilterDateRange(dates)} + value={filterDateRange} + /> +
+
{/* Button to open create item modal */}