[frontend]: Add reset filters button

This commit is contained in:
2025-04-06 03:08:49 +01:00
parent 29cdf8a23b
commit 69230edcbb

View File

@ -171,6 +171,20 @@ const Sidebar = ({ selectedSources, setSelectedSources, clusteringEnabled, setCl
fetchData(enabledSources, numberInputValue); // Use enabledSources for data fetching
};
const resetFilters = () => {
const savedSources = Cookies.get("selectedSources");
const savedNumberInputValue = Cookies.get("numberInputValue");
if (savedSources) {
setSelectedSources(JSON.parse(savedSources));
} else {
setSelectedSources(customDefaultChecked);
}
setNumberInputValue(savedNumberInputValue || "");
};
return (
<div style={{
position: "absolute", top: "6vh", right: "1vh",
@ -227,7 +241,44 @@ const Sidebar = ({ selectedSources, setSelectedSources, clusteringEnabled, setCl
/>
</div>
)}
<button onClick={handleSubmit} style={{marginTop: "10px", color: "white"}}>Submit</button>
<div style={{
display: "flex",
flexDirection: "row",
justifyContent: "space-between",
gap: "10px",
marginTop: "10px",
width: "100%"
}}>
<button
onClick={handleSubmit}
style={{
flex: 1,
color: "white",
backgroundColor: "#4CAF50",
padding: "6px 12px",
borderRadius: "5px",
border: "none",
cursor: "pointer"
}}
>
Submit
</button>
<button
onClick={resetFilters}
style={{
flex: 1,
color: "white",
backgroundColor: "#f44336",
padding: "6px 12px",
borderRadius: "5px",
border: "none",
cursor: "pointer"
}}
>
Reset
</button>
</div>
</div>
)}
</div>