import { AppState } from '../index' ; import { Dispatch } from 'redux' ; import { connect } from 'react-redux' ; import { push } from 'connected-react-router' ; import { routes } from '../routes/Route' ; import { Header } from '../components/Header' ; import { CategorySimple } from '../dataObjects/category' ; const mapStateToProps = ( state ) => ( { isLoggedIn : ! ! state . authStatus . userId , ownUserId : state . authStatus . userId || 0 , categories : state . categories . categories . filter ( ( category ) => category . parentId === 0 ) , } ) ; const mapDispatchToProps = ( dispatch ) => ( { goToTopPage : ( ) => { dispatch ( push ( routes . timeline . path ) ) ; } , goToUserPage : ( userId ) => { dispatch ( push ( routes . user . getPath ( userId ) ) ) ; } , goToSettingPage : ( ) => { dispatch ( push ( routes . userSetting . path ) ) ; } , goToCategoryItemList : ( categoryId ) => { dispatch ( push ( routes . categoryTimeline . getPath ( categoryId ) ) ) ; } , onClickTitle : ( isLoggedIn ) => { if ( isLoggedIn ) { dispatch ( push ( routes . timeline . path ) ) ; return ; } dispatch ( push ( routes . top . path ) ) ; } , } ) ; export default connect ( mapStateToProps , mapDispatchToProps ) ( Header ) ;