@@ -19,11 +19,11 @@ export default function CategorySearchList(){
19
19
20
20
const [ adData , setAdData ] = useState ( [ ] )
21
21
const [ modal , setModal ] = useState ( false )
22
+
22
23
const [ localidade , setLocalidade ] = useState ( null )
23
24
const [ estadoDaPeca , setEstadoDaPeca ] = useState ( null )
24
25
const [ dataPostagem , setDataPostagem ] = useState ( null )
25
26
const [ marca , setMarca ] = useState ( null )
26
-
27
27
const [ valor , setValor ] = useState ( null )
28
28
29
29
const [ loading , setLoading ] = useState ( false )
@@ -41,16 +41,21 @@ const addPage = async () => {
41
41
const newPage = page + 1 ; // Calcular o novo valor de page
42
42
setPage ( newPage ) // Atualizar o estado
43
43
44
- if ( localidade == null && estadoDaPeca == null && valor == null && dataPostagem == null ) {
45
- setAdData ( [ ] )
46
- const response = await axiosInstance . get ( `/api/advertisements/category/${ category } ?page=${ newPage } &size=10` , config )
47
- if ( response . data . content . length == 0 ) {
48
- alert ( "Não há mais páginas disponíveis" )
49
- setPage ( page )
50
- setAdData ( response . data . content )
51
- } else {
52
- setAdData ( response . data . content )
53
- }
44
+ if ( localidade == null && estadoDaPeca == null && valor == null && dataPostagem == null && marca == null ) {
45
+ await axiosInstance . get ( `/api/advertisements/category/${ category } ?page=${ newPage } &size=10` , config ) . then ( response => {
46
+ if ( response . data . content . length == 0 ) {
47
+ alert ( "Não há mais páginas disponíveis" )
48
+ setPage ( newPage - 1 )
49
+ } else {
50
+ setAdData ( [ ] )
51
+ response . data . content . map ( ( ad ) => {
52
+ const formatdate = format ( new Date ( ad . dataPostagem ) , "dd/MM/yyyy 'às' HH:mm" )
53
+ ad . dataPostagem = formatdate ;
54
+ }
55
+ )
56
+ setAdData ( response . data . content )
57
+ }
58
+ } )
54
59
} else {
55
60
setAdData ( [ ] )
56
61
const response = await axiosInstance . get ( `/api/advertisements/pagination?categoria=${ category } &page=${ newPage } &size=10&sortBy=preco&asc=false` , config )
@@ -80,9 +85,9 @@ const subPage = async () => {
80
85
const newPage = page - 1 ; // Calcular o novo valor de page
81
86
setPage ( newPage ) // Atualizar o estado
82
87
83
- if ( localidade == null && estadoDaPeca == null && valor == null && dataPostagem == null ) {
88
+ if ( localidade == null && estadoDaPeca == null && valor == null && dataPostagem == null && marca == null ) {
84
89
setAdData ( [ ] )
85
- const response = await axiosInstance . get ( `/api/advertisements/category/${ category } ?page=${ newPage } &size=10` , config ) . then ( response => {
90
+ await axiosInstance . get ( `/api/advertisements/category/${ category } ?page=${ newPage } &size=10` , config ) . then ( response => {
86
91
response . data . content . map ( ( ad ) => {
87
92
const formatdate = format ( new Date ( ad . dataPostagem ) , "dd/MM/yyyy 'às' HH:mm" )
88
93
ad . dataPostagem = formatdate ;
@@ -101,7 +106,6 @@ const subPage = async () => {
101
106
setAdData ( response . data . content )
102
107
} )
103
108
}
104
-
105
109
}
106
110
}
107
111
@@ -139,6 +143,9 @@ const subPage = async () => {
139
143
const removefilter = ( ) => {
140
144
setLocalidade ( null )
141
145
setEstadoDaPeca ( null )
146
+ setValor ( null )
147
+ setDataPostagem ( null )
148
+ setMarca ( null )
142
149
setModal ( false )
143
150
getAds ( ) ;
144
151
}
@@ -342,12 +349,12 @@ const subPage = async () => {
342
349
}
343
350
</ View >
344
351
< View className = "flex flex-row justify-center items-center my-4" >
345
- < TouchableOpacity className = "bg-purple-700 rounded-full w-10 h-10 flex justify-center items-center" onPress = { subPage } >
346
- < Text className = "text-white font-extrabold" > - </ Text >
352
+ < TouchableOpacity className = "w-10 h-10 flex justify-center items-center" onPress = { subPage } >
353
+ < Image source = { require ( "../../public/icons/arrowLeftPNG.png" ) } className = "w-10 h-10" > </ Image >
347
354
</ TouchableOpacity >
348
355
< Text className = "mx-5 text-xl" > Página { page + 1 } </ Text >
349
- < TouchableOpacity className = "bg-purple-700 rounded-full w-10 h-10 flex justify-center items-center" onPress = { addPage } >
350
- < Text className = "text-white font-extrabold" > + </ Text >
356
+ < TouchableOpacity className = "w-10 h-10 flex justify-center items-center" onPress = { addPage } >
357
+ < Image source = { require ( "../../public/icons/arrowRightPNG.png" ) } className = "w-10 h-10" > </ Image >
351
358
</ TouchableOpacity >
352
359
</ View >
353
360
</ ScrollView >
0 commit comments