fix: bug when deleting an award reference which was not saved.

This commit is contained in:
2026-07-07 21:08:26 +02:00
parent daf38554a5
commit 128364260b
4 changed files with 45 additions and 8 deletions
+5 -1
View File
@@ -187,6 +187,9 @@ export function QSOEditModal({ qso, onSave, onDelete, onClose, countries = [], b
// WPX, …) are derived from the QSO by the backend and shown read-only.
const awardFieldRef = useRef<Record<string, string>>({});
const [awardRefs, setAwardRefs] = useState('');
// The refs present when the editor opened, so on save we can tell which ones
// were REMOVED and strip their in-field tokens (see applyAwardRefs).
const seedAwardRefsRef = useRef('');
const [computedRefs, setComputedRefs] = useState<Array<{ code: string; ref: string; name?: string }>>([]);
// Load award definitions once, then seed the editable manual refs from the QSO.
@@ -207,6 +210,7 @@ export function QSOEditModal({ qso, onSave, onDelete, onClose, countries = [], b
.filter((r: any) => r.pickable)
.map((r: any) => `${String(r.code).toUpperCase()}@${String(r.ref).toUpperCase()}`)
.join(';');
seedAwardRefsRef.current = seed;
setAwardRefs(seed);
} catch { /* leave manual refs empty on failure */ }
})
@@ -327,7 +331,7 @@ export function QSOEditModal({ qso, onSave, onDelete, onClose, countries = [], b
// the dedicated columns, then route the picked refs back onto the payload
// (POTA/SOTA/IOTA → columns, WWFF/custom → extras).
out.iota = ''; out.sota_ref = ''; out.pota_ref = '';
applyAwardRefs(out, awardRefs, awardFieldRef.current);
applyAwardRefs(out, awardRefs, awardFieldRef.current, seedAwardRefsRef.current);
onSave(out);
}