feat: load phoneOnly filter from localStorage after component mount
This commit is contained in:
@@ -20,21 +20,26 @@ export default function ProjectListPage() {
|
|||||||
const [projects, setProjects] = useState([]);
|
const [projects, setProjects] = useState([]);
|
||||||
const [searchTerm, setSearchTerm] = useState("");
|
const [searchTerm, setSearchTerm] = useState("");
|
||||||
const [filteredProjects, setFilteredProjects] = useState([]);
|
const [filteredProjects, setFilteredProjects] = useState([]);
|
||||||
const [filters, setFilters] = useState(() => {
|
const [filters, setFilters] = useState({
|
||||||
// Load phoneOnly filter from localStorage
|
status: 'all',
|
||||||
const savedPhoneOnly = typeof window !== 'undefined'
|
type: 'all',
|
||||||
? localStorage.getItem('projectsPhoneOnlyFilter') === 'true'
|
customer: 'all',
|
||||||
: false;
|
mine: false,
|
||||||
return {
|
phoneOnly: false
|
||||||
status: 'all',
|
|
||||||
type: 'all',
|
|
||||||
customer: 'all',
|
|
||||||
mine: false,
|
|
||||||
phoneOnly: savedPhoneOnly
|
|
||||||
};
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const [customers, setCustomers] = useState([]);
|
const [customers, setCustomers] = useState([]);
|
||||||
|
|
||||||
|
// Load phoneOnly filter from localStorage after mount to avoid hydration issues
|
||||||
|
useEffect(() => {
|
||||||
|
const savedPhoneOnly = localStorage.getItem('projectsPhoneOnlyFilter') === 'true';
|
||||||
|
if (savedPhoneOnly) {
|
||||||
|
setFilters(prev => ({
|
||||||
|
...prev,
|
||||||
|
phoneOnly: savedPhoneOnly
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}, []);
|
||||||
const [filtersExpanded, setFiltersExpanded] = useState(true); // Start expanded on mobile so users know filters exist
|
const [filtersExpanded, setFiltersExpanded] = useState(true); // Start expanded on mobile so users know filters exist
|
||||||
const [searchMatchType, setSearchMatchType] = useState(null); // Track what type of match was found
|
const [searchMatchType, setSearchMatchType] = useState(null); // Track what type of match was found
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user