Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Marina's Bigfoot JSON frontend #37

Open
wants to merge 16 commits into
base: main
Choose a base branch
from

Conversation

Mannushka
Copy link

No description provided.

Comment on lines +19 to +22
linkStyle = {
textDecoration: "none",
color: "white",
};
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could use your css file for this

Comment on lines +7 to +8
const form = e.target;
const query = form.search.value;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not e.target.form.search.value? :D

Comment on lines +10 to +14
if (isNaN(query)) {
props.setSearchParams({ state: query });
} else {
props.setSearchParams({ year: query });
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not bad, validating data type here. But why is NaN equal to state?

Comment on lines +24 to +27
display: "flex",
justifyContent: "center",
marginTop: 3,
marginBottom: 3,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use your css file for this

const fetchSightingData = async () => {
try {
const data = await axios.get(
`${BACKEND_URL}/sightings/${REPORT_NUMBER}`
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if report number is undefined or a number? you will still make a request

Comment on lines +20 to +29
const query = {};
if (stateQuery) {
query.state = stateQuery;
}
if (yearQuery) {
query.year = yearQuery;
}
const { data } = await axios.get(`${BACKEND_URL}/sightings`, {
params: query,
});
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const query = {};
if (stateQuery) {
query.state = stateQuery;
}
if (yearQuery) {
query.year = yearQuery;
}
const { data } = await axios.get(`${BACKEND_URL}/sightings`, {
params: query,
});
const { data } = await axios.get(`${BACKEND_URL}/sightings`, {
params: {
...(stateQuery && { state: stateQuery}),
...(yearQuery && {year: yearQuery}),
},
});

fetchData();
}, [stateQuery, yearQuery]);

console.log(sightings);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove logs

<Card sx={{ marginBottom: 3, width: 300 }}>
<CardContent sx={{ display: "flex", justifyContent: "flex-start" }}>
<p>
{index + 1}. {sighting.STATE} {sighting.YEAR}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the index + 1 doesnt make much sense here. Would put into variable

Comment on lines +42 to +57
<Link to={`./${sighting.REPORT_NUMBER}`} key={index}>
<Container
sx={{
display: "flex",
justifyContent: "center",
}}
>
<Card sx={{ marginBottom: 3, width: 300 }}>
<CardContent sx={{ display: "flex", justifyContent: "flex-start" }}>
<p>
{index + 1}. {sighting.STATE} {sighting.YEAR}
</p>
</CardContent>
</Card>
</Container>
</Link>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should make this whole thing a component

</Card>
</Container>
</Link>
) : null
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need for ternary operator when using null for else. Just use && shorthand

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants