bruno/packages/grafnode-run/src/pageComponents/Main/index.js

63 lines
1.6 KiB
JavaScript
Raw Normal View History

2021-12-03 20:37:38 +01:00
import React from 'react';
import dynamic from 'next/dynamic'
2021-12-03 21:33:46 +01:00
import {
Navbar,
RequestTabs,
Sidebar
} from '@grafnode/components';
2021-12-03 20:37:38 +01:00
import actions from 'providers/Store/actions';
import { useStore } from '../../providers/Store/index';
2021-12-03 20:37:38 +01:00
import StyledWrapper from './StyledWrapper';
import 'codemirror/mode/javascript/javascript';
import 'codemirror/addon/edit/matchbrackets';
import 'codemirror/addon/fold/brace-fold';
import 'codemirror/addon/fold/foldgutter';
2021-12-05 17:04:03 +01:00
import 'codemirror-graphql/mode';
import 'codemirror/addon/fold/foldgutter.css';
const RequestTabPanel = dynamic(import('@grafnode/components').then(mod => mod.RequestTabPanel), { ssr: false });
2021-12-03 20:37:38 +01:00
export default function Main() {
// disable ssr
if(typeof window === 'undefined') {
return null;
}
2021-12-03 20:37:38 +01:00
const [state, dispatch] = useStore();
const {
collections,
2021-12-03 21:33:46 +01:00
requestTabs,
2021-12-03 20:37:38 +01:00
activeRequestTabId
} = state;
return (
<div>
<Navbar />
<StyledWrapper>
<Sidebar
collections={collections}
actions={actions}
dispatch={dispatch}
activeRequestTabId={activeRequestTabId}
/>
<section className='mt-4 flex flex-grow flex-col'>
2021-12-03 21:33:46 +01:00
<RequestTabs
requestTabs={requestTabs}
actions={actions}
dispatch={dispatch}
activeRequestTabId={activeRequestTabId}
/>
<RequestTabPanel
collections={collections}
requestTabs={requestTabs}
activeRequestTabId={activeRequestTabId}
/>
2021-12-03 20:37:38 +01:00
</section>
</StyledWrapper>
</div>
)
}