From 58ebd3bc0f00c532e97e9a5571471ffab87934ba Mon Sep 17 00:00:00 2001
From: AL-LCL <alvin@alvinhavel.com>
Date: Fri, 19 May 2023 10:39:49 +0200
Subject: GOD-VIEW

---
 server/web/src/index.tsx | 56 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 56 insertions(+)
 create mode 100644 server/web/src/index.tsx

(limited to 'server/web/src/index.tsx')

diff --git a/server/web/src/index.tsx b/server/web/src/index.tsx
new file mode 100644
index 0000000..810a349
--- /dev/null
+++ b/server/web/src/index.tsx
@@ -0,0 +1,56 @@
+import { transitions, positions, Provider as AlertProvider } from 'react-alert';
+import { GlobalStyle } from './design/GlobalStyle';
+import { AlertTemplate } from './components/Alert';
+import { Provider } from 'react-redux';
+import { store } from './redux/store';
+import ReactDOM from 'react-dom';
+import React from 'react';
+import App from './App';
+
+const alertOptions = {
+    // CONSTANT : alert parameters
+    position: positions.TOP_LEFT,
+    transition: transitions.FADE,
+    timeout: 3000
+};
+
+declare global {
+    interface Window {
+        showAlert: any;
+        eel: any;
+    }
+}
+
+window.eel.set_host(`ws://${window.location.host}`);
+window.oncontextmenu = () => false;
+
+window.addEventListener('load', () => {
+    window.addEventListener('error', (event: any) =>
+        console.log(`Window Error: ${event.message}`));
+
+    window.eel._websocket.addEventListener('open', () =>
+        console.log('Host Websocket Connected!'));
+
+    window.eel._websocket.addEventListener('error', (event: any) => {
+        console.log(`Websocket Error: ${event.message}`);
+        window.alert('Host Connection Error. Closing!');
+        window.close();
+    });
+
+    window.eel._websocket.addEventListener('close', () => {
+        window.alert('Host Disconnected. Closing!');
+        window.close();
+    });
+});
+
+ReactDOM.render(
+    <React.StrictMode>
+        <Provider store={store}>
+            <GlobalStyle />
+            <AlertProvider template={AlertTemplate} {...alertOptions}>
+                <App />
+            </AlertProvider>
+        </Provider>
+    </React.StrictMode>,
+    document.getElementById('root')
+);
-- 
cgit v1.2.3

