add world parameter to router

This commit is contained in:
Alexander Bentkamp
2022-12-07 18:24:26 +01:00
parent 0eacf1339b
commit 894d2708d8
4 changed files with 13 additions and 10 deletions
+3 -2
View File
@@ -31,6 +31,7 @@ function Level() {
const params = useParams();
const levelId = parseInt(params.levelId)
const worldId = params.worldId
const [tacticDocs, setTacticDocs] = useState([])
const [lemmaDocs, setLemmaDocs] = useState([])
@@ -105,7 +106,7 @@ function Level() {
return () => { editor.dispose() }
}, [])
const uri = `file:///level${levelId}`
const uri = `file:///${worldId}/${levelId}`
// The next function will be called when the level changes
useEffect(() => {
@@ -122,7 +123,7 @@ function Level() {
new AbbreviationRewriter(new AbbreviationProvider(), model, editor)
leanClient.sendRequest("loadLevel", {world: "TestWorld", level: levelId}).then((res) => {
leanClient.sendRequest("loadLevel", {world: worldId, level: levelId}).then((res) => {
// setLevelTitle("Level " + res["index"] + ": " + res["title"])
// setIndex(parseInt(res["index"]))
setTacticDocs(res["tactics"])
+1 -1
View File
@@ -91,7 +91,7 @@ function Welcome() {
</Typography>
</Box>
<Box textAlign='center' sx={{ m: 5 }}>
<Button component={RouterLink} to="/level/1" variant="contained">Start rescue mission</Button>
<Button component={RouterLink} to="/world/TestWorld/level/1" variant="contained">Start rescue mission</Button>
</Box>
<div ref={worldsRef} style={{"width": "100%","height": "50em"}} />
</div>
+1 -1
View File
@@ -29,7 +29,7 @@ const router = createHashRouter([
element: <Welcome />,
},
{
path: "/level/:levelId",
path: "/world/:worldId/level/:levelId",
element: <Level />,
},
],