Agreements#Show
Show the terms and conditions flow
https://{{base_url}}/public/agreements?email={encodeURIComponent(USER_EMAIL)}import React, { useRef } from 'react';
const Agreements = ({ onComplete }) => {
const iframeRef = useRef();
const termsUrl = 'https://{{base_url}}/public/agreements?email={encodeURIComponent(USER_EMAIL)}'
// Set up a listener for the event that is fired when the user signs the Agreement
useEffect(() => {
window.addEventListener("message", onCompleteHandler);
return () => {
window.removeEventListener("message", onCompleteHandler);
};
}, []);
// Do something in your UI when the event fires
const onCompleteHandler = (event) => {
if (event.data.agreements === 'complete') {
onComplete();
} else if (Object.keys(event.data.agreements).find(i =>i.includes("agreed"))) {
// When a user has signed an agreement, refresh the termsUrl.
// This improves cross-browser support and prevents caching issues.
iframeRef.current.src = termsUrl
}
}
// Render the Agreement, passing in the User's email as a query parameter
return <iframe ref={iframeRef} src={termsUrl} />
}
export default Agreements;Last updated
Was this helpful?