From 0ad3d6f8d83436ad70d53075cbc92c5cea1d6eec Mon Sep 17 00:00:00 2001 From: Shane Garrity Date: Fri, 30 Jun 2023 18:41:19 -0400 Subject: [PATCH 1/4] feat(client): scaffold world table --- .../__snapshots__/webpack.config.test.js.snap | 2 + client/package.json | 2 + client/src/App/App.tsx | 123 +++++++++++++++--- client/webpack.config.js | 2 + common/config/rush/pnpm-lock.yaml | 51 ++++++++ common/config/rush/repo-state.json | 2 +- 6 files changed, 161 insertions(+), 21 deletions(-) diff --git a/client/__snapshots__/webpack.config.test.js.snap b/client/__snapshots__/webpack.config.test.js.snap index aae1fccf..010ceb60 100644 --- a/client/__snapshots__/webpack.config.test.js.snap +++ b/client/__snapshots__/webpack.config.test.js.snap @@ -3,6 +3,7 @@ exports[`webpackConfig development mode matches snapshot 1`] = ` { "devServer": { + "historyApiFallback": true, "setupMiddlewares": [Function], }, "devtool": "eval-source-map", @@ -123,6 +124,7 @@ exports[`webpackConfig development mode matches snapshot 1`] = ` exports[`webpackConfig production mode matches snapshot 1`] = ` { "devServer": { + "historyApiFallback": true, "setupMiddlewares": [Function], }, "devtool": "source-map", diff --git a/client/package.json b/client/package.json index 5886e352..c52da2a5 100644 --- a/client/package.json +++ b/client/package.json @@ -55,6 +55,7 @@ "@types/jest": "~29.5.2", "@types/node": "~16.18.3", "@types/react-dom": "~18.2.6", + "@types/react-router-dom": "~5.3.3", "@types/react": "~18.2.14", "@types/testing-library__jest-dom": "~5.14.5", "@typescript-eslint/eslint-plugin": "~5.60.0", @@ -95,6 +96,7 @@ "axios": "~1.4.0", "core-js": "~3.31.0", "react-dom": "~18.2.0", + "react-router-dom": "~6.14.0", "react": "~18.2.0" } } diff --git a/client/src/App/App.tsx b/client/src/App/App.tsx index 0e48f18a..7f689c9f 100644 --- a/client/src/App/App.tsx +++ b/client/src/App/App.tsx @@ -1,10 +1,10 @@ import React, { StrictMode } from 'react'; +import { createBrowserRouter, RouterProvider, Link, useParams, Outlet } from 'react-router-dom'; -import { Nav } from './Nav'; import { useGuildMemberData } from './use-guild-member-data'; import { Welcome } from './Welcome'; -type GuildUserData = ReturnType +type GuildUserData = ReturnType; const getWelcomeMessage = (guildUser: GuildUserData) => { const welcome = 'welcome to the trash compactor'; @@ -16,29 +16,112 @@ const getWelcomeMessage = (guildUser: GuildUserData) => { return `${welcome}, `; }; -const App = () => { +const Home = () => { const guildUser = useGuildMemberData(); + if (guildUser) { + return ( + <> + worlds + + + ); + } + + return (

loading...

); +}; + +const WorldsList = () => { + const fakeWorlds = [ + { + id: 1, + label: 'world one', + version: '1.16.5', + createdAt: '2023/06/28', + lastOnline: '2023/06/28', + createdBy: '@shaned.gg' + }, + { + id: 2, + label: 'world two', + version: '1.19.0', + createdAt: '2023/06/28', + lastOnline: '2023/06/28', + createdBy: '@shaned.gg' + }, + { + id: 3, + label: 'world three', + version: '1.20.1', + createdAt: '2023/06/28', + lastOnline: '2023/06/28', + createdBy: '@shaned.gg' + }, + ]; + + return ( + <> + back + + + + + + + + + + + + {fakeWorlds.map(({ id, label, version, createdAt, createdBy, lastOnline }) => { + return ( + + + + + + + + ); + })} + +
nameversioncreatedlast onlinecreated by
{label}{version}{new Date(createdAt).toLocaleDateString()}{new Date(lastOnline).toLocaleDateString()}{createdBy}
+ + + ); +}; + +const WorldDetail = () => { + const { worldId } = useParams(); + return ( + <> +

{worldId}

+ + ); +}; + +const router = createBrowserRouter([ + { + path: '/', + element: , + }, + { + path: '/worlds', + element: , + children: [ + { + path: ':worldId', + element: + }, + ], + }, +]); + +const App = () => { return (

trshcmpctr

- {guildUser ? - : -

loading ...

- } -