Proyectos de Subversion LeadersLinked - SPA

Rev

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

Rev 980 Rev 981
Línea 16... Línea 16...
16
import PaginationComponent from 'components/UI/PaginationComponent'
16
import PaginationComponent from 'components/UI/PaginationComponent'
17
import LoaderContainer from 'components/UI/LoaderContainer'
17
import LoaderContainer from 'components/UI/LoaderContainer'
Línea 18... Línea 18...
18
 
18
 
19
const SearchPage = () => {
19
const SearchPage = () => {
20
  const [entities, setEntities] = useState([])
-
 
21
  const [loading, setLoading] = useState(true)
-
 
22
  const [address, setAddress] = useState({})
20
  const [entities, setEntities] = useState([])
-
 
21
  const [pages, setPages] = useState(1)
23
  const [pages, setPages] = useState(1)
22
  const [loading, setLoading] = useState(true)
24
  const { search, pathname } = useLocation()
23
  const { search, pathname } = useLocation()
25
  const { category } = useParams()
24
  const { category } = useParams()
26
  const history = useHistory()
25
  const history = useHistory()
27
  const labels = useSelector(({ intl }) => intl.labels)
26
  const labels = useSelector(({ intl }) => intl.labels)
Línea 28... Línea 27...
28
  const dispatch = useDispatch()
27
  const dispatch = useDispatch()
29
 
28
 
30
  const params = new URLSearchParams(search)
29
  const params = new URLSearchParams(search)
Línea 31... Línea 30...
31
  const keyword = params.get('keyword')
30
  const keyword = params.get('keyword')
32
  const currentPage = params.get('page')
31
  const currentPage = params.get('page')
Línea 33... Línea 32...
33
 
32
 
34
  const searchEntities = (address = {}) => {
33
  const searchEntities = () => {
35
    setLoading(true)
34
    setLoading(true)
Línea 66... Línea 65...
66
  const onChangeCategory = (newCategory = 'user') => {
65
  const onChangeCategory = (newCategory = 'user') => {
67
    params.set('page', '1')
66
    params.set('page', '1')
68
    history.replace(`/search/entity/${newCategory}?${params.toString()}`)
67
    history.replace(`/search/entity/${newCategory}?${params.toString()}`)
69
  }
68
  }
Línea -... Línea 69...
-
 
69
 
-
 
70
  const onChangeAddress = (address = {}) => {
-
 
71
    params.set('page', '1')
-
 
72
    Object.entries(address).forEach(
-
 
73
      ([key, value]) => value && params.set(key, value)
-
 
74
    )
-
 
75
    history.replace(`${pathname}?${params.toString()}`)
-
 
76
  }
70
 
77
 
71
  useEffect(() => {
78
  useEffect(() => {
72
    searchEntities(address)
79
    searchEntities()
Línea 73... Línea 80...
73
  }, [address, search, pathname])
80
  }, [search, pathname])
74
 
81
 
75
  return (
82
  return (
76
    <>
83
    <>
Línea 88... Línea 95...
88
              <CategoryFilter
95
              <CategoryFilter
89
                currentCategory={category}
96
                currentCategory={category}
90
                onChange={onChangeCategory}
97
                onChange={onChangeCategory}
91
              />
98
              />
Línea 92... Línea -...
92
 
-
 
93
              <LocationFilter
99
 
94
                onChange={(newAddress) => setAddress(newAddress)}
-
 
95
              />
100
              <LocationFilter onChange={onChangeAddress} />
96
            </FiltersSidebar>
101
            </FiltersSidebar>
Línea 97... Línea 102...
97
          </Grid>
102
          </Grid>
98
 
103
 
99
          <Grid item xs={12} md={8} display='flex' direction='column' gap={2}>
104
          <Grid item xs={12} md={8} display='flex' direction='column' gap={2}>
100
            <div className='posts-section'>
105
            <div className='posts-section'>
101
              {loading ? (
106
              {loading ? (
102
                <LoaderContainer>
107
                <LoaderContainer>
103
                  <Spinner />
108
                  <Spinner />
-
 
109
                </LoaderContainer>
104
                </LoaderContainer>
110
              ) : (
-
 
111
                <>
-
 
112
                  <EntitiesList entities={entities} />
-
 
113
                  <PaginationComponent
-
 
114
                    pages={pages}
-
 
115
                    currentActivePage={currentPage}
-
 
116
                    onChangePage={onChangePage}
-
 
117
                    isRow
105
              ) : (
118
                  />
106
                <EntitiesList entities={entities} />
119
                </>
107
              )}
-
 
108
            </div>
-
 
109
 
-
 
110
            <PaginationComponent
-
 
111
              pages={pages}
-
 
112
              currentActivePage={currentPage}
-
 
113
              onChangePage={onChangePage}
-
 
114
              isRow
120
              )}
115
            />
121
            </div>
116
          </Grid>
122
          </Grid>
117
        </Grid>
123
        </Grid>
118
      </Container>
124
      </Container>