diff --git a/src/pages/SystemView.tsx b/src/pages/SystemView.tsx index 87c38b6..1079bf9 100644 --- a/src/pages/SystemView.tsx +++ b/src/pages/SystemView.tsx @@ -10,7 +10,7 @@ import { Header } from "@/components/Header"; import { parseSignature, parseScannedPercentage } from "@/utils/signatureParser"; import { getSystemId } from "@/utils/systemApi"; import pb from "@/lib/pocketbase"; -import { Signature } from "@/components/SystemTracker"; +import { Signature } from "@/lib/types"; export const SystemView = () => { const { system, region } = useParams(); @@ -37,7 +37,7 @@ export const SystemView = () => { const existingRecord = existingRecords.items[0]; const existingScannedPercentage = parseScannedPercentage(existingRecord.scanned); - if (newScannedPercentage > existingScannedPercentage) { + if (newScannedPercentage >= existingScannedPercentage) { await pb.collection('signature').update(existingRecord.id, { name: signature.signame, type: signature.type, diff --git a/src/utils/signatureParser.ts b/src/utils/signatureParser.ts index 8c5709c..0abd60e 100644 --- a/src/utils/signatureParser.ts +++ b/src/utils/signatureParser.ts @@ -1,4 +1,4 @@ -import { Signature } from "@/components/SystemTracker"; +import { Signature } from "@/lib/types"; export const parseSignature = (text: string): Omit | null => { const parts = text.split('\t'); diff --git a/src/utils/systemApi.ts b/src/utils/systemApi.ts index 5957ac6..40a0448 100644 --- a/src/utils/systemApi.ts +++ b/src/utils/systemApi.ts @@ -1,11 +1,6 @@ +import pb from '@/lib/pocketbase'; export const getSystemId = async (systemName: string): Promise => { - const url = `https://evebase.site.quack-lab.dev/api/collections/regionview/records?filter=(sysname='${encodeURIComponent(systemName)}')`; - const response = await fetch(url); - const data = await response.json(); - - if (data.items && data.items.length > 0) { - return data.items[0].id; - } - throw new Error(`System ${systemName} not found`); + const system = await pb.collection('regionview').getFirstListItem(`sysname='${systemName}'`); + return system.id; }; diff --git a/src/utils/wormholeStorage.ts b/src/utils/wormholeStorage.ts index dce6396..949c3d3 100644 --- a/src/utils/wormholeStorage.ts +++ b/src/utils/wormholeStorage.ts @@ -1,5 +1,5 @@ import { System } from '@/lib/types'; -import pb from '../lib/pocketbase'; +import pb from '@/lib/pocketbase'; const wormholeCollection = pb.collection('wormholeSystems');