Skip to content

Instantly share code, notes, and snippets.

@harrybanda
Created September 22, 2021 10:13
Show Gist options
  • Save harrybanda/4e0b47b45826f0fe1f2e1e9409333850 to your computer and use it in GitHub Desktop.
Save harrybanda/4e0b47b45826f0fe1f2e1e9409333850 to your computer and use it in GitHub Desktop.
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