import { Box, Modal } from '@rocket.chat/fuselage'; import type { ComponentProps } from 'react'; import { useEffect } from 'react'; import { useTranslation } from 'react-i18next'; const iframeMsgListener = (confirm: (data: any) => void, cancel: () => void) => (e: MessageEvent) => { let data; try { data = JSON.parse(e.data); } catch (e) { return; } data.result ? confirm(data) : cancel(); }; export type IframeModalProps = { url: string; confirm: (data: any) => void; cancel: () => void; wrapperHeight?: string; } & ComponentProps; const IframeModal = ({ url, confirm, cancel, wrapperHeight = 'x360', ...props }: IframeModalProps) => { const { t } = useTranslation(); useEffect(() => { const listener = iframeMsgListener(confirm, cancel); window.addEventListener('message', listener); return () => { window.removeEventListener('message', listener); }; }, [confirm, cancel]); return (