2019-11-19 07:30:42 +03:00
|
|
|
import React from 'react';
|
|
|
|
import ReactDOM from 'react-dom';
|
2019-11-20 08:48:27 +03:00
|
|
|
import 'url-search-params-polyfill';
|
2019-11-19 07:30:42 +03:00
|
|
|
|
|
|
|
import Router from './router'
|
2020-07-15 12:14:53 +03:00
|
|
|
import ErrorBoundary from './error-boundary'
|
2021-03-02 12:15:43 +03:00
|
|
|
import * as api from './api'
|
2019-11-19 07:30:42 +03:00
|
|
|
|
|
|
|
const container = document.getElementById('stats-react-container')
|
|
|
|
|
|
|
|
if (container) {
|
|
|
|
const site = {
|
|
|
|
domain: container.dataset.domain,
|
|
|
|
offset: container.dataset.offset,
|
2020-12-16 12:52:47 +03:00
|
|
|
hasGoals: container.dataset.hasGoals === 'true',
|
2021-03-10 15:41:17 +03:00
|
|
|
insertedAt: container.dataset.insertedAt,
|
2021-03-16 11:40:25 +03:00
|
|
|
embedded: container.dataset.embedded,
|
2021-04-12 12:21:07 +03:00
|
|
|
background: container.dataset.background,
|
2021-12-31 13:16:25 +03:00
|
|
|
selfhosted: container.dataset.selfhosted === 'true'
|
2019-11-19 07:30:42 +03:00
|
|
|
}
|
|
|
|
|
2020-08-13 13:45:18 +03:00
|
|
|
const loggedIn = container.dataset.loggedIn === 'true'
|
2021-06-16 15:00:07 +03:00
|
|
|
const currentUserRole = container.dataset.currentUserRole
|
2021-03-02 12:15:43 +03:00
|
|
|
const sharedLinkAuth = container.dataset.sharedLinkAuth
|
|
|
|
if (sharedLinkAuth) {
|
|
|
|
api.setSharedLinkAuth(sharedLinkAuth)
|
|
|
|
}
|
2020-08-13 13:45:18 +03:00
|
|
|
|
2020-07-15 12:14:53 +03:00
|
|
|
const app = (
|
|
|
|
<ErrorBoundary>
|
2021-06-16 15:00:07 +03:00
|
|
|
<Router site={site} loggedIn={loggedIn} currentUserRole={currentUserRole} />
|
2020-07-15 12:14:53 +03:00
|
|
|
</ErrorBoundary>
|
|
|
|
)
|
|
|
|
|
|
|
|
ReactDOM.render(app, container);
|
2019-11-19 07:30:42 +03:00
|
|
|
}
|