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