import { FunctionComponent, useState } from "react"; import Link from "next/link"; import { useRouter } from "next/router"; import Head from "next/head"; import ReferenceLinks from "../common/ReferenceLinks"; import { fetch, getItemPath } from "../../utils/dataAccess"; import { Review } from "../../types/Review"; interface Props { review: Review; text: string; } export const Show: FunctionComponent = ({ review, text }) => { const [error, setError] = useState(null); const router = useRouter(); const handleDelete = async () => { if (!review["@id"]) return; if (!window.confirm("Are you sure you want to delete this item?")) return; try { await fetch(review["@id"], { method: "DELETE" }); router.push("/reviews"); } catch (error) { setError("Error when deleting the resource."); console.error(error); } }; return (
{`Show Review ${review["@id"]}`}