@@ -8,10 +8,18 @@ import * as es from "react-intl/locale-data/es";
88import * as fr from "react-intl/locale-data/fr" ;
99import { connect } from "react-redux" ;
1010import { routeNodeSelector } from "redux-router5" ;
11+ import { State as IRouteState } from "router5" ;
1112import { cssRaw , cssRule , style } from "typestyle" ;
1213
1314import { Header } from "../components" ;
14- import { AboutPage , CounterPage , HomePage , StarsPage } from "./index" ;
15+ import { IStore } from "../redux/IStore" ;
16+ import { IState } from "../redux/modules/baseModule" ;
17+ import { ILanguage } from "../redux/modules/languageModule" ;
18+ import { AboutPage } from "./AboutPage" ;
19+ import { CounterPage } from "./CounterPage" ;
20+ import { HomePage } from "./HomePage" ;
21+ import { RegisterPage } from "./RegisterPage" ;
22+ import { StarsPage } from "./StarsPage" ;
1523
1624const appConfig = require ( "../../../config/main" ) ;
1725
@@ -33,38 +41,45 @@ const Styles = {
3341 } )
3442} ;
3543
36- class App extends React . Component < any , any > {
44+ class App extends React . Component < IStateToProps , null > {
3745 private components : any = {
3846 about : AboutPage ,
3947 counter : CounterPage ,
4048 home : HomePage ,
49+ register : RegisterPage ,
4150 stars : StarsPage
4251 } ;
52+
4353 constructor ( ) {
4454 super ( ) ;
4555 addLocaleData ( [ ...en , ...es , ...fr , ...de ] ) ;
4656 }
4757
4858 public render ( ) : JSX . Element {
49- const { route} = this . props ;
59+ const { language , route} = this . props ;
5060 const segment = route ? route . name . split ( "." ) [ 0 ] : undefined ;
5161 return (
52- < IntlProvider locale = { this . props . languages . payload . locale } messages = { this . props . languages . payload . languageData } >
62+ < IntlProvider locale = { language . payload . locale } messages = { language . payload . languageData } >
5363 < section className = { Styles . container } >
5464 < Helmet { ...appConfig . app . head } />
5565 < Header />
56- { React . createElement ( this . components [ segment ] ) || < div > Not found</ div > }
66+ { segment && this . components [ segment ] ? React . createElement ( this . components [ segment ] ) : < div > Not found</ div > }
5767 </ section >
5868 </ IntlProvider >
5969 ) ;
6070 }
6171}
6272
63- const mapStateToProps = ( state ) => ( {
73+ interface IStateToProps {
74+ language : IState < ILanguage > ;
75+ route : IRouteState ;
76+ }
77+
78+ const mapStateToProps = ( state : Partial < IStore > ) => ( {
6479 languages : state . language ,
6580 ...routeNodeSelector ( "" ) ( state )
6681} ) ;
6782
68- const connectedApp = connect ( mapStateToProps ) ( App ) ;
83+ const connectedApp = connect < IStateToProps , null , null > ( mapStateToProps , null ) ( App ) ;
6984
70- export { connectedApp as App , Styles }
85+ export { connectedApp as App , App as UnconnectedApp , Styles }
0 commit comments