diff --git a/src/components/Assesment/Assesment.jsx b/src/components/Assesment/Assesment.jsx index 3d07ef07..61332e88 100644 --- a/src/components/Assesment/Assesment.jsx +++ b/src/components/Assesment/Assesment.jsx @@ -647,14 +647,38 @@ const Assesment = ({ discoverStart }) => { const { virtualId } = useSelector((state) => state.user); - const [isVideoOpen, setIsVideoOpen] = useState(false); - const handleOpenVideo = () => { - setIsVideoOpen(true); - }; + if (process.env.REACT_APP_SHOW_HELP_VIDEO === "true") { + let allowedOrigins = []; + try { + allowedOrigins = JSON.parse( + process.env.REACT_APP_PARENT_ORIGIN_URL || "[]" + ); + } catch (error) { + console.error( + "Invalid JSON format in REACT_APP_PARENT_ORIGIN_URL:", + error + ); + } + + const parentOrigin = + window?.location?.ancestorOrigins?.[0] || window.parent.location.origin; - const handleCloseVideo = () => { - setIsVideoOpen(false); + if (allowedOrigins.includes(parentOrigin)) { + try { + window.parent.postMessage( + { + message: "help-video-link", + }, + parentOrigin + ); + } catch (error) { + console.error("Error sending postMessage:", error); + } + } else { + console.warn(`Parent origin "${parentOrigin}" is not allowed.`); + } + } }; const navigate = useNavigate(); @@ -855,48 +879,6 @@ const Assesment = ({ discoverStart }) => { )} - {/* Video Modal */} - - -