import React, { useCallback, useEffect, useRef, useState } from "react" import { Modal, Message } from 'semantic-ui-react'; import { useFetch } from '../../hooks/useFetch'; import Debug from '../../utilities/Debug'; /** * Custom hook to check iframe reachability. * @param {string} url - The URL to check for reachability. * @returns {boolean} - True if reachable, false otherwise. */ const useCheckReachability = (url) => { const { data, error } = useFetch(url); Debug.log('Checking reachability for:', url); return { isReachable: !!data, error }; }; /** * A component to render a debug message. * @param {string} message - The debug message to display. */ const DebugMessage = ({ message }) => { useEffect(() => { Debug.log(message); }, [message]); return null; // This component does not render anything. }; /** * A function to create a one-purpose utility. * @param {Function} fn - The function to execute. * @param {Array} args - The arguments to pass to the function. * @returns {any} - The result of the function execution. */ const executeUtility = (fn, ...args) => { Debug.log('Executing utility function with args:', args); return fn(...args); }; import {TbResize} from 'react-icons/tb' import {BiCube, BiRefresh} from 'react-icons/bi' import {BsTrash} from 'react-icons/bs' import {CgLayoutGridSmall} from 'react-icons/cg' import {useDrag} from '@use-gesture/react' import { useSpring, animated } from 'react-spring' const MINIMUM_HEIGHT = 600; const MINIMUM_WIDTH = 540; export default function CustomNodeIframe({id, data}){ const [collapsed, setCollapsible] = useState(true) const [{width, height}, api] = useSpring(() => ({width: MINIMUM_WIDTH, height: MINIMUM_HEIGHT })) const [sizeAdjuster, setSizeAdjuster] = useState(false) const [reachable ,setReachable] = useState(false) const [refresh, setRefresh] = useState(0) const dragElement = useRef() const bind = useDrag((state) => { const isResizing = (state?.event.target === dragElement.current); if (isResizing) { api.set({ width: state.offset[0], height: state.offset[1], }); } }, { from: (event) => { const isResizing = (event.target === dragElement.current); if (isResizing) { return [width.get(), height.get()]; } }, }); useEffect(() => { const fetched = setInterval( async () => { setReachable(true) clearInterval(fetched) },1000) },[]) return (
{}}>
{setCollapsible((clps) => !clps)}}>
{setSizeAdjuster((size) => !size)}}>
{data.delete([{id}])}}>
{setRefresh((old) => old++)}}>
{ !collapsed && reachable && <>