forked from aces/EEG2BIDS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
107 lines (101 loc) · 2.89 KB
/
App.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
import React, {useEffect, useState} from 'react';
import {AppContext} from './context';
import './css/App.css';
// Socket.io
import {Socket} from './jsx/socket.io';
const uri = 'http://127.0.0.1:7301';
const options = {
transports: ['websocket'],
};
// Main components
import Menu from './jsx/elements/menu';
import Help from './jsx/elements/help';
import SplashScreen from './jsx/SplashScreen';
import Welcome from './jsx/Welcome';
import Configuration from './jsx/Configuration';
import Validator from './jsx/Validator';
/**
* App - the main window.
* @return {JSX.Element}
*/
const App = () => {
// React State
const [appMode, setAppMode] = useState('SplashScreen');
const [activeMenuTab, setActiveMenuTab] = useState(0);
const [task, setTask] = useState({});
/**
* Similar to componentDidMount and componentDidUpdate.
*/
useEffect(() => {
setTimeout(
() => {
setAppMode('Welcome');
}, 1500);
}, []);
/**
* Renders the React component.
* @return {JSX.Element} - React markup for component.
*/
return (
<Socket uri={uri} options={options}>
<AppContext.Provider value={{
setAppMode: (appMode) => {
setAppMode(appMode);
},
setTask: (key, value) => {
task[key] = value;
setTask(task);
},
getFromTask: (key) => {
return task[key] ?? '';
},
}}>
<>
{/*<Help visible={appMode !== 'SplashScreen'} activeMode={appMode}/>*/}
<Menu visible={appMode !== 'SplashScreen'}
tabs={[
{
title: '1) Getting started',
onClick: (e) => {
e.preventDefault();
setActiveMenuTab(0);
setAppMode('Welcome');
},
},
{
title: '2) Configuration',
onClick: (e) => {
e.preventDefault();
setActiveMenuTab(1);
setAppMode('Configuration');
},
},
{
title: '3) EDF to BIDS',
onClick: (e) => {
e.preventDefault();
setActiveMenuTab(2);
setAppMode('Converter');
},
},
{
title: '4) Validate and package',
onClick: (e) => {
e.preventDefault();
setActiveMenuTab(3);
setAppMode('Validator');
},
},
]}
activeTab={activeMenuTab}
/>
<SplashScreen visible={appMode === 'SplashScreen'}/>
<Welcome visible={appMode === 'Welcome'}/>
<Configuration appMode={appMode}/>
<Validator visible={appMode === 'Validator'}/>
</>
</AppContext.Provider>
</Socket>
);
};
export default App;