Remove references to localhost (we are now a website!)
This commit is contained in:
@@ -6,7 +6,6 @@ import { Button } from "@/components/ui/button";
|
|||||||
import { RefreshCw, AlertCircle, Radar } from "lucide-react";
|
import { RefreshCw, AlertCircle, Radar } from "lucide-react";
|
||||||
import SignatureListItem from "./SignatureListItem";
|
import SignatureListItem from "./SignatureListItem";
|
||||||
import { toast } from "@/hooks/use-toast";
|
import { toast } from "@/hooks/use-toast";
|
||||||
import { useNavigate } from "react-router-dom";
|
|
||||||
|
|
||||||
interface SignatureItem {
|
interface SignatureItem {
|
||||||
collectionId: string;
|
collectionId: string;
|
||||||
@@ -27,28 +26,10 @@ interface ApiResponse {
|
|||||||
}
|
}
|
||||||
|
|
||||||
interface SystemTrackerProps {
|
interface SystemTrackerProps {
|
||||||
initialSystem?: string;
|
system: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const SystemTracker = ({ initialSystem }: SystemTrackerProps) => {
|
const SystemTracker = ({ system }: SystemTrackerProps) => {
|
||||||
const [currentSystem, setCurrentSystem] = useState<string>(initialSystem || "");
|
|
||||||
const navigate = useNavigate();
|
|
||||||
|
|
||||||
// Query to get current system from localhost:7000 (always enabled to track system changes)
|
|
||||||
const { data: systemData, refetch: refetchSystem, isLoading: systemLoading } = useQuery({
|
|
||||||
queryKey: ['currentSystem'],
|
|
||||||
queryFn: async () => {
|
|
||||||
const response = await fetch('http://localhost:7000');
|
|
||||||
if (!response.ok) {
|
|
||||||
throw new Error('Failed to fetch current system');
|
|
||||||
}
|
|
||||||
const text = await response.text();
|
|
||||||
return text.trim();
|
|
||||||
},
|
|
||||||
refetchInterval: 1000, // Always refetch to track system changes
|
|
||||||
retry: 3,
|
|
||||||
});
|
|
||||||
|
|
||||||
// Query to get signatures for the current system
|
// Query to get signatures for the current system
|
||||||
const {
|
const {
|
||||||
data: signaturesData,
|
data: signaturesData,
|
||||||
@@ -56,14 +37,14 @@ const SystemTracker = ({ initialSystem }: SystemTrackerProps) => {
|
|||||||
isLoading: signaturesLoading,
|
isLoading: signaturesLoading,
|
||||||
error: signaturesError
|
error: signaturesError
|
||||||
} = useQuery({
|
} = useQuery({
|
||||||
queryKey: ['signatures', currentSystem],
|
queryKey: ['signatures', system],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
if (!currentSystem) return null;
|
if (!system) return null;
|
||||||
|
|
||||||
const encodedSystem = encodeURIComponent(currentSystem);
|
const encodedSystem = encodeURIComponent(system);
|
||||||
const url = `https://evebase.site.quack-lab.dev/api/collections/sigview/records?filter=(system%3D'${encodedSystem}')`;
|
const url = `https://evebase.site.quack-lab.dev/api/collections/sigview/records?filter=(system%3D'${encodedSystem}')`;
|
||||||
|
|
||||||
console.log('Fetching signatures for system:', currentSystem);
|
console.log('Fetching signatures for system:', system);
|
||||||
console.log('API URL:', url);
|
console.log('API URL:', url);
|
||||||
|
|
||||||
const response = await fetch(url);
|
const response = await fetch(url);
|
||||||
@@ -73,41 +54,26 @@ const SystemTracker = ({ initialSystem }: SystemTrackerProps) => {
|
|||||||
const data: ApiResponse = await response.json();
|
const data: ApiResponse = await response.json();
|
||||||
return data;
|
return data;
|
||||||
},
|
},
|
||||||
enabled: !!currentSystem,
|
enabled: !!system,
|
||||||
refetchInterval: 60000, // Keep signature refresh at 1 minute
|
refetchInterval: 60000, // Keep signature refresh at 1 minute
|
||||||
});
|
});
|
||||||
|
|
||||||
// Update current system when data changes and navigate to new system
|
|
||||||
useEffect(() => {
|
|
||||||
if (systemData && systemData !== currentSystem) {
|
|
||||||
setCurrentSystem(systemData);
|
|
||||||
navigate(`/${systemData}`);
|
|
||||||
console.log('Current system updated to:', systemData);
|
|
||||||
// Immediately refetch signatures when system changes
|
|
||||||
refetchSignatures();
|
|
||||||
toast({
|
|
||||||
title: "System Updated",
|
|
||||||
description: `Now tracking: ${systemData}`,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}, [systemData, currentSystem, refetchSignatures, navigate]);
|
|
||||||
|
|
||||||
// Refresh signatures every 5 seconds
|
// Refresh signatures every 5 seconds
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const refreshInterval = setInterval(() => {
|
const refreshInterval = setInterval(() => {
|
||||||
console.log('Auto-refreshing signatures...');
|
console.log('Auto-refreshing signatures...');
|
||||||
if (currentSystem) {
|
if (system) {
|
||||||
refetchSignatures();
|
refetchSignatures();
|
||||||
}
|
}
|
||||||
}, 5000);
|
}, 5000);
|
||||||
|
|
||||||
// Cleanup interval on component unmount
|
// Cleanup interval on component unmount
|
||||||
return () => clearInterval(refreshInterval);
|
return () => clearInterval(refreshInterval);
|
||||||
}, [refetchSignatures, currentSystem]);
|
}, [refetchSignatures, system]);
|
||||||
|
|
||||||
const handleRefresh = () => {
|
const handleRefresh = () => {
|
||||||
refetchSystem();
|
refetchSignatures();
|
||||||
if (currentSystem) {
|
if (system) {
|
||||||
refetchSignatures();
|
refetchSignatures();
|
||||||
}
|
}
|
||||||
toast({
|
toast({
|
||||||
@@ -117,7 +83,7 @@ const SystemTracker = ({ initialSystem }: SystemTrackerProps) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const signatures = signaturesData?.items || [];
|
const signatures = signaturesData?.items || [];
|
||||||
const isLoading = systemLoading || signaturesLoading;
|
const isLoading = signaturesLoading;
|
||||||
|
|
||||||
// Sort signatures by date (newest first) and prioritize unknown types
|
// Sort signatures by date (newest first) and prioritize unknown types
|
||||||
const sortedSignatures = [...signatures].sort((a, b) => {
|
const sortedSignatures = [...signatures].sort((a, b) => {
|
||||||
@@ -153,7 +119,7 @@ const SystemTracker = ({ initialSystem }: SystemTrackerProps) => {
|
|||||||
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-4">
|
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-4">
|
||||||
<CardTitle className="text-xl text-white flex items-center gap-2">
|
<CardTitle className="text-xl text-white flex items-center gap-2">
|
||||||
<Radar className="h-5 w-5 text-blue-400" />
|
<Radar className="h-5 w-5 text-blue-400" />
|
||||||
{initialSystem ? 'System View' : 'Current System'}
|
{system}
|
||||||
</CardTitle>
|
</CardTitle>
|
||||||
<Button
|
<Button
|
||||||
onClick={handleRefresh}
|
onClick={handleRefresh}
|
||||||
@@ -169,10 +135,10 @@ const SystemTracker = ({ initialSystem }: SystemTrackerProps) => {
|
|||||||
<CardContent>
|
<CardContent>
|
||||||
<div className="flex items-center justify-between">
|
<div className="flex items-center justify-between">
|
||||||
<div>
|
<div>
|
||||||
{systemLoading && !initialSystem ? (
|
{signaturesLoading ? (
|
||||||
<div className="text-slate-400">Loading system...</div>
|
<div className="text-slate-400">Loading system...</div>
|
||||||
) : currentSystem ? (
|
) : system ? (
|
||||||
<div className="text-2xl font-bold text-white">{currentSystem}</div>
|
<div className="text-2xl font-bold text-white">{system}</div>
|
||||||
) : (
|
) : (
|
||||||
<div className="text-slate-400">No system data</div>
|
<div className="text-slate-400">No system data</div>
|
||||||
)}
|
)}
|
||||||
@@ -197,12 +163,12 @@ const SystemTracker = ({ initialSystem }: SystemTrackerProps) => {
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
{/* Signatures Display */}
|
{/* Signatures Display */}
|
||||||
{currentSystem && !signaturesLoading && (
|
{system && !signaturesLoading && (
|
||||||
<div className="space-y-4">
|
<div className="space-y-4">
|
||||||
{sortedSignatures.length === 0 ? (
|
{sortedSignatures.length === 0 ? (
|
||||||
<Card className="bg-slate-800/30 border-slate-700">
|
<Card className="bg-slate-800/30 border-slate-700">
|
||||||
<CardContent className="pt-6 text-center">
|
<CardContent className="pt-6 text-center">
|
||||||
<div className="text-slate-400">No signatures found for {currentSystem}</div>
|
<div className="text-slate-400">No signatures found for {system}</div>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
) : (
|
) : (
|
||||||
@@ -228,7 +194,7 @@ const SystemTracker = ({ initialSystem }: SystemTrackerProps) => {
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
{/* Loading State */}
|
{/* Loading State */}
|
||||||
{signaturesLoading && currentSystem && (
|
{signaturesLoading && system && (
|
||||||
<Card className="bg-slate-800/30 border-slate-700">
|
<Card className="bg-slate-800/30 border-slate-700">
|
||||||
<CardContent className="pt-6">
|
<CardContent className="pt-6">
|
||||||
<div className="space-y-4">
|
<div className="space-y-4">
|
||||||
|
@@ -17,7 +17,7 @@ const SystemView = () => {
|
|||||||
<h1 className="text-4xl font-bold text-white mb-2">Cosmic Region Navigator</h1>
|
<h1 className="text-4xl font-bold text-white mb-2">Cosmic Region Navigator</h1>
|
||||||
<p className="text-slate-300">Viewing signatures for system: {system}</p>
|
<p className="text-slate-300">Viewing signatures for system: {system}</p>
|
||||||
</div>
|
</div>
|
||||||
<SystemTracker initialSystem={system} />
|
<SystemTracker system={system} />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
Reference in New Issue
Block a user