From eb64b8f2f9ce1750066b3a0169bb544bd377d0c2 Mon Sep 17 00:00:00 2001 From: rouggy Date: Sun, 7 Jun 2026 12:12:29 +0200 Subject: [PATCH] update --- frontend/src/components/AwardRefSelector.tsx | 48 +++++++++++++++++++- frontend/src/components/DetailsPanel.tsx | 1 + frontend/src/components/QSOEditModal.tsx | 2 +- 3 files changed, 48 insertions(+), 3 deletions(-) diff --git a/frontend/src/components/AwardRefSelector.tsx b/frontend/src/components/AwardRefSelector.tsx index aee3984..42d5393 100644 --- a/frontend/src/components/AwardRefSelector.tsx +++ b/frontend/src/components/AwardRefSelector.tsx @@ -25,9 +25,13 @@ interface Props { // Semicolon-delimited "AWARD@REF" entries, e.g. "POTA@FR-11553;IOTA@EU-064" value: string; onChange: (v: string) => void; + // Current QSO field values (state, cnty, …). When a predefined award reads one + // of these and it's already filled (e.g. VE9CF → state NB), the award counts + // automatically — we surface that so the operator needn't pick it by hand. + fieldValues?: Record; } -export function AwardRefSelector({ dxcc, value, onChange }: Props) { +export function AwardRefSelector({ dxcc, value, onChange, fieldValues }: Props) { const [defs, setDefs] = useState([]); const [metas, setMetas] = useState>({}); const [awardCode, setAwardCode] = useState('POTA'); @@ -67,7 +71,8 @@ export function AwardRefSelector({ dxcc, value, onChange }: Props) { const scope = d.dxcc_filter ?? []; if (scope.length > 0 && (!dxcc || !scope.includes(dxcc))) return false; return true; - }).map((d) => ({ code: d.code, name: d.name })); + }).map((d) => ({ code: d.code, name: d.name, field: String(d.field ?? '').toLowerCase() })) + .sort((a, b) => a.code.localeCompare(b.code)); }, [defs, metas, dxcc]); // Keep the selected award valid as the offered list changes with the call. @@ -86,6 +91,12 @@ export function AwardRefSelector({ dxcc, value, onChange }: Props) { // For dynamic lists, restrict to the contacted entity; otherwise load all. const refDxcc = isDynamic ? (dxcc ?? 0) : 0; + // The field the selected award reads (state / cnty / note / …). + const selField = useMemo( + () => String(defs.find((d) => d.code === awardCode)?.field ?? '').toLowerCase(), + [defs, awardCode], + ); + // Search helper with a DXCC fallback: try the entity-scoped query first, but // if it finds nothing AND we were filtering by DXCC, retry unfiltered. This // fixes awards whose references carry no per-ref DXCC (e.g. SOTA summits, @@ -130,6 +141,20 @@ export function AwardRefSelector({ dxcc, value, onChange }: Props) { // When q is empty/short: show auto-results (if ≤ AUTO_SHOW_MAX); when typing: show search results. const results: AwardRef[] = q.length >= 2 ? searchResults : (tooManyAuto ? [] : autoResults); + // Auto-match: when the selected award reads a QSO field that's already filled + // (e.g. RAC reads `state`, and the call resolved to state NB), find the matching + // reference so the operator can add it in one click — the award already counts + // it from the field, but this makes it explicit and confirms it. + const autoMatch = useMemo(() => { + if (!selField || !fieldValues) return null; + const v = String(fieldValues[selField] ?? '').trim().toUpperCase(); + if (!v) return null; + const pool = (autoResults.length ? autoResults : searchResults); + const m = pool.find((r) => r.code.toUpperCase() === v); + return m ? { code: m.code, name: m.name } : null; + }, [selField, fieldValues, autoResults, searchResults]); + const autoAlreadyAdded = autoMatch ? entries.includes(`${awardCode}@${autoMatch.code}`) : false; + function addRef(ref: AwardRef) { const entry = `${awardCode}@${ref.code}`; if (!entries.includes(entry)) { @@ -230,6 +255,25 @@ export function AwardRefSelector({ dxcc, value, onChange }: Props) { {/* Right panel: reference search */}
References + {/* Auto-match from the QSO field (e.g. State NB → RAC@NB). */} + {autoMatch && ( + + )} onChange({ award_refs: v })} + fieldValues={{ state: details.state ?? '', cnty: details.cnty ?? '' }} />
)} diff --git a/frontend/src/components/QSOEditModal.tsx b/frontend/src/components/QSOEditModal.tsx index 01847b0..71426bc 100644 --- a/frontend/src/components/QSOEditModal.tsx +++ b/frontend/src/components/QSOEditModal.tsx @@ -463,7 +463,7 @@ export function QSOEditModal({ qso, onSave, onDelete, onClose, countries = [] }:
{/* Left: pick reference-list awards (POTA/SOTA/IOTA/WWFF/…) */}
- +
{/* Right: computed awards (read-only) derived from this QSO */}