Fix issue where names are not being submit

This commit is contained in:
2025-06-17 14:29:27 +02:00
parent 7af1ced1a7
commit 2406169bbe

View File

@@ -8,7 +8,7 @@ import { Header } from "@/components/Header";
import { parseSignature, parseScannedPercentage } from "@/utils/signatureParser";
import { getSystemId } from "@/utils/systemApi";
import pb from "@/lib/pocketbase";
import { SigviewRecord as Signature } from "@/lib/pbtypes";
import { SigviewRecord as Signature, SignatureRecord, SigviewRecord } from "@/lib/pbtypes";
export const SystemView = () => {
const { system, region } = useParams();
@@ -24,7 +24,7 @@ export const SystemView = () => {
const saveSignature = async (signature: Signature): Promise<void> => {
try {
// Check if signature already exists
let existingRecord: Signature | null = null;
let existingRecord: SignatureRecord | null = null;
try {
existingRecord = await pb.collection('signature').getFirstListItem(`identifier='${signature.identifier}' && system='${signature.system}'`);
} catch (error) {
@@ -34,15 +34,15 @@ export const SystemView = () => {
const newScannedPercentage = parseScannedPercentage(signature.scanned);
if (existingRecord) {
const updatedSignature: Pick<Signature, 'updated' | 'type' | 'signame' | 'scanned'> = {
const updatedSignature: Pick<SignatureRecord, 'updated' | 'type' | 'name' | 'scanned'> = {
updated: new Date().toISOString()
}
// Existing record has no type and our new signature has a type
if (!!!existingRecord.type && !!signature.type)
updatedSignature.type = signature.type;
// Existing record has no signame and our new signature has a signame
if (!!!existingRecord.signame && !!signature.signame)
updatedSignature.signame = signature.signame;
if (!!!existingRecord.name && !!signature.signame)
updatedSignature.name = signature.signame;
// Update existing signature only if new scan percentage is higher
const existingScannedPercentage = parseScannedPercentage(existingRecord.scanned);
if (newScannedPercentage >= existingScannedPercentage)