mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Add a basic React implementation of the map.
See client/README.md for instructions.
This commit is contained in:
35
client/src/App.tsx
Normal file
35
client/src/App.tsx
Normal file
@@ -0,0 +1,35 @@
|
||||
import { LatLng } from "leaflet";
|
||||
import "./App.css";
|
||||
|
||||
import { LiberationMap } from "./map/liberationmap/LiberationMap";
|
||||
import { ControlPoint } from "./game/controlpoint";
|
||||
import { useEffect } from "react";
|
||||
import { useAppDispatch } from "./app/hooks";
|
||||
import { setControlPoints } from "./game/theater/theaterSlice";
|
||||
import axios from "axios";
|
||||
|
||||
function App() {
|
||||
const mapCenter: LatLng = new LatLng(25.58, 54.9);
|
||||
|
||||
const dispatch = useAppDispatch();
|
||||
|
||||
useEffect(() => {
|
||||
axios
|
||||
.get("http://[::1]:5000/control-points")
|
||||
.catch((error) => console.log(`Error fetching control points: ${error}`))
|
||||
.then((response) => {
|
||||
if (response != null) {
|
||||
dispatch(setControlPoints(response.data as ControlPoint[]));
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
console.log(`mapCenter=${mapCenter}`);
|
||||
return (
|
||||
<div className="App">
|
||||
<LiberationMap mapCenter={mapCenter} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default App;
|
||||
Reference in New Issue
Block a user