Last active
January 31, 2023 21:47
-
-
Save captDaylight/24057df356ef36825c149b7caae297ae to your computer and use it in GitHub Desktop.
Open and close photon dialog example
This file contains hidden or 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 './App.css'; | |
import React, { useEffect, useState, useRef } from "react"; | |
import("@photonhealth/webcomponents").catch(() => {}); | |
function App() { | |
const [isOpen, setIsOpen] = useState(false); | |
return ( | |
<> | |
<button onClick={() => setIsOpen(true)}>Open Modal</button> | |
<photon-client | |
id="7N9QZujlNJHL8EIPqXpu1wq8OuXqoxKb" | |
org="org_KzSVZBQixLRkqj5d" | |
domain="auth.boson.health" | |
audience="https://api.boson.health" | |
uri="https://api.boson.health/graphql" | |
auto-login="true" | |
> | |
<PhotonModal isOpen={isOpen} setIsOpen={setIsOpen} /> | |
</photon-client> | |
</> | |
); | |
} | |
export const PhotonModal = ({ isOpen, setIsOpen }) => { | |
const photonDialogRef = useRef(null); | |
useEffect(() => { | |
if (photonDialogRef.current) { | |
photonDialogRef.current.addEventListener('photon-dialog-canceled', () => { | |
console.log('canceled!') | |
setIsOpen(false); | |
}) | |
} | |
}, [photonDialogRef]); | |
return ( | |
<photon-dialog | |
ref={photonDialogRef} | |
id="photon-modal" | |
label="Send Prescription" | |
hide-footer="true" | |
width="800px" | |
overlay-close="true" | |
header="true" | |
open={isOpen} | |
> | |
<photon-prescribe-workflow | |
patient-id="pat_01GQGDNW09VRK2CQ0Q41H57RVK" | |
enable-order="true" | |
/> | |
</photon-dialog> | |
); | |
}; | |
export default App; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment