generated from openedx/frontend-template-application
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
624 additions
and
427 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export const FETCH_INSTITUTION_DATA_REQUEST = 'FETCH_INSTITUTION_DATA_REQUEST'; | ||
export const FETCH_INSTITUTION_DATA_SUCCESS = 'FETCH_INSTITUTION_DATA_SUCCESS'; | ||
export const FETCH_INSTITUTION_DATA_FAILURE = 'FETCH_INSTITUTION_DATA_FAILURE'; |
2 changes: 1 addition & 1 deletion
2
...tures/Main/Header/data/_test_/api.test.js → src/features/Main/data/_test_/api.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,68 @@ | ||
import React, { useEffect, useReducer } from 'react'; | ||
import { BrowserRouter, Switch, Route } from 'react-router-dom'; | ||
import React from 'react'; | ||
import { Sidebar } from 'features/Main/Sidebar'; | ||
import { Header } from 'features/Main/Header'; | ||
import { Footer } from 'features/Main/Footer'; | ||
import StudentsPage from 'features/Students/StudentsPage'; | ||
import Container from '@edx/paragon/dist/Container'; | ||
import { getConfig } from '@edx/frontend-platform'; | ||
import InstructorsPage from 'features/Instructors/InstructorsPage'; | ||
import reducer from 'features/Main/reducer'; | ||
import { getInstitutionName } from 'features/Main/data/api'; | ||
import { InstitutionContext } from 'features/Main/institutionContext'; | ||
import { | ||
FETCH_INSTITUTION_DATA_REQUEST, | ||
FETCH_INSTITUTION_DATA_SUCCESS, | ||
FETCH_INSTITUTION_DATA_FAILURE, | ||
} from 'features/Main/actionTypes'; | ||
import { RequestStatus } from 'features/constants'; | ||
import './index.scss'; | ||
|
||
const Main = () => ( | ||
<BrowserRouter basename={getConfig().INSTITUTION_PORTAL_PATH}> | ||
<div className="pageWrapper"> | ||
<Sidebar /> | ||
<main> | ||
<Container size="xl"> | ||
<Header /> | ||
<Switch> | ||
<Route path="/students" exact component={StudentsPage} /> | ||
</Switch> | ||
<Switch> | ||
<Route path="/instructors" exact component={InstructorsPage} /> | ||
</Switch> | ||
<Footer /> | ||
</Container> | ||
const initialState = { | ||
data: [], | ||
status: RequestStatus.SUCCESS, | ||
error: null, | ||
}; | ||
|
||
</main> | ||
</div> | ||
</BrowserRouter> | ||
); | ||
const Main = () => { | ||
const [state, dispatch] = useReducer(reducer, initialState); | ||
|
||
useEffect(() => { | ||
const fetchData = async () => { | ||
dispatch({ type: FETCH_INSTITUTION_DATA_REQUEST }); | ||
|
||
try { | ||
const response = await getInstitutionName(); | ||
dispatch({ type: FETCH_INSTITUTION_DATA_SUCCESS, payload: response.data }); | ||
} catch (error) { | ||
dispatch({ type: FETCH_INSTITUTION_DATA_FAILURE, payload: error }); | ||
} | ||
}; | ||
|
||
fetchData(); | ||
}, []); | ||
|
||
return ( | ||
<BrowserRouter basename={getConfig().INSTITUTION_PORTAL_PATH}> | ||
<InstitutionContext.Provider value={state.data}> | ||
<div className="pageWrapper"> | ||
<Sidebar /> | ||
<main> | ||
<Container size="xl"> | ||
<Header /> | ||
<Switch> | ||
<Route path="/students" exact component={StudentsPage} /> | ||
</Switch> | ||
<Switch> | ||
<Route path="/instructors" exact component={InstructorsPage} /> | ||
</Switch> | ||
<Footer /> | ||
</Container> | ||
</main> | ||
</div> | ||
</InstitutionContext.Provider> | ||
</BrowserRouter> | ||
); | ||
}; | ||
|
||
export default Main; |
Oops, something went wrong.