import { Button, FocusModal, Heading, Table, useToggleState, } from "@medusajs/ui" import { useState } from "react" export default function useToggleStateDemo() { const [editOpen, showEdit, closeEdit] = useToggleState() const [entityToEdit, setEntityToEdit] = useState() const entities = ["foo", "bar", "baz"] const editEntity = (entity: string) => { setEntityToEdit(entity) showEdit() } const onSave = () => { // do entity update, etc. closeEdit() } return ( <> Entity Name Actions {entities.map((entity, index) => ( {entity} ))}
{ if (!modalOpened) { closeEdit() } }} > Edit Entity
Edit {entityToEdit}
) }