refactor: video section

This commit is contained in:
2026-03-19 10:21:38 +05:30
parent 762503cedf
commit 7eb3d60932
16 changed files with 1115 additions and 854 deletions

27
src/hooks/use-gps-map.ts Normal file
View File

@@ -0,0 +1,27 @@
import { useMemo } from 'react';
import { DetectionData } from '@/types';
export const useGpsMap = (data: DetectionData) => {
const gpsMap = useMemo(() => {
const map = new Map<number, { lat: number; lng: number }>();
const addItemsToMap = (list?: any[]) => {
if (!list || !Array.isArray(list)) return;
list.forEach((item) => {
const id =
(item as any).pothole_id ?? (item as any).signboard_id ?? (item as any).detection_id;
if (item.lat !== undefined && item.lng !== undefined && id !== undefined) {
map.set(id, { lat: item.lat, lng: item.lng });
}
});
};
addItemsToMap(data.pothole_list);
addItemsToMap(data.signboard_list);
addItemsToMap(data.defected_sign_board_list);
addItemsToMap(data.road_crack_list);
addItemsToMap(data.damaged_road_marking_list);
addItemsToMap(data.good_sign_board_list);
return map;
}, [data]);
return gpsMap;
};