From 0c46b7c9f9e404996faed82e4b6481841b7956a8 Mon Sep 17 00:00:00 2001 From: emuehlstein <8663497+emuehlstein@users.noreply.github.com> Date: Fri, 17 Jul 2026 16:54:17 -0500 Subject: [PATCH 1/2] Add common aircraft frequencies to airport channel import Adds an optional set of common/itinerant aircraft frequencies (Guard, UNICOM, air-to-air, Multicom, SAR, etc.) to the Channel Wizard airport import flow. - Service: generateAirportChannels now accepts a selected subset of common frequencies. In single-zone mode they are appended to the Airports zone; in individual-zone mode they are placed in a separate Aircraft zone. Channels are receive-only (forbidTx, Analog, 25kHz). - UI: the 'Add common aircraft frequencies' checkbox is available in both zone-grouping modes, with a select/deselect list (all selected by default) plus Select All / Deselect All. - Tests: updated and added coverage for single-zone append, separate Aircraft zone in individual mode, partial subset selection, empty list, and receive-only channels. --- .../import/sources/AirportSource.tsx | 63 ++++++++++++++- src/services/airportChannels.ts | 76 ++++++++++++++++++- tests/unit/airportChannels.test.ts | 52 ++++++++++++- 3 files changed, 187 insertions(+), 4 deletions(-) diff --git a/src/components/import/sources/AirportSource.tsx b/src/components/import/sources/AirportSource.tsx index 584ca56..ec7e0f2 100644 --- a/src/components/import/sources/AirportSource.tsx +++ b/src/components/import/sources/AirportSource.tsx @@ -2,7 +2,7 @@ import React, { useState } from 'react'; import { formatPlural } from '../../../utils/formatPlural'; import { useImportStores } from '../../../hooks/useImportStores'; import { getNextChannelNumber, selectionCardClass } from '../../../utils/importHelpers'; -import { generateAirportChannels } from '../../../services/airportChannels'; +import { generateAirportChannels, COMMON_AIRCRAFT_FREQUENCIES } from '../../../services/airportChannels'; import { getAirportFrequenciesWithTypes, type AirportData } from '../../../data/airportsData'; import { SelectAllButtons } from '../SelectAllButtons'; import { Button } from '../../ui/Button'; @@ -26,8 +26,22 @@ export const AirportSource: React.FC = ({ const [selectedAirports, setSelectedAirports] = useState>(new Set()); const [airportZoneGrouping, setAirportZoneGrouping] = useState<'individual' | 'single'>('individual'); + const [includeCommonFrequencies, setIncludeCommonFrequencies] = useState(false); + const [selectedCommonFreqs, setSelectedCommonFreqs] = useState>( + new Set(COMMON_AIRCRAFT_FREQUENCIES.map((_, i) => i)) + ); const [isAddingAirports, setIsAddingAirports] = useState(false); + const handleToggleCommonFreq = (index: number) => { + const newSelected = new Set(selectedCommonFreqs); + if (newSelected.has(index)) { + newSelected.delete(index); + } else { + newSelected.add(index); + } + setSelectedCommonFreqs(newSelected); + }; + const handleToggleAirport = (index: number) => { const newSelected = new Set(selectedAirports); if (newSelected.has(index)) { @@ -67,11 +81,17 @@ export const AirportSource: React.FC = ({ const nextChannelNumber = getNextChannelNumber(channels); + // Build the selected subset of common aircraft frequencies (if enabled) + const commonFreqs = includeCommonFrequencies + ? COMMON_AIRCRAFT_FREQUENCIES.filter((_, i) => selectedCommonFreqs.has(i)) + : []; + // Generate channels and zones for selected airports const result = generateAirportChannels( nextChannelNumber, selectedAirportList, // Pass selected airports - airportZoneGrouping === 'single' // Group all in one zone if selected + airportZoneGrouping === 'single', // Group all in one zone if selected + commonFreqs // Common aircraft frequencies to also add ); if (result.channels.length === 0) { @@ -188,6 +208,45 @@ export const AirportSource: React.FC = ({ Single zone (all airports together) + + {includeCommonFrequencies && ( +
+
+ + {airportZoneGrouping === 'single' + ? 'Added to the Airports zone' + : 'Added as a separate "Aircraft" zone'} + + + setSelectedCommonFreqs(new Set(COMMON_AIRCRAFT_FREQUENCIES.map((_, i) => i))) + } + onDeselectAll={() => setSelectedCommonFreqs(new Set())} + /> +
+
+ {COMMON_AIRCRAFT_FREQUENCIES.map((freq, index) => ( + + ))} +
+
+ )}