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"
|
"Assault case"
|
||||||
];
|
];
|
||||||
const description = descriptions[i % descriptions.length];
|
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];
|
return [...SAMPLE_CRIME_DATA, ...additionalData];
|
||||||
}
|
}
|
||||||
|
|
@ -370,6 +380,16 @@ export default function TopControl({
|
||||||
const handleCloseInfoBox = () => {
|
const handleCloseInfoBox = () => {
|
||||||
setShowInfoBox(false);
|
setShowInfoBox(false);
|
||||||
setSelectedSuggestion(null);
|
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 = () => {
|
const toggleSelectors = () => {
|
||||||
|
|
@ -606,9 +626,24 @@ export default function TopControl({
|
||||||
>
|
>
|
||||||
<span className="font-medium">{item.id}</span>
|
<span className="font-medium">{item.id}</span>
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
<span className="text-muted-foreground text-sm truncate max-w-[300px]">
|
{/* Show different information based on search type */}
|
||||||
{item.description}
|
{selectedSearchType === 'crime_id' || selectedSearchType === 'incident_id' ? (
|
||||||
</span>
|
<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
|
<Button
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
size="sm"
|
size="sm"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue