Fix parsing and updating signatures
This commit is contained in:
@@ -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,
|
||||
|
@@ -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');
|
||||
|
@@ -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;
|
||||
};
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import { System } from '@/lib/types';
|
||||
import pb from '../lib/pocketbase';
|
||||
import pb from '@/lib/pocketbase';
|
||||
|
||||
const wormholeCollection = pb.collection('wormholeSystems');
|
||||
|
||||
|
Reference in New Issue
Block a user