88 lines
2.8 KiB
JavaScript
88 lines
2.8 KiB
JavaScript
import { AlertOutlined } from "@ant-design/icons";
|
|
import * as Sentry from "@sentry/react";
|
|
import { Button, notification } from "antd";
|
|
//import "antd/dist/antd.css";
|
|
import "antd/dist/antd.less";
|
|
import Dinero from "dinero.js";
|
|
import i18n from "i18next";
|
|
import React from "react";
|
|
import ReactDOM from "react-dom";
|
|
import { Provider } from "react-redux";
|
|
import { BrowserRouter } from "react-router-dom";
|
|
import { PersistGate } from "redux-persist/integration/react";
|
|
import AppContainer from "./App/App.container";
|
|
import LoadingSpinner from "./components/loading-spinner/loading-spinner.component";
|
|
import "./index.css";
|
|
import { persistor, store } from "./redux/store";
|
|
import * as serviceWorkerRegistration from "./serviceWorkerRegistration";
|
|
import reportWebVitals from "./reportWebVitals";
|
|
import "./translations/i18n";
|
|
import "./utils/CleanAxios";
|
|
require("dotenv").config();
|
|
|
|
// Dinero.defaultCurrency = "CAD";
|
|
// Dinero.globalLocale = "en-CA";
|
|
Dinero.globalRoundingMode = "HALF_EVEN";
|
|
|
|
if (process.env.NODE_ENV !== "development") {
|
|
Sentry.init({
|
|
dsn:
|
|
"https://fd7e89369b6b4bdc9c6c4c9f22fa4ee4@o492140.ingest.sentry.io/5651027",
|
|
integrations: [
|
|
// new Integrations.BrowserTracing(),
|
|
// new Sentry.Integrations.Breadcrumbs({ console: true }),
|
|
],
|
|
environment: process.env.NODE_ENV,
|
|
// We recommend adjusting this value in production, or using tracesSampler
|
|
// for finer control
|
|
// tracesSampleRate: 0.5,
|
|
});
|
|
}
|
|
|
|
ReactDOM.render(
|
|
<Provider store={store}>
|
|
<BrowserRouter>
|
|
<PersistGate
|
|
loading={<LoadingSpinner message="Restoring your settings..." />}
|
|
persistor={persistor}
|
|
>
|
|
<AppContainer />
|
|
</PersistGate>
|
|
</BrowserRouter>
|
|
</Provider>,
|
|
document.getElementById("root")
|
|
);
|
|
|
|
const onServiceWorkerUpdate = (registration) => {
|
|
console.log("onServiceWorkerUpdate", registration);
|
|
const key = `open${Date.now()}`;
|
|
const btn = (
|
|
<Button
|
|
type="primary"
|
|
onClick={async () => {
|
|
if (registration && registration.waiting) {
|
|
await registration.unregister();
|
|
// Makes Workbox call skipWaiting()
|
|
registration.waiting.postMessage({ type: "SKIP_WAITING" });
|
|
// Once the service worker is unregistered, we can reload the page to let
|
|
// the browser download a fresh copy of our app (invalidating the cache)
|
|
window.location.reload();
|
|
}
|
|
}}
|
|
>
|
|
{i18n.t("general.actions.refresh")}
|
|
</Button>
|
|
);
|
|
notification.open({
|
|
icon: <AlertOutlined />,
|
|
message: i18n.t("general.messages.newversiontitle"),
|
|
description: i18n.t("general.messages.newversionmessage"),
|
|
duration: 0,
|
|
btn,
|
|
key,
|
|
});
|
|
};
|
|
|
|
serviceWorkerRegistration.register({ onUpdate: onServiceWorkerUpdate });
|
|
reportWebVitals(console.log);
|