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 { parseSignature, parseScannedPercentage } from "@/utils/signatureParser";
|
||||||
import { getSystemId } from "@/utils/systemApi";
|
import { getSystemId } from "@/utils/systemApi";
|
||||||
import pb from "@/lib/pocketbase";
|
import pb from "@/lib/pocketbase";
|
||||||
import { Signature } from "@/components/SystemTracker";
|
import { Signature } from "@/lib/types";
|
||||||
|
|
||||||
export const SystemView = () => {
|
export const SystemView = () => {
|
||||||
const { system, region } = useParams();
|
const { system, region } = useParams();
|
||||||
@@ -37,7 +37,7 @@ export const SystemView = () => {
|
|||||||
const existingRecord = existingRecords.items[0];
|
const existingRecord = existingRecords.items[0];
|
||||||
const existingScannedPercentage = parseScannedPercentage(existingRecord.scanned);
|
const existingScannedPercentage = parseScannedPercentage(existingRecord.scanned);
|
||||||
|
|
||||||
if (newScannedPercentage > existingScannedPercentage) {
|
if (newScannedPercentage >= existingScannedPercentage) {
|
||||||
await pb.collection('signature').update(existingRecord.id, {
|
await pb.collection('signature').update(existingRecord.id, {
|
||||||
name: signature.signame,
|
name: signature.signame,
|
||||||
type: signature.type,
|
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 => {
|
export const parseSignature = (text: string): Omit<Signature, 'system' | 'sysid'> | null => {
|
||||||
const parts = text.split('\t');
|
const parts = text.split('\t');
|
||||||
|
@@ -1,11 +1,6 @@
|
|||||||
|
import pb from '@/lib/pocketbase';
|
||||||
|
|
||||||
export const getSystemId = async (systemName: string): Promise<string> => {
|
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 system = await pb.collection('regionview').getFirstListItem(`sysname='${systemName}'`);
|
||||||
const response = await fetch(url);
|
return system.id;
|
||||||
const data = await response.json();
|
|
||||||
|
|
||||||
if (data.items && data.items.length > 0) {
|
|
||||||
return data.items[0].id;
|
|
||||||
}
|
|
||||||
throw new Error(`System ${systemName} not found`);
|
|
||||||
};
|
};
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import { System } from '@/lib/types';
|
import { System } from '@/lib/types';
|
||||||
import pb from '../lib/pocketbase';
|
import pb from '@/lib/pocketbase';
|
||||||
|
|
||||||
const wormholeCollection = pb.collection('wormholeSystems');
|
const wormholeCollection = pb.collection('wormholeSystems');
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user