Skip to content

Commit

Permalink
chore: fixing test issue
Browse files Browse the repository at this point in the history
  • Loading branch information
paulushcgcj committed Dec 10, 2024
1 parent 56f32a7 commit a1990bd
Showing 1 changed file with 15 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,31 +123,28 @@ const OpeningsSearchTab: React.FC = () => {
handleSearchInputChange(searchTerm);
},[searchTerm]);

//initally when the screen loads check if there was a earch term present
useEffect (()=>{
if(searchTerm.length>0 || countActiveFilters(filters)>0){
handleSearch();
}
},[])

// Check if we have query parms and if the params align with the filter fields
useEffect(() => {
// Get the query params
const urlParams = new URLSearchParams(window.location.search);

if(urlParams.keys().toArray().length > 0){
// Here we do a match between the query params and the filter fields
Object.keys(filters).forEach((key) => {
// This is to avoid setting the filter fields with the query params if they don't exist on the filter
if(urlParams.has(key)){
setFilters((prevFilters: OpeningFilters) => ({
...prevFilters,
[key]: urlParams.get(key)
}));
}
});
// Here we do a match between the query params and the filter fields
Object.keys(filters).forEach((key) => {
// This is to avoid setting the filter fields with the query params if they don't exist on the filter
if(urlParams.has(key)){
setFilters((prevFilters: OpeningFilters) => ({
...prevFilters,
[key]: urlParams.get(key)
}));
}
});

//initally when the screen loads check if there was a earch term present
if(searchTerm.length>0 || countActiveFilters(filters)>0){
handleSearch();
}


},[]);

return (
Expand Down

0 comments on commit a1990bd

Please sign in to comment.