diff --git a/sigap-website/app/_components/map/controls/top-controls.tsx b/sigap-website/app/_components/map/controls/top-controls.tsx index f13bb84..e67af28 100644 --- a/sigap-website/app/_components/map/controls/top-controls.tsx +++ b/sigap-website/app/_components/map/controls/top-controls.tsx @@ -70,7 +70,17 @@ const generateSampleData = () => { "Assault case" ]; const description = descriptions[i % descriptions.length]; - additionalData.push({ id, description: `${description} #${i}` }); + + // Add more detailed properties for enhanced suggestions + additionalData.push({ + id, + description: `${description} #${i}`, + coordinates: `${-6 - (i % 5) * 0.01}, ${106 + (i % 7) * 0.01}`, + address: `Jl. ${["Sudirman", "Thamrin", "Gatot Subroto", "Rasuna Said", "Asia Afrika"][i % 5]} No. ${i + 10}, Jakarta`, + date: new Date(2022 + (i % 3), i % 12, i % 28 + 1), + type: ["Theft", "Assault", "Vandalism", "Robbery", "Fraud"][i % 5], + category: ["Property Crime", "Violent Crime", "Public Disturbance", "White Collar", "Misdemeanor"][i % 5] + }); } return [...SAMPLE_CRIME_DATA, ...additionalData]; } @@ -370,6 +380,16 @@ export default function TopControl({ const handleCloseInfoBox = () => { setShowInfoBox(false); setSelectedSuggestion(null); + + // Restore original suggestions for the current search type + if (selectedSearchType) { + const currentPrefix = ACTIONS.find(action => action.id === selectedSearchType)?.prefix || ""; + const initialSuggestions = filterSuggestions(selectedSearchType, currentPrefix); + + setTimeout(() => { + setSuggestions(initialSuggestions); + }, 0); + } }; const toggleSelectors = () => { @@ -606,9 +626,24 @@ export default function TopControl({ > {item.id}
- - {item.description} - + {/* Show different information based on search type */} + {selectedSearchType === 'crime_id' || selectedSearchType === 'incident_id' ? ( + + {item.description} + + ) : selectedSearchType === 'coordinates' && 'coordinates' in item ? ( + + {typeof item.coordinates === 'string' ? item.coordinates : 'N/A'} - {item.description} + + ) : selectedSearchType === 'address' && 'address' in item ? ( + + {'address' in item && typeof item.address === 'string' ? item.address : 'N/A'} + + ) : ( + + {item.description} + + )}