feat: improved suggestions and update suggestion display based on search type
This commit is contained in:
parent
125b281275
commit
5b57476437
|
|
@ -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({
|
|||
>
|
||||
<span className="font-medium">{item.id}</span>
|
||||
<div className="flex items-center gap-2">
|
||||
<span className="text-muted-foreground text-sm truncate max-w-[300px]">
|
||||
{item.description}
|
||||
</span>
|
||||
{/* Show different information based on search type */}
|
||||
{selectedSearchType === 'crime_id' || selectedSearchType === 'incident_id' ? (
|
||||
<span className="text-muted-foreground text-sm truncate max-w-[300px]">
|
||||
{item.description}
|
||||
</span>
|
||||
) : selectedSearchType === 'coordinates' && 'coordinates' in item ? (
|
||||
<span className="text-muted-foreground text-sm truncate max-w-[300px]">
|
||||
{typeof item.coordinates === 'string' ? item.coordinates : 'N/A'} - {item.description}
|
||||
</span>
|
||||
) : selectedSearchType === 'address' && 'address' in item ? (
|
||||
<span className="text-muted-foreground text-sm truncate max-w-[300px]">
|
||||
{'address' in item && typeof item.address === 'string' ? item.address : 'N/A'}
|
||||
</span>
|
||||
) : (
|
||||
<span className="text-muted-foreground text-sm truncate max-w-[300px]">
|
||||
{item.description}
|
||||
</span>
|
||||
)}
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
|
|
|
|||
Loading…
Reference in New Issue