Fix parsing and updating signatures

This commit is contained in:
2025-06-15 17:55:06 +02:00
parent 16bfd1d9a6
commit ec663fba55
4 changed files with 7 additions and 12 deletions

View File

@@ -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,

View File

@@ -1,4 +1,4 @@
import { Signature } from "@/components/SystemTracker";
import { Signature } from "@/lib/types";
export const parseSignature = (text: string): Omit<Signature, 'system' | 'sysid'> | null => {
const parts = text.split('\t');

View File

@@ -1,11 +1,6 @@
import pb from '@/lib/pocketbase';
export const getSystemId = async (systemName: string): Promise<string> => {
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;
};

View File

@@ -1,5 +1,5 @@
import { System } from '@/lib/types';
import pb from '../lib/pocketbase';
import pb from '@/lib/pocketbase';
const wormholeCollection = pb.collection('wormholeSystems');