Pass system and region to system mapping
Pass system and region to the system mapping function to avoid redundant API calls.
This commit is contained in:
@@ -135,7 +135,8 @@ export const RegionMap: React.FC<RegionMapProps> = ({
|
|||||||
}, [systems, focusSystem, isCompact]);
|
}, [systems, focusSystem, isCompact]);
|
||||||
|
|
||||||
const handleSystemClick = (systemName: string) => {
|
const handleSystemClick = (systemName: string) => {
|
||||||
navigate(`/systems/${systemName}`);
|
// Pass the region name when navigating to a system
|
||||||
|
navigate(`/systems/${systemName}?region=${regionName}`);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleMouseDown = useCallback((e: React.MouseEvent) => {
|
const handleMouseDown = useCallback((e: React.MouseEvent) => {
|
||||||
|
|||||||
@@ -1,19 +1,13 @@
|
|||||||
|
|
||||||
import { useParams, useNavigate } from "react-router-dom";
|
import { useParams, useNavigate, useSearchParams } from "react-router-dom";
|
||||||
import { useQuery } from "@tanstack/react-query";
|
|
||||||
import SystemTracker from "@/components/SystemTracker";
|
import SystemTracker from "@/components/SystemTracker";
|
||||||
import { RegionMap } from "@/components/RegionMap";
|
import { RegionMap } from "@/components/RegionMap";
|
||||||
import { findSystemRegion } from "@/utils/systemRegionMapping";
|
|
||||||
|
|
||||||
const SystemView = () => {
|
const SystemView = () => {
|
||||||
const { system } = useParams();
|
const { system } = useParams();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
const [searchParams] = useSearchParams();
|
||||||
const { data: regionName } = useQuery({
|
const regionName = searchParams.get('region');
|
||||||
queryKey: ['system-region', system],
|
|
||||||
queryFn: () => findSystemRegion(system!),
|
|
||||||
enabled: !!system,
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!system) {
|
if (!system) {
|
||||||
navigate("/");
|
navigate("/");
|
||||||
@@ -53,8 +47,8 @@ const SystemView = () => {
|
|||||||
) : (
|
) : (
|
||||||
<div className="bg-black/20 backdrop-blur-sm border border-purple-500/30 rounded-lg p-4 h-96 flex items-center justify-center">
|
<div className="bg-black/20 backdrop-blur-sm border border-purple-500/30 rounded-lg p-4 h-96 flex items-center justify-center">
|
||||||
<div className="text-center">
|
<div className="text-center">
|
||||||
<div className="text-white text-sm">Loading region data...</div>
|
<div className="text-white text-sm">No region information</div>
|
||||||
<div className="text-purple-200 text-xs mt-1">Finding system location</div>
|
<div className="text-purple-200 text-xs mt-1">Navigate from a region map to see regional overview</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|||||||
Reference in New Issue
Block a user