2024-11-19 01:35:35 +00:00
|
|
|
import React, { useEffect, useState } from 'react';
|
2024-11-12 04:13:52 +00:00
|
|
|
import './App.css';
|
|
|
|
import { Client } from './client';
|
2024-11-19 01:35:35 +00:00
|
|
|
import { createBrowserRouter, RouterProvider } from 'react-router-dom';
|
2024-11-27 15:56:11 +00:00
|
|
|
import { DesignPage } from './views/Design/Design';
|
2024-11-20 03:48:36 +00:00
|
|
|
import { GmView } from './views/GmView/GmView';
|
2024-11-19 05:09:48 +00:00
|
|
|
import { WebsocketProvider } from './components/WebsocketProvider';
|
2024-11-19 19:53:42 +00:00
|
|
|
import { PlayerView } from './views/PlayerView/PlayerView';
|
2024-12-01 19:07:37 +00:00
|
|
|
import { Admin } from './views/Admin/Admin';
|
2024-11-25 13:28:22 +00:00
|
|
|
import Candela from './plugins/Candela';
|
2024-12-16 03:49:53 +00:00
|
|
|
import { Authentication } from './views/Authentication/Authentication';
|
2024-12-16 05:27:55 +00:00
|
|
|
import { StateProvider } from './components/StateProvider';
|
2024-11-12 04:13:52 +00:00
|
|
|
|
2024-12-01 19:07:37 +00:00
|
|
|
const TEST_CHARSHEET_UUID = "12df9c09-1f2f-4147-8eda-a97bd2a7a803";
|
|
|
|
|
2024-11-19 01:52:04 +00:00
|
|
|
interface AppProps {
|
|
|
|
client: Client;
|
|
|
|
}
|
|
|
|
|
2024-11-30 23:43:20 +00:00
|
|
|
const CandelaCharsheet = ({ client }: { client: Client }) => {
|
|
|
|
let [sheet, setSheet] = useState(undefined);
|
|
|
|
useEffect(
|
2024-12-01 19:07:37 +00:00
|
|
|
() => { client.charsheet(TEST_CHARSHEET_UUID).then((c) => setSheet(c)); },
|
2024-11-30 23:43:20 +00:00
|
|
|
[client, setSheet]
|
|
|
|
);
|
|
|
|
|
|
|
|
return sheet ? <Candela.CharsheetElement sheet={sheet} /> : <div> </div>
|
|
|
|
}
|
|
|
|
|
2024-11-19 01:52:04 +00:00
|
|
|
const App = ({ client }: AppProps) => {
|
2024-11-19 01:35:35 +00:00
|
|
|
console.log("rendering app");
|
|
|
|
const [websocketUrl, setWebsocketUrl] = useState<string | undefined>(undefined);
|
|
|
|
|
|
|
|
useEffect(() => {
|
2024-11-19 01:52:04 +00:00
|
|
|
client.registerWebsocket().then((url) => setWebsocketUrl(url))
|
2024-11-19 01:35:35 +00:00
|
|
|
}, [client]);
|
|
|
|
|
|
|
|
let router =
|
|
|
|
createBrowserRouter([
|
2024-12-16 03:49:53 +00:00
|
|
|
{
|
|
|
|
path: "/",
|
2024-12-16 05:27:55 +00:00
|
|
|
element: <StateProvider client={client}> <Authentication> <PlayerView client={client} /> </Authentication> </StateProvider>
|
|
|
|
|
2024-12-16 03:49:53 +00:00
|
|
|
},
|
2024-11-19 01:35:35 +00:00
|
|
|
{
|
|
|
|
path: "/gm",
|
2024-11-20 03:48:36 +00:00
|
|
|
element: websocketUrl ? <WebsocketProvider websocketUrl={websocketUrl}> <GmView client={client} /> </WebsocketProvider> : <div> </div>
|
2024-11-19 01:35:35 +00:00
|
|
|
},
|
2024-12-01 19:07:37 +00:00
|
|
|
{
|
|
|
|
path: "/admin",
|
|
|
|
element: <Admin client={client} />
|
|
|
|
},
|
2024-11-25 13:28:22 +00:00
|
|
|
{
|
|
|
|
path: "/candela",
|
2024-11-30 23:43:20 +00:00
|
|
|
element: <CandelaCharsheet client={client} />
|
2024-11-27 15:56:11 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
path: "/design",
|
|
|
|
element: <DesignPage />
|
2024-11-19 01:35:35 +00:00
|
|
|
}
|
|
|
|
]);
|
2024-11-12 04:13:52 +00:00
|
|
|
return (
|
|
|
|
<div className="App">
|
2024-11-19 01:35:35 +00:00
|
|
|
<RouterProvider router={router} />
|
2024-11-12 04:13:52 +00:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
export default App;
|