same key오류 해결
This commit is contained in:
parent
2facf19429
commit
818fd5ac0d
|
|
@ -424,7 +424,7 @@ export default function MapTestWidgetV2({ element }: MapTestWidgetV2Props) {
|
||||||
const firstCoord = row.coordinates[0];
|
const firstCoord = row.coordinates[0];
|
||||||
if (Array.isArray(firstCoord) && firstCoord.length === 2) {
|
if (Array.isArray(firstCoord) && firstCoord.length === 2) {
|
||||||
polygons.push({
|
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}`,
|
name: row.name || row.title || `영역 ${index + 1}`,
|
||||||
coordinates: row.coordinates as [number, number][],
|
coordinates: row.coordinates as [number, number][],
|
||||||
status: row.status || row.level,
|
status: row.status || row.level,
|
||||||
|
|
@ -499,9 +499,8 @@ export default function MapTestWidgetV2({ element }: MapTestWidgetV2Props) {
|
||||||
if (lat !== undefined && lng !== undefined && (mapDisplayType as string) !== "polygon") {
|
if (lat !== undefined && lng !== undefined && (mapDisplayType as string) !== "polygon") {
|
||||||
markers.push({
|
markers.push({
|
||||||
// 진행 방향(heading) 계산을 위해 ID는 새로고침마다 바뀌지 않도록 고정값 사용
|
// 진행 방향(heading) 계산을 위해 ID는 새로고침마다 바뀌지 않도록 고정값 사용
|
||||||
// - row.id / row.code가 있으면 그 값을 사용
|
// 중복 방지를 위해 sourceName과 index를 조합하여 고유 ID 생성
|
||||||
// - 없으면 sourceName과 index 조합으로 고정 ID 생성
|
id: `${sourceName}-${row.id || row.code || "marker"}-${index}`,
|
||||||
id: row.id || row.code || `${sourceName}-marker-${index}`,
|
|
||||||
lat: Number(lat),
|
lat: Number(lat),
|
||||||
lng: Number(lng),
|
lng: Number(lng),
|
||||||
latitude: Number(lat),
|
latitude: Number(lat),
|
||||||
|
|
@ -1264,9 +1263,9 @@ export default function MapTestWidgetV2({ element }: MapTestWidgetV2Props) {
|
||||||
|
|
||||||
{/* 마커 렌더링 */}
|
{/* 마커 렌더링 */}
|
||||||
{markers.map((marker) => {
|
{markers.map((marker) => {
|
||||||
// 첫 번째 데이터 소스의 마커 종류 가져오기
|
// 마커의 소스에 해당하는 데이터 소스 찾기
|
||||||
const firstDataSource = dataSources?.[0];
|
const sourceDataSource = dataSources?.find((ds) => ds.name === marker.source) || dataSources?.[0];
|
||||||
const markerType = firstDataSource?.markerType || "circle";
|
const markerType = sourceDataSource?.markerType || "circle";
|
||||||
|
|
||||||
let markerIcon: any;
|
let markerIcon: any;
|
||||||
if (typeof window !== "undefined") {
|
if (typeof window !== "undefined") {
|
||||||
|
|
|
||||||
|
|
@ -377,8 +377,8 @@ export default function RiskAlertTestWidget({ element }: RiskAlertTestWidgetProp
|
||||||
new Date().toISOString();
|
new Date().toISOString();
|
||||||
|
|
||||||
const alert: Alert = {
|
const alert: Alert = {
|
||||||
id: row.id || row.alert_id || row.incidentId || row.eventId ||
|
// 중복 방지를 위해 소스명과 인덱스를 포함하여 고유 ID 생성
|
||||||
row.code || row.subCode || `${sourceName}-${index}-${Date.now()}`,
|
id: `${sourceName}-${index}-${row.id || row.alert_id || row.incidentId || row.eventId || row.code || row.subCode || Date.now()}`,
|
||||||
type,
|
type,
|
||||||
severity,
|
severity,
|
||||||
title,
|
title,
|
||||||
|
|
@ -614,8 +614,9 @@ export default function RiskAlertTestWidget({ element }: RiskAlertTestWidgetProp
|
||||||
<p className="text-sm">알림이 없습니다</p>
|
<p className="text-sm">알림이 없습니다</p>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
filteredAlerts.map((alert) => (
|
filteredAlerts.map((alert, idx) => (
|
||||||
<Card key={alert.id} className="p-2">
|
// key 중복 방지를 위해 인덱스 추가
|
||||||
|
<Card key={`${alert.id}-${idx}`} className="p-2">
|
||||||
<div className="flex items-start gap-2">
|
<div className="flex items-start gap-2">
|
||||||
<div className={`mt-0.5 rounded-full p-1 ${alert.severity === "high" ? "bg-destructive/10 text-destructive" : alert.severity === "medium" ? "bg-warning/10 text-warning" : "bg-primary/10 text-primary"}`}>
|
<div className={`mt-0.5 rounded-full p-1 ${alert.severity === "high" ? "bg-destructive/10 text-destructive" : alert.severity === "medium" ? "bg-warning/10 text-warning" : "bg-primary/10 text-primary"}`}>
|
||||||
{getTypeIcon(alert.type)}
|
{getTypeIcon(alert.type)}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue