-
Notifications
You must be signed in to change notification settings - Fork 93
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
base: main
Are you sure you want to change the base?
Conversation
linkStyle = { | ||
textDecoration: "none", | ||
color: "white", | ||
}; |
There was a problem hiding this comment.
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
const form = e.target; | ||
const query = form.search.value; |
There was a problem hiding this comment.
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
if (isNaN(query)) { | ||
props.setSearchParams({ state: query }); | ||
} else { | ||
props.setSearchParams({ year: query }); | ||
} |
There was a problem hiding this comment.
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?
display: "flex", | ||
justifyContent: "center", | ||
marginTop: 3, | ||
marginBottom: 3, |
There was a problem hiding this comment.
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}` |
There was a problem hiding this comment.
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
const query = {}; | ||
if (stateQuery) { | ||
query.state = stateQuery; | ||
} | ||
if (yearQuery) { | ||
query.year = yearQuery; | ||
} | ||
const { data } = await axios.get(`${BACKEND_URL}/sightings`, { | ||
params: query, | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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); |
There was a problem hiding this comment.
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} |
There was a problem hiding this comment.
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
<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> |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
No description provided.