2020-08-03 14:18:48 +00:00
|
|
|
import React from "react";
|
|
|
|
|
import { connect } from "react-redux";
|
|
|
|
|
import { getCurrentUser } from "actions/authActions";
|
|
|
|
|
import PageHeader from "pages/common/PageHeader";
|
|
|
|
|
import LoginHeader from "pages/common/LoginHeader";
|
|
|
|
|
import { Route, Switch } from "react-router";
|
|
|
|
|
import {
|
|
|
|
|
APP_VIEW_URL,
|
|
|
|
|
BASE_URL,
|
|
|
|
|
BUILDER_URL,
|
|
|
|
|
USER_AUTH_URL,
|
|
|
|
|
} from "constants/routes";
|
|
|
|
|
import { withRouter, RouteComponentProps } from "react-router";
|
2020-08-06 11:06:53 +00:00
|
|
|
import AppViewerHeader from "pages/AppViewer/viewer/AppViewerHeader";
|
2020-08-07 06:56:47 +00:00
|
|
|
import AppEditorHeader from "pages/Editor/EditorHeader";
|
2020-08-03 14:18:48 +00:00
|
|
|
|
2020-12-17 07:03:59 +00:00
|
|
|
type Props = {
|
|
|
|
|
getCurrentUser: () => void;
|
|
|
|
|
} & RouteComponentProps;
|
2020-08-03 14:18:48 +00:00
|
|
|
|
|
|
|
|
class AppHeader extends React.Component<Props, any> {
|
|
|
|
|
componentDidMount() {
|
|
|
|
|
this.props.getCurrentUser();
|
|
|
|
|
}
|
|
|
|
|
render() {
|
|
|
|
|
return (
|
|
|
|
|
<React.Fragment>
|
|
|
|
|
<Switch>
|
2020-08-07 06:56:47 +00:00
|
|
|
<Route path={BUILDER_URL} component={AppEditorHeader} />
|
2020-08-06 11:06:53 +00:00
|
|
|
<Route path={APP_VIEW_URL} component={AppViewerHeader} />
|
2020-08-03 14:18:48 +00:00
|
|
|
<Route path={USER_AUTH_URL} component={LoginHeader} />
|
|
|
|
|
<Route path={BASE_URL} component={PageHeader} />
|
|
|
|
|
</Switch>
|
|
|
|
|
</React.Fragment>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-17 07:03:59 +00:00
|
|
|
const mapDispatchToProps = (dispatch: any) => ({
|
2020-08-03 14:18:48 +00:00
|
|
|
getCurrentUser: () => dispatch(getCurrentUser()),
|
|
|
|
|
});
|
|
|
|
|
|
2020-12-17 07:03:59 +00:00
|
|
|
export default withRouter(connect(null, mapDispatchToProps)(AppHeader));
|