11import React , { useReducer } from 'react' ;
22import styles from './App.module.scss' ;
33import { GlobalContext , globalState , globalReducer } from './context/reducers/globalReducer' ;
4- import { ReactTestCaseContext , reactTestCaseState , reactTestCaseReducer } from './context/reducers/reactTestCaseReducer' ;
5- import {
6- PuppeteerTestCaseContext ,
7- puppeteerTestCaseState ,
8- puppeteerTestCaseReducer ,
9- } from './context/reducers/puppeteerTestCaseReducer' ;
10- import {
11- EndpointTestCaseContext ,
12- endpointTestCaseState ,
13- endpointTestCaseReducer ,
14- } from './context/reducers/endpointTestCaseReducer' ;
15- import {
16- ReduxTestCaseContext ,
17- reduxTestCaseState ,
18- reduxTestCaseReducer ,
19- } from './context/reducers/reduxTestCaseReducer' ;
20- import {
21- HooksTestCaseContext ,
22- hooksTestCaseState ,
23- hooksTestCaseReducer ,
24- } from './context/reducers/hooksTestCaseReducer' ;
25- import {
26- TestFileModalContext ,
27- testFileModalState ,
28- testFileModalReducer ,
29- } from './context/reducers/testFileModalReducer' ;
30-
31- import { MockDataContext , mockDataState , mockDataReducer } from './context/reducers/mockDataReducer' ;
324import ProjectLoader from './pages/ProjectLoader/ProjectLoader' ;
335import NavBar from './components/NavBar/NavBar' ;
346import LeftPanel from './pages//LeftPanel/LeftPanel' ;
357import RightPanel from './pages/RightPanel/RightPanel' ;
8+ import About from './pages/About/About' ;
369
3710const App = ( ) => {
38- const [ global , dispatchToGlobal ] = useReducer ( globalReducer , globalState ) ;
39- const [ reactTestCase , dispatchToReactTestCase ] = useReducer ( reactTestCaseReducer , reactTestCaseState ) ;
40- const [ mockData , dispatchToMockData ] = useReducer ( mockDataReducer , mockDataState ) ;
41- const [ endpointTestCase , dispatchToEndpointTestCase ] = useReducer (
42- endpointTestCaseReducer ,
43- endpointTestCaseState
44- ) ;
45-
46- const [ reduxTestCase , dispatchToReduxTestCase ] = useReducer (
47- reduxTestCaseReducer ,
48- reduxTestCaseState
49- ) ;
50- const [ hooksTestCase , dispatchToHooksTestCase ] = useReducer (
51- hooksTestCaseReducer ,
52- hooksTestCaseState
53- ) ;
54- const [ puppeteerTestCase , dispatchToPuppeteerTestCase ] = useReducer (
55- puppeteerTestCaseReducer ,
56- puppeteerTestCaseState
57- ) ;
58- const [ testFileModal , dispatchToTestFileModal ] = useReducer (
59- testFileModalReducer ,
60- testFileModalState
61- ) ;
11+ // useReducer takes a reducer and initial state as
12+ // args and return the current state paired with a dispatch method
13+ // distpatchTo method invokes associated reducer function
6214
15+ const [ global , dispatchToGlobal ] = useReducer ( globalReducer , globalState ) ;
6316
6417 if ( ! global . isProjectLoaded ) {
6518 return (
6619 < div >
20+ { /* pass global state and dispatch function as prop to context provider for child components */ }
6721 < GlobalContext . Provider value = { [ global , dispatchToGlobal ] } >
6822 < ProjectLoader />
6923 </ GlobalContext . Provider >
@@ -72,7 +26,7 @@ const App = () => {
7226 } else {
7327 return (
7428 /**
75- * Wrap the components that we want to share the unique states with (ex: share testCase state with navbar & left panel (the two containers that hold the components that need testCaseRducer)) in the unique providers (ex: TestCaseContext.Provider) .
29+ * Wrap the components that we want to share the unique states with.
7630 * You can only provide one value to a Provider.
7731 * - In order to avoid creating separate Contexts, wrap multiples in an array (ex: testCase and dispatchToTestCase).
7832 *
@@ -83,28 +37,32 @@ const App = () => {
8337 *
8438 * We access the value that we gave to the Provider through useContext
8539 */
86- < div id = { global . isFileDirectoryOpen ?
87- ( global . isRightPanelOpen ? styles . fileDirectoryOpenRightPanelOpen : styles . fileDirectoryOpenRightPanelClosed ) :
88- ( global . isRightPanelOpen ? styles . fileDirectoryClosedRightPanelOpen : styles . fileDirectoryClosedRightPanelClosed )
89- } >
40+ < div
41+ id = {
42+ global . isProjectLoaded === 'about'
43+ ? ''
44+ : global . isFileDirectoryOpen
45+ ? global . isRightPanelOpen
46+ ? styles . fileDirectoryOpenRightPanelOpen
47+ : styles . fileDirectoryOpenRightPanelClosed
48+ : global . isRightPanelOpen
49+ ? styles . fileDirectoryClosedRightPanelOpen
50+ : styles . fileDirectoryClosedRightPanelClosed
51+ }
52+ >
9053 < GlobalContext . Provider value = { [ global , dispatchToGlobal ] } >
91- < ReduxTestCaseContext . Provider value = { [ reduxTestCase , dispatchToReduxTestCase ] } >
92- < ReactTestCaseContext . Provider value = { [ reactTestCase , dispatchToReactTestCase ] } >
93- < EndpointTestCaseContext . Provider value = { [ endpointTestCase , dispatchToEndpointTestCase ] } >
94- < HooksTestCaseContext . Provider value = { [ hooksTestCase , dispatchToHooksTestCase ] } >
95- < TestFileModalContext . Provider value = { [ testFileModal , dispatchToTestFileModal ] } >
96- < MockDataContext . Provider value = { [ mockData , dispatchToMockData ] } >
97- < PuppeteerTestCaseContext . Provider value = { [ puppeteerTestCase , dispatchToPuppeteerTestCase ] } >
98- < NavBar />
99- < LeftPanel />
100- </ PuppeteerTestCaseContext . Provider >
101- </ MockDataContext . Provider >
102- </ TestFileModalContext . Provider >
103- </ HooksTestCaseContext . Provider >
104- </ EndpointTestCaseContext . Provider >
105- </ ReactTestCaseContext . Provider >
106- </ ReduxTestCaseContext . Provider >
107- { global . isRightPanelOpen ? < RightPanel /> : '' }
54+ { global . isProjectLoaded === 'about' ? (
55+ < >
56+ < NavBar inAboutPage = { true } />
57+ < About dispatch = { dispatchToGlobal } /> { ' ' }
58+ </ >
59+ ) : (
60+ < >
61+ < NavBar inAboutPage = { false } />
62+ < LeftPanel />
63+ </ >
64+ ) }
65+ { global . isRightPanelOpen ? < RightPanel /> : '' }
10866 </ GlobalContext . Provider >
10967 </ div >
11068 ) ;
0 commit comments