Update: review entry edit button to Link

This commit is contained in:
2021-12-14 00:47:46 +08:00
parent 83ab1a91b2
commit 922b2370ee

View File

@@ -1,9 +1,7 @@
import { Link } from "react-router-dom";
import { useNavigate } from "react-router";
import { convertIntToDateTime } from "./Common";
function ReviewEntry(props) {
let navigate = useNavigate();
return (
<div>
<h4>
@@ -12,19 +10,15 @@ function ReviewEntry(props) {
</Link>{" "}
wrote on {convertIntToDateTime(props.review.created_at)}{" "}
{props.review.updated_at !== 0 &&
"(modified on " + convertIntToDateTime(props.review.updated_at) + ")"}
"(modified on " +
convertIntToDateTime(props.review.updated_at) +
")"}{" "}
{(props.user.role === 1 || props.review.user.id === props.user.id) &&
props.user.role !== 0 &&
<Link to={`/manage/reviews/${props.review.id}`}>Edit</Link>
}
</h4>
<p>{props.review.content}</p>
{(props.user.role === 1 || props.review.user.id === props.user.id) &&
props.user.role !== 0 && (
<button
onClick={() => {
navigate(`/manage/reviews/${props.review.id}`);
}}
>
Edit
</button>
)}
</div>
);
}