From 818fd5ac0dbb14056ec379a0314077c1dd706ba8 Mon Sep 17 00:00:00 2001 From: dohyeons Date: Thu, 20 Nov 2025 16:25:26 +0900 Subject: [PATCH] =?UTF-8?q?same=20key=EC=98=A4=EB=A5=98=20=ED=95=B4?= =?UTF-8?q?=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dashboard/widgets/MapTestWidgetV2.tsx | 13 ++++++------- .../dashboard/widgets/RiskAlertTestWidget.tsx | 9 +++++---- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/frontend/components/dashboard/widgets/MapTestWidgetV2.tsx b/frontend/components/dashboard/widgets/MapTestWidgetV2.tsx index 6b30f328..9cb2aa39 100644 --- a/frontend/components/dashboard/widgets/MapTestWidgetV2.tsx +++ b/frontend/components/dashboard/widgets/MapTestWidgetV2.tsx @@ -424,7 +424,7 @@ export default function MapTestWidgetV2({ element }: MapTestWidgetV2Props) { const firstCoord = row.coordinates[0]; if (Array.isArray(firstCoord) && firstCoord.length === 2) { polygons.push({ - id: row.id || row.code || `polygon-${index}`, + id: `${sourceName}-polygon-${index}-${row.code || row.id || Date.now()}`, // 고유 ID 생성 name: row.name || row.title || `영역 ${index + 1}`, coordinates: row.coordinates as [number, number][], status: row.status || row.level, @@ -499,9 +499,8 @@ export default function MapTestWidgetV2({ element }: MapTestWidgetV2Props) { if (lat !== undefined && lng !== undefined && (mapDisplayType as string) !== "polygon") { markers.push({ // 진행 방향(heading) 계산을 위해 ID는 새로고침마다 바뀌지 않도록 고정값 사용 - // - row.id / row.code가 있으면 그 값을 사용 - // - 없으면 sourceName과 index 조합으로 고정 ID 생성 - id: row.id || row.code || `${sourceName}-marker-${index}`, + // 중복 방지를 위해 sourceName과 index를 조합하여 고유 ID 생성 + id: `${sourceName}-${row.id || row.code || "marker"}-${index}`, lat: Number(lat), lng: Number(lng), latitude: Number(lat), @@ -1264,9 +1263,9 @@ export default function MapTestWidgetV2({ element }: MapTestWidgetV2Props) { {/* 마커 렌더링 */} {markers.map((marker) => { - // 첫 번째 데이터 소스의 마커 종류 가져오기 - const firstDataSource = dataSources?.[0]; - const markerType = firstDataSource?.markerType || "circle"; + // 마커의 소스에 해당하는 데이터 소스 찾기 + const sourceDataSource = dataSources?.find((ds) => ds.name === marker.source) || dataSources?.[0]; + const markerType = sourceDataSource?.markerType || "circle"; let markerIcon: any; if (typeof window !== "undefined") { diff --git a/frontend/components/dashboard/widgets/RiskAlertTestWidget.tsx b/frontend/components/dashboard/widgets/RiskAlertTestWidget.tsx index df8bf098..30ee99a5 100644 --- a/frontend/components/dashboard/widgets/RiskAlertTestWidget.tsx +++ b/frontend/components/dashboard/widgets/RiskAlertTestWidget.tsx @@ -377,8 +377,8 @@ export default function RiskAlertTestWidget({ element }: RiskAlertTestWidgetProp new Date().toISOString(); const alert: Alert = { - id: row.id || row.alert_id || row.incidentId || row.eventId || - row.code || row.subCode || `${sourceName}-${index}-${Date.now()}`, + // 중복 방지를 위해 소스명과 인덱스를 포함하여 고유 ID 생성 + id: `${sourceName}-${index}-${row.id || row.alert_id || row.incidentId || row.eventId || row.code || row.subCode || Date.now()}`, type, severity, title, @@ -614,8 +614,9 @@ export default function RiskAlertTestWidget({ element }: RiskAlertTestWidgetProp

알림이 없습니다

) : ( - filteredAlerts.map((alert) => ( - + filteredAlerts.map((alert, idx) => ( + // key 중복 방지를 위해 인덱스 추가 +
{getTypeIcon(alert.type)}