From 95a3db34f148f9b04852d6956f0555494993afae Mon Sep 17 00:00:00 2001 From: Pouzor Date: Sun, 29 Mar 2026 14:57:25 +0200 Subject: [PATCH] fix: move AnimMode type to module scope, fix tsc -b build error --- frontend/src/components/modals/EdgeModal.tsx | 45 +++++++++++++------- 1 file changed, 29 insertions(+), 16 deletions(-) diff --git a/frontend/src/components/modals/EdgeModal.tsx b/frontend/src/components/modals/EdgeModal.tsx index ff228ab..95d07b7 100644 --- a/frontend/src/components/modals/EdgeModal.tsx +++ b/frontend/src/components/modals/EdgeModal.tsx @@ -10,6 +10,14 @@ import { EDGE_DEFAULT_COLORS } from '@/utils/edgeColors' const EDGE_TYPES = Object.entries(EDGE_TYPE_LABELS) as [EdgeType, string][] +type AnimMode = 'none' | 'snake' | 'flow' + +function toAnimMode(v: EdgeData['animated']): AnimMode { + if (v === true || v === 'snake') return 'snake' + if (v === 'flow') return 'flow' + return 'none' +} + interface EdgeModalProps { open: boolean onClose: () => void @@ -25,7 +33,7 @@ export function EdgeModal({ open, onClose, onSubmit, onDelete, initial, title = const [vlanId, setVlanId] = useState(initial?.vlan_id?.toString() ?? '') const [customColor, setCustomColor] = useState(initial?.custom_color) const [pathStyle, setPathStyle] = useState(initial?.path_style ?? 'bezier') - const [animated, setAnimated] = useState(initial?.animated ?? false) + const [animation, setAnimation] = useState(() => toAnimMode(initial?.animated)) const effectiveColor = customColor ?? EDGE_DEFAULT_COLORS[type] @@ -37,7 +45,7 @@ export function EdgeModal({ open, onClose, onSubmit, onDelete, initial, title = vlan_id: type === 'vlan' && vlanId ? parseInt(vlanId) : undefined, custom_color: customColor, path_style: pathStyle, - animated: animated || undefined, + animated: animation !== 'none' ? animation : undefined, }) onClose() } @@ -115,20 +123,25 @@ export function EdgeModal({ open, onClose, onSubmit, onDelete, initial, title = -
- - +
+ +
+ {(['none', 'snake', 'flow'] as AnimMode[]).map((mode, i) => ( + + ))} +