feat: implement drain issue
This commit is contained in:
@@ -5,6 +5,7 @@ import dynamic from 'next/dynamic';
|
||||
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
|
||||
import { Loader2, Milestone } from 'lucide-react';
|
||||
import { Detection } from '@/types';
|
||||
import { DETECTION_TYPES } from '@/constants/detectionModeConfig';
|
||||
|
||||
// Dynamically import the map to avoid SSR issues with Leaflet
|
||||
const DashboardMapContent = dynamic(() => import('./dashboard-map-content'), {
|
||||
@@ -78,20 +79,6 @@ export function DashboardMap({
|
||||
// Filter detections with valid GPS coordinates
|
||||
const validDetections = detections.filter((d) => d.latitude && d.longitude);
|
||||
|
||||
// Count detections by category
|
||||
const counts = {
|
||||
defected_sign_board: validDetections.filter(
|
||||
(d) => d.type?.toLowerCase() === 'defected_sign_board',
|
||||
).length,
|
||||
pothole: validDetections.filter((d) => d.type?.toLowerCase() === 'pothole').length,
|
||||
road_crack: validDetections.filter((d) => d.type?.toLowerCase() === 'road_crack').length,
|
||||
damaged_road_marking: validDetections.filter(
|
||||
(d) => d.type?.toLowerCase() === 'damaged_road_marking',
|
||||
).length,
|
||||
good_sign_board: validDetections.filter((d) => d.type?.toLowerCase() === 'good_sign_board')
|
||||
.length,
|
||||
};
|
||||
|
||||
return (
|
||||
<Card className={`overflow-hidden ${className}`}>
|
||||
<CardHeader className="pb-2">
|
||||
@@ -104,42 +91,30 @@ export function DashboardMap({
|
||||
<CardTitle className="text-base font-bold">Detection Map</CardTitle>
|
||||
<p className="text-xs text-muted-foreground">
|
||||
{isLoading
|
||||
? 'Loading...'
|
||||
: `${validDetections.length} detections with GPS coordinates`}
|
||||
? 'Loading...'
|
||||
: `${validDetections.length} detections with GPS coordinates`}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Compact Color Legend */}
|
||||
{/* Dynamic Color Legend */}
|
||||
<div className="flex flex-wrap items-center justify-end gap-x-4 gap-y-1 text-[10px] max-w-[60%]">
|
||||
<div className="flex items-center gap-1">
|
||||
<div className="w-2.5 h-2.5 rounded-full bg-red-500" />
|
||||
<span className="text-muted-foreground font-medium">Potholes ({counts.pothole})</span>
|
||||
</div>
|
||||
<div className="flex items-center gap-1">
|
||||
<div className="w-2.5 h-2.5 rounded-full bg-blue-500" />
|
||||
<span className="text-muted-foreground font-medium">
|
||||
Defected Signs ({counts.defected_sign_board})
|
||||
</span>
|
||||
</div>
|
||||
<div className="flex items-center gap-1">
|
||||
<div className="w-2.5 h-2.5 rounded-full bg-amber-500" />
|
||||
<span className="text-muted-foreground font-medium">
|
||||
Cracks ({counts.road_crack})
|
||||
</span>
|
||||
</div>
|
||||
<div className="flex items-center gap-1">
|
||||
<div className="w-2.5 h-2.5 rounded-full bg-indigo-500" />
|
||||
<span className="text-muted-foreground font-medium">
|
||||
Markings ({counts.damaged_road_marking})
|
||||
</span>
|
||||
</div>
|
||||
<div className="flex items-center gap-1">
|
||||
<div className="w-2.5 h-2.5 rounded-full bg-emerald-500" />
|
||||
<span className="text-muted-foreground font-medium">
|
||||
Good Signs ({counts.good_sign_board})
|
||||
</span>
|
||||
</div>
|
||||
{Object.values(DETECTION_TYPES).map((type) => {
|
||||
const count = validDetections.filter(
|
||||
(d) => (d.type || d.class || '').toLowerCase() === type.id.toLowerCase()
|
||||
).length;
|
||||
|
||||
if (count === 0 && (type.id.includes('culvert') || type.id === 'drain_issue')) return null;
|
||||
|
||||
return (
|
||||
<div key={type.id} className="flex items-center gap-1">
|
||||
<div className="w-2.5 h-2.5 rounded-full" style={{ backgroundColor: type.color }} />
|
||||
<span className="text-muted-foreground font-medium">
|
||||
{type.label} ({count})
|
||||
</span>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
</CardHeader>
|
||||
|
||||
Reference in New Issue
Block a user