Created
September 22, 2021 10:13
-
-
Save harrybanda/4e0b47b45826f0fe1f2e1e9409333850 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ForgeUI, { ModalDialog, Form, TextField } from "@forge/ui"; | |
import { storage } from "@forge/api"; | |
import uuid from "uuid-random"; | |
export const BookDialog = ({ isOpenModal, setOpenModal }) => { | |
const onSubmit = async (formData) => { | |
const bookId = "book_" + uuid(); | |
await storage.set(bookId, formData); | |
setOpenModal(false); | |
}; | |
return ( | |
isOpenModal && ( | |
<ModalDialog header="Add Book" onClose={() => setOpenModal(false)}> | |
<Form onSubmit={onSubmit}> | |
<TextField name="bookname" label="Book Name" /> | |
<TextField name="author" label="Author" /> | |
<TextField name="quantity" label="Quantity" /> | |
<TextField name="price" label="Price" /> | |
</Form> | |
</ModalDialog> | |
) | |
); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment