Skip to content

Commit

Permalink
chore: pagination bugfix + using code_insee as parameter instead of a…
Browse files Browse the repository at this point in the history
…round (#1907)
  • Loading branch information
Destinyyyy authored Feb 12, 2025
1 parent de3123d commit 0851d46
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions static/js/ui/ContribPagination.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,15 @@ async function ContribPagination(root) {

try {
const { results, status } = await getInternalResults({ apiKey, apiUrl, params })
const shouldDeleteViewMoreButton = currentCount >= totalCount

// If there are results, continue filling in the list of ERP cards
if (results?.length > 0) {
currentCount += results.length
populateInternalResults({ resultsContainer, results })
}

const shouldDeleteViewMoreButton = currentCount >= totalCount

if (status === 200) {
if (results.length >= PAGINATION_SIZE) {
currentPage++
Expand Down Expand Up @@ -138,8 +139,11 @@ function getParams({ root, currentPage, paginationSize }) {

const paramsForApiCall = new URLSearchParams()

if (params.get('code')) {
paramsForApiCall.append('code_insee', params.get('code'))
}

paramsForApiCall.append('q', q)
paramsForApiCall.append('around', `${params.get('lat')},${params.get('lon')}`)
paramsForApiCall.append('activite', activitySlug || params.get('activite'))
paramsForApiCall.append('page_size', paginationSize)
paramsForApiCall.append('page', currentPage)
Expand Down

0 comments on commit 0851d46

Please sign in to comment.