[frontend]: Add reset filters button
This commit is contained in:
@ -171,6 +171,20 @@ const Sidebar = ({ selectedSources, setSelectedSources, clusteringEnabled, setCl
|
|||||||
fetchData(enabledSources, numberInputValue); // Use enabledSources for data fetching
|
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 (
|
return (
|
||||||
<div style={{
|
<div style={{
|
||||||
position: "absolute", top: "6vh", right: "1vh",
|
position: "absolute", top: "6vh", right: "1vh",
|
||||||
@ -227,7 +241,44 @@ const Sidebar = ({ selectedSources, setSelectedSources, clusteringEnabled, setCl
|
|||||||
/>
|
/>
|
||||||
</div>
|
</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>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
Reference in New Issue
Block a user