@mytec: iter10.1 ready for testing

This commit is contained in:
2026-01-30 16:34:46 +02:00
parent 55fd42b696
commit d0e827e350
5 changed files with 96 additions and 60 deletions

View File

@@ -8,6 +8,7 @@ interface ShortcutHandlers {
onCalculate: () => void;
onCloseForm: () => void;
onShowShortcuts?: () => void;
onDeleteRequest?: (siteId: string, siteName: string) => void;
}
function isInputActive(): boolean {
@@ -21,6 +22,7 @@ export function useKeyboardShortcuts({
onCalculate,
onCloseForm,
onShowShortcuts,
onDeleteRequest,
}: ShortcutHandlers) {
useEffect(() => {
const handleKeyDown = (e: KeyboardEvent) => {
@@ -85,41 +87,15 @@ export function useKeyboardShortcuts({
case 'f': // F: Fit to coverage — dispatch custom event for Map.tsx to handle
window.dispatchEvent(new CustomEvent('rfcp:fit-bounds'));
return;
case 'delete': // Delete key: delete selected site with undo
case 'delete': // Delete key: show confirmation dialog
case 'backspace':
{
const selectedId = useSitesStore.getState().selectedSiteId;
if (selectedId) {
if (selectedId && onDeleteRequest) {
const site = useSitesStore.getState().sites.find(s => s.id === selectedId);
if (site) {
// Snapshot for undo
const snapshot = { ...site };
useSitesStore.getState().deleteSite(selectedId);
useToastStore.getState().addToast(`"${site.name}" deleted`, 'info', {
duration: 10000,
action: {
label: 'Undo',
onClick: async () => {
await useSitesStore.getState().addSite({
name: snapshot.name,
lat: snapshot.lat,
lon: snapshot.lon,
height: snapshot.height,
power: snapshot.power,
gain: snapshot.gain,
frequency: snapshot.frequency,
antennaType: snapshot.antennaType,
azimuth: snapshot.azimuth,
beamwidth: snapshot.beamwidth,
color: snapshot.color,
visible: snapshot.visible,
notes: snapshot.notes,
equipment: snapshot.equipment,
});
useToastStore.getState().addToast(`"${snapshot.name}" restored`, 'success');
},
},
});
e.preventDefault();
onDeleteRequest(site.id, site.name);
}
}
}
@@ -142,5 +118,5 @@ export function useKeyboardShortcuts({
window.addEventListener('keydown', handleKeyDown);
return () => window.removeEventListener('keydown', handleKeyDown);
}, [onCalculate, onCloseForm, onShowShortcuts]);
}, [onCalculate, onCloseForm, onShowShortcuts, onDeleteRequest]);
}