Remove references to localhost (we are now a website!)

This commit is contained in:
2025-06-14 16:48:55 +02:00
parent dcf50b3ade
commit 8aff6f06e7
2 changed files with 31 additions and 65 deletions

View File

@@ -6,7 +6,6 @@ import { Button } from "@/components/ui/button";
import { RefreshCw, AlertCircle, Radar } from "lucide-react";
import SignatureListItem from "./SignatureListItem";
import { toast } from "@/hooks/use-toast";
import { useNavigate } from "react-router-dom";
interface SignatureItem {
collectionId: string;
@@ -27,28 +26,10 @@ interface ApiResponse {
}
interface SystemTrackerProps {
initialSystem?: string;
system: string;
}
const SystemTracker = ({ initialSystem }: 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,
});
const SystemTracker = ({ system }: SystemTrackerProps) => {
// Query to get signatures for the current system
const {
data: signaturesData,
@@ -56,14 +37,14 @@ const SystemTracker = ({ initialSystem }: SystemTrackerProps) => {
isLoading: signaturesLoading,
error: signaturesError
} = useQuery({
queryKey: ['signatures', currentSystem],
queryKey: ['signatures', system],
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}')`;
console.log('Fetching signatures for system:', currentSystem);
console.log('Fetching signatures for system:', system);
console.log('API URL:', url);
const response = await fetch(url);
@@ -73,41 +54,26 @@ const SystemTracker = ({ initialSystem }: SystemTrackerProps) => {
const data: ApiResponse = await response.json();
return data;
},
enabled: !!currentSystem,
enabled: !!system,
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
useEffect(() => {
const refreshInterval = setInterval(() => {
console.log('Auto-refreshing signatures...');
if (currentSystem) {
if (system) {
refetchSignatures();
}
}, 5000);
// Cleanup interval on component unmount
return () => clearInterval(refreshInterval);
}, [refetchSignatures, currentSystem]);
}, [refetchSignatures, system]);
const handleRefresh = () => {
refetchSystem();
if (currentSystem) {
refetchSignatures();
if (system) {
refetchSignatures();
}
toast({
@@ -117,7 +83,7 @@ const SystemTracker = ({ initialSystem }: SystemTrackerProps) => {
};
const signatures = signaturesData?.items || [];
const isLoading = systemLoading || signaturesLoading;
const isLoading = signaturesLoading;
// Sort signatures by date (newest first) and prioritize unknown types
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">
<CardTitle className="text-xl text-white flex items-center gap-2">
<Radar className="h-5 w-5 text-blue-400" />
{initialSystem ? 'System View' : 'Current System'}
{system}
</CardTitle>
<Button
onClick={handleRefresh}
@@ -169,10 +135,10 @@ const SystemTracker = ({ initialSystem }: SystemTrackerProps) => {
<CardContent>
<div className="flex items-center justify-between">
<div>
{systemLoading && !initialSystem ? (
{signaturesLoading ? (
<div className="text-slate-400">Loading system...</div>
) : currentSystem ? (
<div className="text-2xl font-bold text-white">{currentSystem}</div>
) : system ? (
<div className="text-2xl font-bold text-white">{system}</div>
) : (
<div className="text-slate-400">No system data</div>
)}
@@ -197,12 +163,12 @@ const SystemTracker = ({ initialSystem }: SystemTrackerProps) => {
)}
{/* Signatures Display */}
{currentSystem && !signaturesLoading && (
{system && !signaturesLoading && (
<div className="space-y-4">
{sortedSignatures.length === 0 ? (
<Card className="bg-slate-800/30 border-slate-700">
<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>
</Card>
) : (
@@ -228,7 +194,7 @@ const SystemTracker = ({ initialSystem }: SystemTrackerProps) => {
)}
{/* Loading State */}
{signaturesLoading && currentSystem && (
{signaturesLoading && system && (
<Card className="bg-slate-800/30 border-slate-700">
<CardContent className="pt-6">
<div className="space-y-4">

View File

@@ -17,7 +17,7 @@ const SystemView = () => {
<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>
</div>
<SystemTracker initialSystem={system} />
<SystemTracker system={system} />
</div>
</div>
);