import ReactDOM from 'react-dom'
import React from 'react'
const { ipcRenderer } = require('electron')
import { App } from './App';
import { AnniversaryProvider } from './contex/configureContext/ConfigureProvider';
import { DataProvider } from './contex/dataContext/DataProvider';

let start: boolean = false

ipcRenderer.on('preload', (_event: any, data: VixonicData) => {
  render(data)
})

ipcRenderer.on('start', (_event: any, data: VixonicData) => {
  start = true
  // initialize(data)
  render(data)
})

ipcRenderer.on('update', (_event: any, data: VixonicData) => {
  render(data)
})

ipcRenderer.on('finish', (_event: any) => {
  console.log('finish')
})


function render(data: VixonicData) {
  ReactDOM.render(
    <AnniversaryProvider>
      <DataProvider>
        <App data={data} start={start} />
      </DataProvider>
    </AnniversaryProvider>, document.getElementById('root'))
  // ReactDOM.render(React.createElement(App,{data, start}), document.getElementById('root'))
}






