import React, {useEffect} from 'react';

import { BrowserRouter } from 'react-router-dom';
import { Dashboard } from './dashboard';

import {ToastContainer} from "react-toastify";
import 'react-toastify/dist/ReactToastify.css';

import { Provider } from 'react-redux';
import store from './backend/redux/store.js'; // Import your store


import './index.css'
import {displayMessage} from "./backend/notifications/notifications.js";
import {MessageType} from "./backend/notifications/message";

const App = () => {
    useEffect(() => {
        document.title = 'Enterfront';
    }, []);

    useEffect(() => {
        const msg = localStorage.getItem('message');

        if (!msg) return;

        displayMessage(msg, MessageType.SUCCESS);
        localStorage.removeItem('message');
    }, []);

  return(
      <Provider store={store}>
          <BrowserRouter>
              <Dashboard />
          </BrowserRouter>

          <ToastContainer/>
      </Provider>

  )
}

export default App;
