|
|
@@ -22,6 +22,7 @@ export const SystemView = () => {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const saveSignature = async (signature: Signature): Promise<void> => {
|
|
|
|
const saveSignature = async (signature: Signature): Promise<void> => {
|
|
|
|
|
|
|
|
console.log(signature);
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
// Check if signature already exists
|
|
|
|
// Check if signature already exists
|
|
|
|
let existingRecord: SignatureRecord | null = null;
|
|
|
|
let existingRecord: SignatureRecord | null = null;
|
|
|
@@ -34,7 +35,7 @@ export const SystemView = () => {
|
|
|
|
const newScannedPercentage = parseScannedPercentage(signature.scanned);
|
|
|
|
const newScannedPercentage = parseScannedPercentage(signature.scanned);
|
|
|
|
|
|
|
|
|
|
|
|
if (existingRecord) {
|
|
|
|
if (existingRecord) {
|
|
|
|
const updatedSignature: Pick<SignatureRecord, 'updated' | 'type' | 'name' | 'scanned'> = {
|
|
|
|
const updatedSignature: Pick<SignatureRecord, 'updated' | 'type' | 'name' | 'scanned' | 'note'> = {
|
|
|
|
updated: new Date().toISOString()
|
|
|
|
updated: new Date().toISOString()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Existing record has no type and our new signature has a type
|
|
|
|
// Existing record has no type and our new signature has a type
|
|
|
@@ -47,6 +48,8 @@ export const SystemView = () => {
|
|
|
|
const existingScannedPercentage = parseScannedPercentage(existingRecord.scanned);
|
|
|
|
const existingScannedPercentage = parseScannedPercentage(existingRecord.scanned);
|
|
|
|
if (newScannedPercentage >= existingScannedPercentage)
|
|
|
|
if (newScannedPercentage >= existingScannedPercentage)
|
|
|
|
updatedSignature.scanned = signature.scanned;
|
|
|
|
updatedSignature.scanned = signature.scanned;
|
|
|
|
|
|
|
|
if (!!!existingRecord.note && !!signature.note)
|
|
|
|
|
|
|
|
updatedSignature.note = signature.note;
|
|
|
|
await pb.collection('signature').update(existingRecord.id, updatedSignature);
|
|
|
|
await pb.collection('signature').update(existingRecord.id, updatedSignature);
|
|
|
|
console.log(`Updated signature ${signature.identifier}: ${existingScannedPercentage}% -> ${newScannedPercentage}%`);
|
|
|
|
console.log(`Updated signature ${signature.identifier}: ${existingScannedPercentage}% -> ${newScannedPercentage}%`);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
@@ -57,7 +60,8 @@ export const SystemView = () => {
|
|
|
|
name: signature.signame,
|
|
|
|
name: signature.signame,
|
|
|
|
type: signature.type,
|
|
|
|
type: signature.type,
|
|
|
|
dangerous: signature.dangerous,
|
|
|
|
dangerous: signature.dangerous,
|
|
|
|
scanned: signature.scanned
|
|
|
|
scanned: signature.scanned,
|
|
|
|
|
|
|
|
note: signature.note
|
|
|
|
});
|
|
|
|
});
|
|
|
|
console.log(`Created new signature ${signature.identifier} with ${newScannedPercentage}% scan`);
|
|
|
|
console.log(`Created new signature ${signature.identifier} with ${newScannedPercentage}% scan`);
|
|
|
|
}
|
|
|
|
}
|
|
|
|