import { useState } from 'react'; import '../styles/Modal.css'; const AddModal = ({onExit}) => { const [name, setName] = useState(''); const [link, setLink] = useState(''); const [tag, setTag] = useState(''); function SetName(e) { setName(e.target.value); } function SetLink(e) { setLink(e.target.value); } function SetTag(e) { setTag(e.target.value); } async function submitBookmark() { if(name != '' && link != '' && tag != '') { fetch("/post", { // Adding method type method: "POST", // Adding body or contents to send body: JSON.stringify({ name: name, title: "foo", link: link, tag: tag }), // Adding headers to the request headers: { "Content-type": "application/json; charset=UTF-8" } }); onExit(); } else { alert('Please fill all fields...'); } } function abort(e) { if (e.target.className == "overlay" || e.target.className == "cancel-btn") { onExit(); } } return (

Add Bookmark

Name:

Link:

Tag:

) } export default AddModal