@@ -17,22 +17,26 @@ import withTranslation from "../../util/withTranslation.js";
1717import Popup from '../Popup/Popup.js' ;
1818import About from '../../pages/Posts/About.js' ;
1919import MenuBookIcon from '@material-ui/icons/MenuBook' ;
20+ import { LocalizationConsumer } from '../../util/LocalizationContext' ;
2021
2122class LessonSelection extends React . Component {
2223 static contextType = ThemeContext ;
2324
2425 constructor ( props , context ) {
2526 super ( props ) ;
26- const { courseNum, setLanguage } = this . props ;
27+ // const { courseNum, setLanguage } = this.props;
2728
28- if ( courseNum == 6 ) {
29- setLanguage ( 'se' )
30- }
29+ // if (courseNum != null) {
30+ // const course = _coursePlansNoEditor[parseInt(courseNum)];
31+ // if (course && course.language) {
32+ // setLanguage(course.language);
33+ // }
34+ // }
3135
32- if ( props . history . location . pathname == '/' ) {
33- const defaultLocale = localStorage . getItem ( 'defaultLocale ' ) ;
34- setLanguage ( defaultLocale )
35- }
36+ // if (props.history.location.pathname == '/') {
37+ // const defaultLocale = localStorage.getItem('platformLanguage ');
38+ // setLanguage(defaultLocale)
39+ // }
3640
3741 this . user = context . user || { }
3842 this . isPrivileged = ! ! this . user . privileged
@@ -63,6 +67,13 @@ class LessonSelection extends React.Component {
6367 this . setState ( { preparedRemoveProgress : true } ) ;
6468 }
6569
70+ handleCourseSelect = ( course , courseIndex ) => {
71+ const { history } = this . props ;
72+ // localStorage.setItem("defaultLocale", course.language);
73+
74+ history . push ( `/courses/${ courseIndex } ` ) ;
75+ } ;
76+
6677 render ( ) {
6778 const { translate } = this . props ;
6879 const { classes, courseNum } = this . props ;
@@ -116,9 +127,11 @@ class LessonSelection extends React.Component {
116127 < IconButton aria-label = { `View Course ${ i } ` }
117128 aria-roledescription = { `Navigate to course ${ i } 's page to view available lessons` }
118129 role = { "link" }
119- onClick = { ( ) => {
120- this . props . history . push ( `/courses/${ i } ` )
121- } } >
130+ // onClick={() => {
131+ // this.props.history.push(`/courses/${i}`)
132+ // }}
133+ onClick = { ( ) => this . handleCourseSelect ( course , i ) }
134+ >
122135 < img
123136 src = { `${ process . env . PUBLIC_URL } /static/images/icons/folder.png` }
124137 width = "64px"
@@ -206,4 +219,16 @@ class LessonSelection extends React.Component {
206219 }
207220}
208221
209- export default withStyles ( styles ) ( withTranslation ( LessonSelection ) ) ;
222+ // export default withStyles(styles)(withTranslation(LessonSelection));
223+
224+ export default withStyles ( styles ) ( withTranslation ( ( props ) => (
225+ < LocalizationConsumer >
226+ { ( { language, platformLanguage } ) => (
227+ < LessonSelection
228+ { ...props }
229+ language = { language }
230+ platformLanguage = { platformLanguage }
231+ />
232+ ) }
233+ </ LocalizationConsumer >
234+ ) ) ) ;
0 commit comments