import React, { Component } from 'react';

import './App.css';
import '@trendmicro/react-sidenav/dist/react-sidenav.css';
import logo from './logo.svg';
import {Bat} from './components/bat';
import {Form} from './components/form';
import {Soot} from './components/footer';
import {Paginator} from './components/pagination';
import { Row, Col,Pagination } from 'react-materialize';
import NavbarModule from './Modules/NavbarModule';
import Product from './Modules/Product';
import ProductList from './Modules/ProductView';
import ProductService from './Services/ProductService';
import FileUploader from './Modules/FileUploader';
import FormModule from './Modules/Form';
import Modularity from 'modularity-front';
import CardModule from './Modules/Card';
import CarouselPanelModule from './Modules/CarouselPanel';
import CarouselModule from './Modules/Carousel';
import TableModule from './Modules/Table';
import PaginationModule from './Modules/Pagination';
import FooterModule from './Modules/Footer';
import SideNavModule from './Modules/SideNav';
import HorizontalContainer from './Modules/HorizontalContainer';
import ViewModule from './Modules/View';
import ListModule from './HigherModules/ListModule';
import TableData from './HigherModules/TableData';
import UserService from './Services/UserService';
import CrudService from './Services/CrudService';
import LoadedModulesService from './Services/LoadedModulesService';
import CrudListPackage from './Packages/CrudListPackage';
import UserPackage from './Packages/UserPackage';
import VerticalNavbarPackage from './Packages/VerticalNavbarPackage';
import MiniCartModule from './Modules/mini-cart';
import Vertical from './Modules/VerticalNavbar';
import ParallaxModule from './Modules/parallax';
import ModalModule from './Modules/Modal';
import SearchBarModule from './Modules/searchbar.js';
import CustomTable from './Modules/CustomTable.js';
import FullScreenContainer from './Modules/FullScreenContainer.js';
import PresentationModule from './Packages/Tonersales/Presentation1';
import ClientForm from './Modules/ClientForm';
import SearchBarPackage from './Packages/Tonersales/SearchBarPackage';
import CartPackage from './Packages/Tonersales/CartPage';
import FiltersPackage from './Packages/FiltersPackage';
import ChipModule from './Modules/Chip';
import HorizontalCard from './Modules/HorizontalCard';
import Import from './Modules/Import';
import ProductPresent from './Modules/Product/Present';
import GoogleMapModule from './Modules/GoogleMap';

//Tonersales Packages
import ProductPresentPackage from './Packages/Tonersales/ProductPresentPackage';
import PrinterPresentPackage from './Packages/Tonersales/PrinterPresentPackage';
import UserAccount from './Packages/Tonersales/UserAccount';
import OrderPackage from './Packages/Tonersales/OrderPackage';
import ContactPackage from './Packages/Tonersales/ContactPackage';
//Filter Modules
import FilterModule from './Modules/FilterModule';
import SiteScript from './Environments/Frontend.js';
import ViewOrder from './HigherModules/ViewOrder';
import TextEditor from './Modules/TextEditor';



let Core = Modularity.Systems.getCore();
Modularity.Systems.addModule(ProductList);
Modularity.Systems.addModule(Product);
Modularity.Systems.addService(ProductService);
Modularity.Systems.addService(LoadedModulesService);
Modularity.Systems.addService(CrudService);
Modularity.Systems.addService(UserService);
Modularity.Systems.addModule(UserPackage);
Modularity.Systems.addModule(FileUploader);
Modularity.Systems.addModule(NavbarModule);
Modularity.Systems.addModule(FormModule);
Modularity.Systems.addModule(CardModule);
Modularity.Systems.addModule(CarouselPanelModule);
Modularity.Systems.addModule(CarouselModule);
Modularity.Systems.addModule(TableModule);
Modularity.Systems.addModule(PaginationModule);
Modularity.Systems.addModule(FooterModule);
Modularity.Systems.addModule(SideNavModule);
Modularity.Systems.addModule(ListModule);
Modularity.Systems.addModule(ViewModule);
Modularity.Systems.addModule(Vertical);
Modularity.Systems.addModule(VerticalNavbarPackage);
Modularity.Systems.addModule(CrudListPackage);
Modularity.Systems.addModule(ParallaxModule);
Modularity.Systems.addModule(ModalModule);
Modularity.Systems.addModule(SearchBarModule);
Modularity.Systems.addModule(FilterModule);
Modularity.Systems.addModule(HorizontalContainer);
Modularity.Systems.addModule(HorizontalCard)
Modularity.Systems.addModule(FullScreenContainer);
Modularity.Systems.addModule(MiniCartModule);
Modularity.Systems.addModule(PresentationModule);
Modularity.Systems.addModule(SearchBarPackage);
Modularity.Systems.addModule(FiltersPackage);
Modularity.Systems.addModule(Import);
Modularity.Systems.addModule(ChipModule);
Modularity.Systems.addModule(CartPackage);
Modularity.Systems.addModule(CustomTable);
Modularity.Systems.addModule(ClientForm);
Modularity.Systems.addModule(ProductPresent);
Modularity.Systems.addModule(ProductPresentPackage);
Modularity.Systems.addModule(PrinterPresentPackage);
Modularity.Systems.addModule(UserAccount);
Modularity.Systems.addModule(TableData);
Modularity.Systems.addModule(OrderPackage);
Modularity.Systems.addModule(ViewOrder);
Modularity.Systems.addModule(TextEditor);
Modularity.Systems.addModule(ContactPackage);
Modularity.Systems.addModule(GoogleMapModule);

class App extends Component {

  constructor(props) {
  	super(props);
  	this.state = {
  		SiteMode: localStorage.getItem("SolidLoader") == "true" ,
  		script: {}
  	}

    if(process.env.NODE_ENV !== 'production')
  	window.addEventListener('keypress', (e) => {
  		let keynum;
  		if(window.event) { // IE                    
	      keynum = e.keyCode;
	    } else if(e.which){ // Netscape/Firefox/Opera                   
	      keynum = e.which;
	    }
	    if(keynum === 61) {
        localStorage.setItem("AdminMode", !this.state.SiteMode ? "" : "admin");
        localStorage.setItem("AdminVision", !this.state.SiteMode ? "" : "admin");
        localStorage.setItem("SolidLoader", !this.state.SiteMode);
  			this.setState({SiteMode: !this.state.SiteMode});
  		}
  	})
  }

  render() {
    
    return (
      <div>
        <div className="" key={'App'}>
        {process.env.NODE_ENV !== 'production' ? 
          (this.state.SiteMode 
          	? <Modularity.ModuleLoader.SolidLoader script={SiteScript} /> 
          	: <Modularity.ModuleLoader.MemoryLoader />
          ) 
          : <Modularity.ModuleLoader.SolidLoader script={SiteScript} />  
        }
        </div>
      </div>

    );
  }
}

export default App;
