Skip to content

Commit

Permalink
Add router to web
Browse files Browse the repository at this point in the history
  • Loading branch information
aswallace committed May 14, 2024
1 parent 119c6df commit edcf712
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
},
"dependencies": {
"@duckdb/duckdb-wasm": "1.28.1-dev106.0",
"react-router-dom": "^6.23.1",
"regenerator-runtime": "0.13.x",
"semver": "7.3.x"
}
Expand Down
15 changes: 14 additions & 1 deletion packages/web/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { memoize } from "lodash";
import * as React from "react";
import { render } from "react-dom";
import { Provider } from "react-redux";
import { createBrowserRouter, RouterProvider } from "react-router-dom";

import NotificationServiceWeb from "./services/NotificationServiceWeb";
import PersistentConfigServiceWeb from "./services/PersistentConfigServiceWeb";
Expand All @@ -14,6 +15,7 @@ import FmsFileExplorer from "../../core/App";
import { createReduxStore } from "../../core/state";
import FileViewerServiceWeb from "./services/FileViewerServiceWeb";
import FileDownloadServiceWeb from "./services/FileDownloadServiceWeb";
import Root from "./routes/Root";

const APP_ID = "fms-file-explorer-web";

Expand Down Expand Up @@ -54,9 +56,20 @@ const collectPlatformDependentServices = memoize(() => ({
persistentConfigService,
}));

const router = createBrowserRouter([
{
path: "/",
element: <Root />, // Splash page placeholder
},
{
path: "app",
element: <FmsFileExplorer platformDependentServices={collectPlatformDependentServices()} />,
},
]);

render(
<Provider store={createReduxStore()}>
<FmsFileExplorer platformDependentServices={collectPlatformDependentServices()} />
<RouterProvider router={router} />
</Provider>,
document.getElementById(APP_ID)
);
10 changes: 10 additions & 0 deletions packages/web/src/routes/Root/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import * as React from "react";

// Placeholder for the splash page
export default function Root() {
return (
<div>
<h1> Coming soon </h1>
</div>
);
}
1 change: 1 addition & 0 deletions packages/web/webpack/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ module.exports = ({ analyze, production } = {}) => ({
devServer: {
host: devServer.host,
port: devServer.port,
historyApiFallback: true,
},
entry: {
app: "./src/index.tsx",
Expand Down

0 comments on commit edcf712

Please sign in to comment.