Upload 5.5, 5.6, and 5.7

This commit is contained in:
Andrew Trieu
2023-06-20 15:13:14 +03:00
parent bef62485da
commit 67a52f38a2
4 changed files with 133 additions and 72 deletions

View File

@@ -0,0 +1,59 @@
import { useState } from "react";
export const BlogForm = ({ createBlog }) => {
const [title, setTitle] = useState("");
const [author, setAuthor] = useState("");
const [urlAddress, setUrlAddress] = useState("");
const resetInputFields = () => {
setTitle("");
setAuthor("");
setUrlAddress("");
};
const addBlog = async (event) => {
event.preventDefault();
createBlog({
title: title,
author: author,
url: urlAddress,
});
resetInputFields();
};
return (
<div>
<h2> Create new blog</h2>
<form onSubmit={addBlog}>
<div>
Title:
<input
type="text"
value={title}
name="title"
onChange={(event) => setTitle(event.target.value)}
/>
</div>
<div>
Author:
<input
type="text"
value={author}
name="author"
onChange={(event) => setAuthor(event.target.value)}
/>
</div>
<div>
URL:
<input
type="text"
value={urlAddress}
name="urlAddress"
onChange={(event) => setUrlAddress(event.target.value)}
/>
</div>
<button type="submit">Create</button>
</form>
</div>
);
};