Proyectos de Subversion LeadersLinked - SPA

Rev

Rev 990 | Rev 1175 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 990 Rev 991
Línea 1... Línea 1...
1
import React, { useState, useEffect } from 'react'
1
import React, { useState, useEffect, useRef } from 'react'
2
import { axios, debounce } from '../../utils'
2
import { axios, debounce } from '../../utils'
3
import { useDispatch, useSelector } from 'react-redux'
3
import { useDispatch, useSelector } from 'react-redux'
4
import { useHistory, useLocation, useParams } from 'react-router-dom'
4
import { useHistory, useLocation, useParams } from 'react-router-dom'
5
import { addNotification } from '../../redux/notification/notification.actions'
5
import { addNotification } from '../../redux/notification/notification.actions'
6
import { Search } from '@mui/icons-material'
6
import { Search } from '@mui/icons-material'
Línea 20... Línea 20...
20
  const [entities, setEntities] = useState([])
20
  const [entities, setEntities] = useState([])
21
  const [pages, setPages] = useState(1)
21
  const [pages, setPages] = useState(1)
22
  const [loading, setLoading] = useState(true)
22
  const [loading, setLoading] = useState(true)
23
  const { search, pathname } = useLocation()
23
  const { search, pathname } = useLocation()
24
  const { category } = useParams()
24
  const { category } = useParams()
-
 
25
  const addressRef = useRef({})
25
  const history = useHistory()
26
  const history = useHistory()
26
  const labels = useSelector(({ intl }) => intl.labels)
27
  const labels = useSelector(({ intl }) => intl.labels)
27
  const dispatch = useDispatch()
28
  const dispatch = useDispatch()
Línea 28... Línea 29...
28
 
29
 
Línea 67... Línea 68...
67
    history.replace(`/search/entity/${newCategory}?${params.toString()}`)
68
    history.replace(`/search/entity/${newCategory}?${params.toString()}`)
68
  }
69
  }
Línea 69... Línea 70...
69
 
70
 
70
  const onChangeAddress = (address = {}) => {
71
  const onChangeAddress = (address = {}) => {
71
    params.set('page', '1')
72
    params.set('page', '1')
72
    const addressEntries = Object.entries(address)
-
 
73
 
-
 
74
    for (const [key] of params.entries()) {
73
    Object.entries(addressRef.current).forEach(([key]) => {
75
      if (!['page', 'keyword'].includes(key)) params.delete(key)
74
      if (!['page', 'keyword'].includes(key)) params.delete(key)
-
 
75
    })
-
 
76
 
Línea -... Línea 77...
-
 
77
    addressRef.current = address
76
    }
78
 
-
 
79
    Object.entries(address).forEach(
Línea 77... Línea 80...
77
 
80
      ([key, value]) => value && params.set(key, value)
78
    addressEntries.forEach(([key, value]) => value && params.set(key, value))
81
    )
Línea 79... Línea 82...
79
 
82