2020-08-03 14:18:48 +00:00
|
|
|
import React from "react";
|
2020-12-30 09:06:24 +00:00
|
|
|
import ReactDOM from "react-dom";
|
2020-08-03 14:18:48 +00:00
|
|
|
import PageHeader from "pages/common/PageHeader";
|
|
|
|
|
import LoginHeader from "pages/common/LoginHeader";
|
|
|
|
|
import { Route, Switch } from "react-router";
|
|
|
|
|
import {
|
2022-03-25 10:43:26 +00:00
|
|
|
VIEWER_PATH,
|
2020-08-03 14:18:48 +00:00
|
|
|
BASE_URL,
|
2022-03-25 10:43:26 +00:00
|
|
|
BUILDER_PATH,
|
2021-09-12 16:36:43 +00:00
|
|
|
SETUP,
|
2021-10-21 05:36:17 +00:00
|
|
|
SIGNUP_SUCCESS_URL,
|
2020-08-03 14:18:48 +00:00
|
|
|
USER_AUTH_URL,
|
2022-03-25 10:43:26 +00:00
|
|
|
BUILDER_PATH_DEPRECATED,
|
|
|
|
|
VIEWER_PATH_DEPRECATED,
|
2022-03-26 05:10:35 +00:00
|
|
|
ADMIN_SETTINGS_CATEGORY_PATH,
|
2022-07-11 04:06:29 +00:00
|
|
|
VIEWER_CUSTOM_PATH,
|
|
|
|
|
BUILDER_CUSTOM_PATH,
|
2020-08-03 14:18:48 +00:00
|
|
|
} from "constants/routes";
|
|
|
|
|
import { withRouter, RouteComponentProps } from "react-router";
|
2022-05-04 09:45:57 +00:00
|
|
|
import AppViewerHeader from "pages/AppViewer/AppViewerHeader";
|
2020-08-07 06:56:47 +00:00
|
|
|
import AppEditorHeader from "pages/Editor/EditorHeader";
|
2020-08-03 14:18:48 +00:00
|
|
|
|
2021-08-05 06:10:19 +00:00
|
|
|
type Props = RouteComponentProps;
|
2020-08-03 14:18:48 +00:00
|
|
|
|
2020-12-30 09:06:24 +00:00
|
|
|
const headerRoot = document.getElementById("header-root");
|
|
|
|
|
|
2020-08-03 14:18:48 +00:00
|
|
|
class AppHeader extends React.Component<Props, any> {
|
2020-12-30 09:06:24 +00:00
|
|
|
private container = document.createElement("div");
|
|
|
|
|
|
2020-08-03 14:18:48 +00:00
|
|
|
componentDidMount() {
|
2020-12-30 09:06:24 +00:00
|
|
|
headerRoot?.appendChild(this.container);
|
2020-08-03 14:18:48 +00:00
|
|
|
}
|
2020-12-30 09:06:24 +00:00
|
|
|
componentWillUnmount() {
|
|
|
|
|
headerRoot?.removeChild(this.container);
|
|
|
|
|
}
|
|
|
|
|
get header() {
|
2020-08-03 14:18:48 +00:00
|
|
|
return (
|
2021-04-28 10:28:39 +00:00
|
|
|
<Switch>
|
2022-03-26 05:10:35 +00:00
|
|
|
<Route component={PageHeader} path={ADMIN_SETTINGS_CATEGORY_PATH} />
|
|
|
|
|
<Route component={LoginHeader} path={USER_AUTH_URL} />
|
|
|
|
|
<Route path={SETUP} />
|
|
|
|
|
<Route path={SIGNUP_SUCCESS_URL} />
|
2022-03-25 10:43:26 +00:00
|
|
|
<Route component={AppEditorHeader} path={BUILDER_PATH_DEPRECATED} />
|
2022-04-11 05:14:50 +00:00
|
|
|
<Route component={AppViewerHeader} path={VIEWER_PATH_DEPRECATED} />
|
2022-07-11 04:06:29 +00:00
|
|
|
<Route component={AppEditorHeader} path={BUILDER_PATH} />
|
|
|
|
|
<Route component={AppEditorHeader} path={BUILDER_CUSTOM_PATH} />
|
|
|
|
|
<Route component={AppViewerHeader} path={VIEWER_PATH} />
|
|
|
|
|
<Route component={AppViewerHeader} path={VIEWER_CUSTOM_PATH} />
|
2021-04-28 10:28:39 +00:00
|
|
|
<Route component={PageHeader} path={BASE_URL} />
|
|
|
|
|
</Switch>
|
2020-08-03 14:18:48 +00:00
|
|
|
);
|
|
|
|
|
}
|
2020-12-30 09:06:24 +00:00
|
|
|
render() {
|
|
|
|
|
return ReactDOM.createPortal(this.header, this.container);
|
|
|
|
|
}
|
2020-08-03 14:18:48 +00:00
|
|
|
}
|
|
|
|
|
|
2021-08-05 06:10:19 +00:00
|
|
|
export default withRouter(AppHeader);
|