Skip to content

Commit

Permalink
fix: remove 0% similar animals
Browse files Browse the repository at this point in the history
  • Loading branch information
Ronkiro committed May 29, 2024
1 parent bb7b357 commit baa34d2
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 29 deletions.
4 changes: 2 additions & 2 deletions src/Find/FindPet/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import PetsService from "../../shared/services/pets";
// eslint-disable-next-line react/prop-types
const FindSelect = ({ label, items, handleChange, ...props }) => (
<FormControl fullWidth>
<InputLabel id="demo-simple-select-label">{label}</InputLabel>
<InputLabel>{label}</InputLabel>
<Select label={label} onChange={handleChange} {...props}>
<MenuItem key={null} value={null}>
Todos
Expand Down Expand Up @@ -216,7 +216,7 @@ const FindPet = ({ onSearch, loading }) => {
critérios maior a chance de você encontrar!!
</Typography>
</Box>
<Grid container spacing={2} sx={{ my: 2 }}>
<Grid container spacing={2} sx={{ my: 2 }} id="find">
{citys && citys.length > 0 && (
<Grid item xs={12} md={4}>
<FindSelect
Expand Down
65 changes: 38 additions & 27 deletions src/Find/PetList/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ import {
CardMedia,
Chip,
Grid,
Link,
Typography,
} from "@mui/material";
import { useEffect, useState } from "react";
import { useNavigate } from "react-router-dom";
import { useNavigate } from "react-router-dom";
import PetsService from "../../shared/services/pets";

const Pet = ({ imgUrl, city, score, gender, handleClick }) => (
Expand Down Expand Up @@ -72,7 +73,7 @@ const PetList = ({ searchParams, selectedImage, onChangeLoadingState }) => {
} else {
petList = (
await PetsService.getWithImageMatch(currentSearchParams, currentImage)
).data.data;
).data.data.filter((pet) => !!pet["score"]);
}
if (petList.length) {
if (page != 1) setPets([...pets, ...petList]);
Expand Down Expand Up @@ -109,32 +110,42 @@ const PetList = ({ searchParams, selectedImage, onChangeLoadingState }) => {
};

return (
<Box sx={{ display: "flex", textAlign: "-webkit-center", mb: 2 }}>
<Grid container spacing={2}>
{!petsLoading &&
pets.length &&
pets.map((pet) => (
<Pet
gender={pet["attributes"]["sexo"]}
handleClick={() => handlePetClick(pet["_id"])}
imgUrl={
pet["attributes"]["foto"]["data"][0]["attributes"][
"gcs_foto_url"
]
}
score={pet["score"]}
city={pet["attributes"]["cidade"]["data"]["attributes"]["nome"]}
key={pet["_id"]}
/>
))}
{!petsLoading && !pets.length && (
<Box>
Nenhum pet encontrado. Tente alterar seus critérios de busca
<>
<Box sx={{ display: "flex", textAlign: "-webkit-center", mb: 2 }}>
<Grid container spacing={2}>
{!petsLoading &&
pets.length &&
pets.map((pet) => (
<Pet
gender={pet["attributes"]["sexo"]}
handleClick={() => handlePetClick(pet["_id"])}
imgUrl={
pet["attributes"]["foto"]["data"][0]["attributes"][
"gcs_foto_url"
]
}
score={pet["score"]}
city={pet["attributes"]["cidade"]["data"]["attributes"]["nome"]}
key={pet["_id"]}
/>
))}
{!petsLoading && !pets.length && (
<Box>
Nenhum pet encontrado. Tente alterar seus critérios de busca
</Box>
)}
{petsLoading && <Box>Aguarde, carregando...</Box>}
</Grid>
</Box>
{!petsLoading && pets.length && (
<Grid>
<Box sx={{ my: 2, textAlign: "center" }} fullWidth>
Ainda não encontrou seu pet?{" "}
<Link href="#find">Tente alterar os critérios de busca</Link>.
</Box>
)}
{petsLoading && <Box>Aguarde, carregando...</Box>}
</Grid>
</Box>
</Grid>
)}
</>
);
};

Expand Down

0 comments on commit baa34d2

Please sign in to comment.