From b58fca5e797e0c7a8111173bbeff95c23bc70732 Mon Sep 17 00:00:00 2001 From: Andrew Date: Wed, 26 Mar 2025 10:22:49 +0000 Subject: [PATCH] [frontend]: Fix cookies not being loaded properly --- frontend/src/components/Sidebar.jsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/frontend/src/components/Sidebar.jsx b/frontend/src/components/Sidebar.jsx index 5b69a69..ec2d135 100644 --- a/frontend/src/components/Sidebar.jsx +++ b/frontend/src/components/Sidebar.jsx @@ -64,6 +64,9 @@ const getAllDefaultCheckedIds = (data) => { }; const CheckboxItem = ({ item, selectedSources, setSelectedSources, enabledSources, setEnabledSources, level = 0, parentChecked = true }) => { + console.log("item id: " + item.id); + console.log(selectedSources.includes(item.id)); + const isChecked = selectedSources.includes(item.id); const isDisabled = !parentChecked; // Disable if any parent is not checked const isEnabled = isChecked && parentChecked; // Only enabled if checked and parent is checked @@ -154,8 +157,8 @@ const Sidebar = ({ selectedSources, setSelectedSources, clusteringEnabled, setCl }, [setSelectedSources]); const handleSubmit = () => { - Cookies.set("selectedSources", JSON.stringify(selectedSources)); - Cookies.set("numberInputValue", numberInputValue); // Save numberInputValue to cookie + Cookies.set("selectedSources", JSON.stringify(selectedSources), { expires: 365 }); + Cookies.set("numberInputValue", numberInputValue, { expires: 365 }); // Save numberInputValue to cookie fetchData(enabledSources, numberInputValue); // Use enabledSources for data fetching };