import '@babel/register';
import '@babel/polyfill';
import 'antd/dist/antd.min';
import 'antd/dist/antd.min.css';
import './global.scss';
import 'react-responsive-carousel/lib/styles/carousel.css';
import React from 'react';
import {Helmet} from "react-helmet";
import {render} from 'react-dom';
import {Provider} from 'mobx-react';
import {BrowserRouter, Route} from 'react-router-dom';
window.moment = require('moment');
// require(`imports-loader?this=>window,fix=>module.exports=0!snapsvg/dist/snap.svg.js`);
import AppState from '../common/stores/appstate';
import Routes from '../common/routes';
import RootComponent from "../common/pages/Root";
import { LocaleProvider } from 'antd';
import enUS from 'antd/lib/locale-provider/en_US';
import {getMobileOperatingSystem} from "../common/stores/firebase";
import cinnamonSugar from "cinnamon-sugar";
import ButterToast from "butter-toast";
import * as firebase from "firebase";
// var injectTapEventPlugin = require("react-tap-event-plugin");
// injectTapEventPlugin();
const initialState = window.__INITIAL_STATE__ || {};
const appstate = new AppState(Object.assign({
token: localStorage.getItem('id_token') || '',
userData: {
}
}, initialState));
// if (getMobileOperatingSystem() !== 'iOS') {
firebase.messaging().onMessage((payload) => {
console.log("Message received cok.", payload);
// alert(payload.notification.body);
if(payload.data.new_message){
appstate.message.pushNewMessage(payload.data);
}
if(payload.data.notification_type == 'notification'){
appstate.notification.unread_notif+=1
}
const toast = cinnamonSugar({
kind: 'crisp',
theme: 'info',
// picture: 'http://lorempixel.com/150/150/people',
title: {payload.notification.title}, // you can also add jsx code here!
// message: JSON.stringify(payload), // you can also add jsx code here!
message: payload.notification.body, // you can also add jsx code here!
toastTimeout: 4000,
icon: 'bell' // literally any font awesome 4.7 icon
// you may also add here regular butter-toast options, such as toastTimeout,
// name, sticky, etc..
});
ButterToast.raise(toast)
});
// }
render(
,
document.getElementById('root')
);