import React, { useState } from "react"; import Layout from "../components/Layout"; import Router from "next/router"; import Link from "next/link"; const Draft: React.FC = () => { const [title, setTitle] = useState(""); const [content, setContent] = useState(""); const [authorName, setAuthorName] = useState(""); const submitData = async (e: React.SyntheticEvent) => { e.preventDefault(); try { const body = { title, content, authorName }; const result = await fetch(`/api/post`, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(body), }); await result.json(); await Router.push("/drafts"); } catch (error) { console.error(error); } }; return (

Create draft

setTitle(e.target.value)} placeholder="Title" type="text" value={title} /> setAuthorName(e.target.value)} placeholder="Author name" type="text" value={authorName} />