Skip to content

Commit

Permalink
Merge pull request #549 from ertush/hotfix
Browse files Browse the repository at this point in the history
Modified the page param filters for facilities/index.js
  • Loading branch information
ertush authored Nov 19, 2024
2 parents 231b8b4 + 4aa2fc4 commit f93e26a
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions pages/facilities/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,22 +181,37 @@ function FacilityHome(props) {

const href = new URL(window.location.href)

const filter = href.searchParams.get('filter');
setPageFilter(filter);
let currentPageFilters = ''

for(let [k, v] of href.searchParams.entries()) {
if(k == 'filter') continue
currentPageFilters += `&${k}=${v}`
}


setPageFilter(currentPageFilters);


mutate()

})

// console.log({pageFilter})

const {data: searchedFacility, mutate, isLoading: searchIsLoading} = useSWR(`${process.env.NEXT_PUBLIC_API_URL}/facilities/facilities/?search=${searchTerm}&filter=${pageFilter}`, searchFacility, {
const {mutate, isLoading: searchIsLoading} = useSWR(
!!searchTerm && !!pageFilter
?
`${process.env.NEXT_PUBLIC_API_URL}/facilities/facilities/?search=${searchTerm}${pageFilter}`
:
null
, searchFacility, {
revalidateOnMount: false,
revalidateOnFocus: false,
onSuccess: (data) => {

setFacilities(data?.results)
}

})


Expand Down

0 comments on commit f93e26a

Please sign in to comment.