Skip to content

Commit 65b68a8

Browse files
committed
Alteração de estilizações, see passwords e lógica dos IFs de alteração do cadastro, uso de Regex aplicado
1 parent 62c4a64 commit 65b68a8

6 files changed

+260
-52
lines changed

app/(app)/CategorySearchList.tsx

Lines changed: 66 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export default function CategorySearchList(){
2222
const [localidade, setLocalidade] = useState(null)
2323
const [estadoDaPeca, setEstadoDaPeca] = useState(null)
2424
const [dataPostagem, setDataPostagem] = useState(null)
25+
const [marca, setMarca] = useState(null)
2526

2627
const [valor, setValor] = useState(null)
2728

@@ -40,19 +41,23 @@ const addPage = async () => {
4041
const newPage = page + 1; // Calcular o novo valor de page
4142
setPage(newPage) // Atualizar o estado
4243

43-
if(localidade == null && estadoDaPeca == null && valor == null){
44+
if(localidade == null && estadoDaPeca == null && valor == null && dataPostagem == null){
45+
setAdData([])
4446
const response = await axiosInstance.get(`/api/advertisements/category/${category}?page=${newPage}&size=10` , config)
4547
if(response.data.content.length == 0){
4648
alert("Não há mais páginas disponíveis")
4749
setPage(page)
50+
setAdData(response.data.content)
4851
} else{
4952
setAdData(response.data.content)
5053
}
5154
} else{
55+
setAdData([])
5256
const response = await axiosInstance.get(`/api/advertisements/pagination?categoria=${category}&page=${newPage}&size=10&sortBy=preco&asc=false`, config)
5357
if(response.data.content.length == 0){
5458
alert("Não há mais páginas disponíveis")
5559
setPage(page)
60+
setAdData(response.data.content)
5661
} else{
5762
setAdData(response.data.content)
5863
}
@@ -75,12 +80,26 @@ const subPage = async () => {
7580
const newPage = page - 1; // Calcular o novo valor de page
7681
setPage(newPage) // Atualizar o estado
7782

78-
if(localidade == null && estadoDaPeca == null && valor == null){
79-
const response = await axiosInstance.get(`/api/advertisements/category/${category}?page=${newPage}&size=10` , config)
80-
setAdData(response.data.content)
83+
if(localidade == null && estadoDaPeca == null && valor == null && dataPostagem == null){
84+
setAdData([])
85+
const response = await axiosInstance.get(`/api/advertisements/category/${category}?page=${newPage}&size=10` , config).then(response => {
86+
response.data.content.map((ad) => {
87+
const formatdate = format(new Date(ad.dataPostagem), "dd/MM/yyyy 'às' HH:mm")
88+
ad.dataPostagem = formatdate;
89+
}
90+
)
91+
setAdData(response.data.content)
92+
})
8193
} else{
82-
const response = await axiosInstance.get(`/api/advertisements/pagination?categoria=${category}&page=${newPage}&size=10&sortBy=preco&asc=false`, config)
83-
setAdData(response.data.content)
94+
setAdData([])
95+
await axiosInstance.get(`/api/advertisements/pagination?categoria=${category}&page=${newPage}&size=10&sortBy=preco&asc=false`, config).then(response => {
96+
response.data.content.map((ad) => {
97+
const formatdate = format(new Date(ad.dataPostagem), "dd/MM/yyyy 'às' HH:mm")
98+
ad.dataPostagem = formatdate;
99+
}
100+
)
101+
setAdData(response.data.content)
102+
})
84103
}
85104

86105
}
@@ -102,8 +121,8 @@ const subPage = async () => {
102121
}
103122
await axiosInstance.get(`/api/advertisements/category/${category}?page=0&size=10` , config).then(response => {
104123
response.data.content.map((ad) => {
105-
setFormatDate(format(new Date(ad.dataPostagem), 'dd/MM/yyyy'))
106-
setFormatHour(format(new Date(ad.dataPostagem), 'HH:mm'))
124+
const formatdate = format(new Date(ad.dataPostagem), "dd/MM/yyyy 'às' HH:mm")
125+
ad.dataPostagem = formatdate;
107126
}
108127
)
109128
setAdData(response.data.content)
@@ -122,7 +141,6 @@ const subPage = async () => {
122141
setEstadoDaPeca(null)
123142
setModal(false)
124143
getAds();
125-
126144
}
127145

128146
useEffect(() => {
@@ -233,6 +251,43 @@ const subPage = async () => {
233251
<Picker.Item label="Anúncios mais antigos" value="Anúncios mais antigos"></Picker.Item>
234252
</Picker>
235253
</View>
254+
<View className="border bg-purple-100 border-black rounded-md w-60 mt-2">
255+
256+
<Picker selectedValue={marca} onValueChange={setMarca}>
257+
<Picker.Item label="Selecione uma opção" value={null}></Picker.Item>
258+
<Picker.Item label="OUTRA MARCA" value="OUTRA MARCA" />
259+
<Picker.Item label="Animal" value="Animal" />
260+
<Picker.Item label="BSD" value="BSD" />
261+
<Picker.Item label="Cinema" value="Cinema" />
262+
<Picker.Item label="Colony" value="Colony" />
263+
<Picker.Item label="Cult" value="Cult" />
264+
<Picker.Item label="Demolition" value="Demolition" />
265+
<Picker.Item label="Division" value="Division" />
266+
<Picker.Item label="Drb" value="Drb" />
267+
<Picker.Item label="Eclat" value="Eclat" />
268+
<Picker.Item label="Federal" value="Federal" />
269+
<Picker.Item label="Fiend" value="Fiend" />
270+
<Picker.Item label="FitBikeCo" value="FitBikeCo" />
271+
<Picker.Item label="Fly" value="Fly" />
272+
<Picker.Item label="G-Sport" value="G-Sport" />
273+
<Picker.Item label="Gios" value="Gios" />
274+
<Picker.Item label="Haro" value="Haro" />
275+
<Picker.Item label="Kink" value="Kink" />
276+
<Picker.Item label="Magic Flute" value="Magic Flute" />
277+
<Picker.Item label="Master Bikes" value="Master Bikes" />
278+
<Picker.Item label="Merrit" value="Merrit" />
279+
<Picker.Item label="Mob" value="Mob" />
280+
<Picker.Item label="Odyssey" value="Odyssey" />
281+
<Picker.Item label="Polso" value="Polso" />
282+
<Picker.Item label="Primo" value="Primo" />
283+
<Picker.Item label="Profile" value="Profile" />
284+
<Picker.Item label="Pro-X" value="Pro-X" />
285+
<Picker.Item label="Sunday" value="Sunday" />
286+
<Picker.Item label="United" value="United" />
287+
<Picker.Item label="Volume" value="Volume" />
288+
<Picker.Item label="We The People" value="We The People" />
289+
</Picker>
290+
</View>
236291
</View>
237292
<View className="flex flex-col">
238293
<TouchableOpacity onPress={filter} className="bg-green-500 p-3 rounded-lg w-32 mb-2">
@@ -266,12 +321,12 @@ const subPage = async () => {
266321
? <View className="flex justify-center ml-2">
267322
<Text className="text-white text-xs font-black mb-2">{ad.categoria}</Text>
268323
<Text className="text-yellow-300">{ad.localidade}</Text>
269-
<Text className="text-white">{formatDate} às {formatHour}</Text>
324+
<Text className="text-white">{ad.dataPostagem}</Text>
270325
<Text className="text-yellow-300 mt-4 font-bold">R$ {ad.preco}</Text>
271326
</View> : <View className="flex justify-center ml-2">
272327
<Text className="text-white text-xs font-black mb-2">{ad.categoria} {ad.marca}</Text>
273328
<Text className="text-yellow-300">{ad.localidade}</Text>
274-
<Text className="text-white">{formatDate} às {formatHour}</Text>
329+
<Text className="text-white">{ad.dataPostagem}</Text>
275330
<Text className="text-yellow-300 mt-4 font-bold">R$ {ad.preco}</Text>
276331
</View>}
277332
</View>

0 commit comments

Comments
 (0)