Skip to content

Commit 568b4fb

Browse files
fix: redirection issue
1 parent 47bf3d9 commit 568b4fb

File tree

1 file changed

+6
-5
lines changed
  • examples/playground/src/components/map

1 file changed

+6
-5
lines changed

examples/playground/src/components/map/index.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,8 @@ import { Scope } from "@navigraph/app";
1111
import "leaflet/dist/leaflet.css"
1212
import { mapFaaState, mapSourceState, mapTacState, mapThemeState } from "../../state/mapStyle";
1313
import { chartOverlayOpacityState, chartOverlayState } from "../../state/chartOverlay";
14-
import { calculateChartBounds } from "@navigraph/charts";
14+
import { calculateChartBounds, getChartsAPI } from "@navigraph/charts";
1515
import { useQuery } from "@tanstack/react-query";
16-
import { protectedPage } from "../protectedPage";
1716
import { TbCircleX } from "react-icons/tb";
1817
import Button from "../Button";
1918
import AmdbManager from "./amdb";
@@ -29,7 +28,7 @@ export function createPreset(source: NavigraphRasterSource, theme: NavigraphThem
2928
return { source, theme, type: faa ? 'FAA' : 'Navigraph' }
3029
}
3130

32-
const ChartOverlay = protectedPage(({ charts }) => {
31+
const ChartOverlay = ({ charts }: { charts: ReturnType<typeof getChartsAPI> }) => {
3332
const theme = useRecoilValue(mapThemeState);
3433

3534
const opacity = useRecoilValue(chartOverlayOpacityState);
@@ -72,7 +71,7 @@ const ChartOverlay = protectedPage(({ charts }) => {
7271
opacity={opacity}
7372
/>
7473
)
75-
}, [Scope.CHARTS]);
74+
};
7675

7776
function NavigraphTiles({ auth }: { auth: NavigraphAuth }) {
7877
const map = useMap();
@@ -131,6 +130,8 @@ export default function MapPane() {
131130
const app = useRecoilValue(appState);
132131
const user = useRecoilValue(userState);
133132

133+
const charts = user?.scope.includes(Scope.CHARTS) ? getChartsAPI() : undefined;
134+
134135
return (
135136
<div className='w-full'>
136137
<MapContainer center={[51.505, -0.09]} zoom={13} className='h-screen' zoomControl={false} ref={mapRef} whenReady={() => {
@@ -145,7 +146,7 @@ export default function MapPane() {
145146
url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
146147
/>
147148
)}
148-
<ChartOverlay />
149+
{charts && <ChartOverlay charts={charts} />}
149150
<AmdbManager />
150151
</MapContainer>
151152
</div>

0 commit comments

Comments
 (0)