Proyectos de Subversion LeadersLinked - SPA

Rev

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

Rev 1190 Rev 1191
Línea 24... Línea 24...
24
  const { category } = useParams()
24
  const { category } = useParams()
25
  const addressRef = useRef({})
25
  const addressRef = useRef({})
26
  const history = useHistory()
26
  const history = useHistory()
27
  const labels = useSelector(({ intl }) => intl.labels)
27
  const labels = useSelector(({ intl }) => intl.labels)
28
  const dispatch = useDispatch()
28
  const dispatch = useDispatch()
29
 
-
 
30
  const params = new URLSearchParams(search)
29
  const params = new URLSearchParams(search)
31
  const keyword = params.get('keyword')
-
 
32
  const currentPage = params.get('page')
-
 
Línea 33... Línea 30...
33
 
30
 
34
  const onChangeKeyword = debounce((value = '') => {
31
  const onChangeKeyword = debounce((value = '') => {
35
    params.set('page', '1')
32
    params.set('page', '1')
36
    params.set('keyword', value)
33
    params.set('keyword', value)
Línea 73... Línea 70...
73
 
70
 
74
        if (!success) {
71
        if (!success) {
75
          throw new Error(data)
72
          throw new Error(data)
Línea 76... Línea -...
76
        }
-
 
77
 
73
        }
78
        console.log(data)
74
 
79
        setEntities(data.current.items)
75
        setEntities(data.current.items)
80
        setPages(data.total.pages)
76
        setPages(data.total.pages)
81
      } catch (error) {
77
      } catch (error) {
Línea 88... Línea 84...
88
    searchEntities()
84
    searchEntities()
89
  }, [search, pathname])
85
  }, [search, pathname])
Línea 90... Línea 86...
90
 
86
 
91
  return (
87
  return (
92
    <>
88
    <>
-
 
89
      <Container as='main'>
-
 
90
        <Input
-
 
91
          icon={Search}
-
 
92
          onChange={(e) => onChangeKeyword(e.target.value)}
-
 
93
          defaultValue={params.get('keyword')}
-
 
94
          placeholder={labels.search}
-
 
95
        />
-
 
96
 
-
 
97
        <Grid container spacing={2} mt={2}>
-
 
98
          <Grid item xs={12} md={4} display='flex' direction='column' gap={2}>
-
 
99
            <FiltersSidebar>
-
 
100
              <CategoryFilter
-
 
101
                currentCategory={category}
-
 
102
                onChange={onChangeCategory}
-
 
103
              />
-
 
104
 
-
 
105
              <LocationFilter onChange={onChangeAddress} />
-
 
106
            </FiltersSidebar>
-
 
107
          </Grid>
-
 
108
 
-
 
109
          <Grid item xs={12} md={8} display='flex' direction='column' gap={2}>
-
 
110
            <div className='posts-section'>
-
 
111
              {loading ? (
-
 
112
                <LoaderContainer>
-
 
113
                  <Spinner />
-
 
114
                </LoaderContainer>
-
 
115
              ) : (
-
 
116
                <>
-
 
117
                  <EntitiesList entities={entities} />
-
 
118
                  <PaginationComponent
-
 
119
                    pages={pages}
-
 
120
                    currentActivePage={params.get('page') || 1}
-
 
121
                    onChangePage={onChangePage}
-
 
122
                    isRow
-
 
123
                  />
-
 
124
                </>
-
 
125
              )}
-
 
126
            </div>
-
 
127
          </Grid>
-
 
128
        </Grid>
93
      <Container as='main'></Container>
129
      </Container>
94
    </>
130
    </>
95
  )
131
  )
Línea 96... Línea 132...
96
}
132
}