import dynamic from 'next/dynamic' import Split from 'react-split' import { useSnapshot } from 'valtio' import { Box, Container, Flex, Tab, Tabs } from '../../components' import Transaction from '../../components/Transaction' import state, { renameTxState } from '../../state' import { getSplit, saveSplit } from '../../state/actions/persistSplits' import { transactionsState, modifyTxState } from '../../state' import { useEffect, useState } from 'react' import { FileJs } from 'phosphor-react' import RunScript from '../../components/RunScript' const DebugStream = dynamic(() => import('../../components/DebugStream'), { ssr: false }) const LogBox = dynamic(() => import('../../components/LogBox'), { ssr: false }) const Accounts = dynamic(() => import('../../components/Accounts'), { ssr: false }) const Test = () => { // This and useEffect is here to prevent useLayoutEffect warnings from react-split const [showComponent, setShowComponent] = useState(false) const { transactionLogs } = useSnapshot(state) const { transactions, activeHeader } = useSnapshot(transactionsState) const snap = useSnapshot(state) useEffect(() => { setShowComponent(true) }, []) if (!showComponent) { return null } const hasScripts = Boolean(snap.files.filter(f => f.name.toLowerCase()?.endsWith('.js')).length) const renderNav = () => ( {snap.files .filter(f => f.name.endsWith('.js')) .map(file => ( ))} ) return ( saveSplit('testVertical', e)} > saveSplit('testHorizontal', e)} > { if (header) transactionsState.activeHeader = header }} keepAllAlive defaultExtension="json" allowedExtensions={['json']} onCreateNewTab={header => modifyTxState(header, {})} onRenameTab={(idx, nwName, oldName = '') => renameTxState(oldName, nwName)} onCloseTab={(idx, header) => header && modifyTxState(header, undefined)} > {transactions.map(({ header, state }) => ( ))} {hasScripts ? ( (state.scriptLogs = [])} renderNav={renderNav} /> ) : null} (state.transactionLogs = [])} /> ) } export default Test