From 2688c054a2986db581e516dd5f0e7f43d8c2983f Mon Sep 17 00:00:00 2001 From: "prudhvi.k" Date: Sat, 7 Jun 2025 00:39:00 +0530 Subject: [PATCH 1/2] added post call to navigator --- client/src/App.jsx | 2 + .../SidebarLayoutFrame/SidebarLayoutFrame.jsx | 3 + .../Navigator/components/NavigatorContent.jsx | 80 +++++++++++++++++++ server/constants.js | 1 + server/server.js | 2 + 5 files changed, 88 insertions(+) create mode 100644 client/src/pages/Navigator/components/NavigatorContent.jsx diff --git a/client/src/App.jsx b/client/src/App.jsx index ab2d1e1..fa2849a 100644 --- a/client/src/App.jsx +++ b/client/src/App.jsx @@ -18,6 +18,7 @@ import Contacts from './pages/Contacts/Contacts.jsx'; import ContactForm from './pages/ContactForm/ContactForm.jsx'; import DemoAccountInitializer from './services/demoAccountInitializer.js'; import createPrefixedLogger from './helpers/logger.js'; +import Navigator from './pages/Navigator/Navigator.jsx'; const logger = createPrefixedLogger('App'); @@ -61,6 +62,7 @@ function App() { } /> } /> } /> + } /> ); } diff --git a/client/src/components/SidebarLayoutFrame/SidebarLayoutFrame.jsx b/client/src/components/SidebarLayoutFrame/SidebarLayoutFrame.jsx index 399b197..a46d227 100644 --- a/client/src/components/SidebarLayoutFrame/SidebarLayoutFrame.jsx +++ b/client/src/components/SidebarLayoutFrame/SidebarLayoutFrame.jsx @@ -22,6 +22,9 @@ const SidebarLayoutFrame = ({ children }) => { {t.tabs.contacts} + + {t.tabs.navigator} +
{children}
diff --git a/client/src/pages/Navigator/components/NavigatorContent.jsx b/client/src/pages/Navigator/components/NavigatorContent.jsx new file mode 100644 index 0000000..96bb63e --- /dev/null +++ b/client/src/pages/Navigator/components/NavigatorContent.jsx @@ -0,0 +1,80 @@ +import { useState, useEffect, useRef } from 'react'; +import { useSelector } from 'react-redux'; +import { api } from '../../../api'; +import styles from './NavigatorContent.module.css'; + +const NavigatorContent = () => { + const [error, setError] = useState(null); + const iframe = useRef(null); + const userEmail = useSelector(state => state.auth.userEmail); + const userName = useSelector(state => state.auth.userName); + + useEffect(() => { + const initNavigator = async () => { + try { + const response = await api.navigator.getData(); + const { token } = response.data; + console.log('Navigator token:', token); + if (!iframe.current) return; + + // Configure the iframe + iframe.current.src = 'https://apps-d.docusign.com/navigator-for-partners'; + + const handleIframeLoad = () => { + const dataToSend = { + message: 'Embedded-Navigator-View', + authInfo: { access_token: token }, + userInfo: { + sub: '13f69e9e-d3ec-4cfe-b551-5ff33b1751c8', + name: "prudhvi nag", + email: "prudhvinag@dsxtr.com", + accounts: [{ + account_id: 'c9b55f81-6261-4a6e-b53f-59a2d341c10f', + name: userName, + is_default: true, + account_name: userName, + base_uri: 'https://demo.docusign.net', + }] + }, + envelopeIds: [], + currentAccount: 'c9b55f81-6261-4a6e-b53f-59a2d341c10f', + timestamp: new Date().toISOString() + }; + + iframe.current.contentWindow.postMessage( + dataToSend, + iframe.current.src + ); + }; + + iframe.current.onload = handleIframeLoad; + + } catch (err) { + setError(err.message); + console.error('Navigator initialization error:', err); + } + }; + + initNavigator(); + }, [userEmail, userName]); + + if (error) return
Error: {error}
; + + return ( +
+
+

DocuSign Navigator

+
+