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

Connect-react Lab #12

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Prev Previous commit
Next Next commit
edit logdetails
DiegoCarrero committed Apr 18, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit cf6c7d0b76304d4de9c38998fe09a269211d7c15
23 changes: 7 additions & 16 deletions src/components/LogDetails.js
Original file line number Diff line number Diff line change
@@ -11,33 +11,24 @@ export default function LogDetails() {
useEffect(() => {
axios
.get(`${API}/logs/${index}`)
.then((response) => setLog(response.data))
.catch(() => {
navigate('/not-found')
})
}, [index, navigate]);
.then(response => setLog(response.data))
.catch((error) => console.error(error))
}, [index]);

const handleDelete = () => {
axios
.delete(`${API}/logs/${index}`)
.then(() => navigate(`/logs`))
.then(() => navigate('/logs'))
.catch((e) => console.error(e))
};

return (
<article>
<h3>
{log.mistakesWereMadeToday ? <span>⭐️</span> : null} {log.name}
{log.mistakesWereMadeToday ? <span>💥</span> : null} {log.captainName}
</h3>
<h5>
<span>
<a href={log.url}>{log.name}</a>
</span>{" "}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
{log.url}
</h5>
<h6>{log.category}</h6>
<p>{log.description}</p>
<h4>{log.title}</h4>
<p>{log.post}</p>
<div className="showNavigation">
<div>
{" "}