2021-02-22 02:39:04 +00:00
|
|
|
import { Component } from "inferno";
|
2021-09-18 14:27:49 +00:00
|
|
|
import { Provider } from "inferno-i18next-dess";
|
2021-07-17 20:42:55 +00:00
|
|
|
import { Route, Switch } from "inferno-router";
|
|
|
|
import { i18n } from "../../i18next";
|
|
|
|
import { routes } from "../../routes";
|
2023-05-14 15:08:06 +00:00
|
|
|
import { isAuthPath, setIsoData } from "../../utils";
|
|
|
|
import AuthGuard from "../common/auth-guard";
|
|
|
|
import ErrorGuard from "../common/error-guard";
|
|
|
|
import { ErrorPage } from "./error-page";
|
2021-02-22 02:39:04 +00:00
|
|
|
import { Footer } from "./footer";
|
2021-07-17 20:42:55 +00:00
|
|
|
import { Navbar } from "./navbar";
|
2021-02-22 02:39:04 +00:00
|
|
|
import "./styles.scss";
|
2021-07-17 20:42:55 +00:00
|
|
|
import { Theme } from "./theme";
|
2020-09-06 16:15:25 +00:00
|
|
|
|
2022-06-21 21:42:29 +00:00
|
|
|
export class App extends Component<any, any> {
|
|
|
|
private isoData = setIsoData(this.context);
|
2020-09-06 16:15:25 +00:00
|
|
|
constructor(props: any, context: any) {
|
|
|
|
super(props, context);
|
|
|
|
}
|
|
|
|
render() {
|
2023-05-14 15:08:06 +00:00
|
|
|
const siteRes = this.isoData.site_res;
|
|
|
|
const siteView = siteRes.site_view;
|
2022-06-21 21:42:29 +00:00
|
|
|
|
2020-09-06 16:15:25 +00:00
|
|
|
return (
|
|
|
|
<>
|
2020-09-07 15:32:07 +00:00
|
|
|
<Provider i18next={i18n}>
|
2022-12-22 21:54:52 +00:00
|
|
|
<div id="app">
|
2022-11-09 19:53:07 +00:00
|
|
|
<Theme defaultTheme={siteView.local_site.default_theme} />
|
2022-06-21 21:42:29 +00:00
|
|
|
<Navbar siteRes={siteRes} />
|
2022-09-22 15:03:35 +00:00
|
|
|
<div className="mt-4 p-0 fl-1">
|
2020-09-07 15:32:07 +00:00
|
|
|
<Switch>
|
2023-05-14 15:08:06 +00:00
|
|
|
{routes.map(({ path, component: RouteComponent }) => (
|
|
|
|
<Route
|
|
|
|
key={path}
|
|
|
|
path={path}
|
|
|
|
exact
|
|
|
|
component={routeProps => (
|
|
|
|
<ErrorGuard>
|
|
|
|
{RouteComponent &&
|
|
|
|
(isAuthPath(path ?? "") ? (
|
|
|
|
<AuthGuard>
|
|
|
|
<RouteComponent {...routeProps} />
|
|
|
|
</AuthGuard>
|
|
|
|
) : (
|
|
|
|
<RouteComponent {...routeProps} />
|
|
|
|
))}
|
|
|
|
</ErrorGuard>
|
|
|
|
)}
|
|
|
|
/>
|
2023-04-15 14:47:10 +00:00
|
|
|
))}
|
2023-05-14 15:08:06 +00:00
|
|
|
<Route component={ErrorPage} />
|
2020-09-07 15:32:07 +00:00
|
|
|
</Switch>
|
|
|
|
</div>
|
2022-06-21 21:42:29 +00:00
|
|
|
<Footer site={siteRes} />
|
2020-09-06 16:15:25 +00:00
|
|
|
</div>
|
2020-09-07 15:32:07 +00:00
|
|
|
</Provider>
|
2020-09-06 16:15:25 +00:00
|
|
|
</>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|