Proyectos de Subversion LeadersLinked - SPA

Rev

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

Rev 1196 Rev 2614
Línea 1... Línea 1...
1
import React, { useState, useEffect, useRef } 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 { useNavigate, 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'
7
import { Container, Grid } from '@mui/material'
7
import { Container, Grid } from '@mui/material'
Línea 8... Línea 8...
8
 
8
 
Línea 21... Línea 21...
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 addressRef = useRef({})
26
  const history = useHistory()
26
  const navigate = useNavigate()
27
  const labels = useSelector(({ intl }) => intl.labels)
27
  const labels = useSelector(({ intl }) => intl.labels)
28
  const dispatch = useDispatch()
28
  const dispatch = useDispatch()
29
  const params = new URLSearchParams(search)
29
  const params = new URLSearchParams(search)
Línea 30... Línea 30...
30
 
30
 
31
  const onChangeKeyword = debounce((value = '') => {
31
  const onChangeKeyword = debounce((value = '') => {
32
    const params = new URLSearchParams(search)
32
    const params = new URLSearchParams(search)
33
    params.set('page', '1')
33
    params.set('page', '1')
34
    params.set('keyword', value)
34
    params.set('keyword', value)
35
    history.replace(`${pathname}?${params.toString()}`)
35
    navigate(`${pathname}?${params.toString()}`)
Línea 36... Línea 36...
36
  }, 500)
36
  }, 500)
37
 
37
 
38
  const onChangePage = (currentPage = 1) => {
38
  const onChangePage = (currentPage = 1) => {
39
    const params = new URLSearchParams(search)
39
    const params = new URLSearchParams(search)
40
    params.set('page', `${currentPage}`)
40
    params.set('page', `${currentPage}`)
Línea 41... Línea 41...
41
    history.replace(`${pathname}?${params.toString()}`)
41
    navigate(`${pathname}?${params.toString()}`)
42
  }
42
  }
43
 
43
 
44
  const onChangeCategory = (newCategory = 'user') => {
44
  const onChangeCategory = (newCategory = 'user') => {
45
    const params = new URLSearchParams(search)
45
    const params = new URLSearchParams(search)
Línea 46... Línea 46...
46
    params.set('page', '1')
46
    params.set('page', '1')
47
    history.replace(`/search/entity/${newCategory}?${params.toString()}`)
47
    navigate(`/search/entity/${newCategory}?${params.toString()}`)
48
  }
48
  }
Línea 58... Línea 58...
58
 
58
 
59
    Object.entries(address).forEach(
59
    Object.entries(address).forEach(
60
      ([key, value]) => value && params.set(key, value)
60
      ([key, value]) => value && params.set(key, value)
Línea 61... Línea 61...
61
    )
61
    )
62
 
62
 
Línea 63... Línea 63...
63
    history.replace(`${pathname}?${params.toString()}`)
63
    navigate(`${pathname}?${params.toString()}`)
64
  }
64
  }
65
 
65