diff --git a/src/components/Search/SmartSearchBar.jsx b/src/components/Search/SmartSearchBar.jsx index 0a66945..af8ef79 100644 --- a/src/components/Search/SmartSearchBar.jsx +++ b/src/components/Search/SmartSearchBar.jsx @@ -4,10 +4,21 @@ import "../../styles/smartSearchBar.css"; function defaultZoomForKind(kind) { const k = (kind || "").toLowerCase(); + + // Specific types from suggestions endpoint + if (k === "post") return 16; // Close zoom for posts + if (k === "profile") return 14; // Medium zoom for profiles + if (k === "city") return 11; // City-level zoom + if (k === "region") return 7; // Wide zoom for regions/provinces + if (k === "place" || k === "poi") return 13; // Places zoom + + // Legacy/fallback if (k.includes("post")) return 15; - if (k.includes("place") || k.includes("poi")) return 13; - if (k.includes("region") || k.includes("area") || k.includes("city")) return 9; - return 12; + if (k.includes("city")) return 11; + if (k.includes("region") || k.includes("area") || k.includes("province") || k.includes("state")) return 7; + if (k.includes("place")) return 13; + + return 12; // Default } function IconPin(props) { diff --git a/src/services/recoSearch.js b/src/services/recoSearch.js index 168a4c4..dd22b9b 100644 --- a/src/services/recoSearch.js +++ b/src/services/recoSearch.js @@ -11,7 +11,8 @@ */ const DEFAULT_PATHS = [ - "/api/unified-search", // NEW: Unified search (posts + profiles + places) + "/api/suggestions", // NEW: Autocomplete suggestions (cities, posts, profiles) + "/api/unified-search", // Unified search (posts + profiles + places) "/api/search", // Fallback: Posts only "/api/reco/search", "/api/reco/suggest", @@ -30,7 +31,7 @@ function normalizeOne(r) { .toString() .trim(); - // coords possibles + // coords possibles (support multiple formats) const lat = typeof r.lat === "number" ? r.lat : (typeof r.latitude === "number" ? r.latitude : null); const lon = typeof r.lon === "number" ? r.lon : (typeof r.lng === "number" ? r.lng : null); @@ -40,13 +41,17 @@ function normalizeOne(r) { : (lat != null && lon != null ? [lon, lat] : null); const type = (r.type ?? r.kind ?? r.entity ?? "").toString().toLowerCase().trim(); + const kind = type || (coords ? "place" : "item"); return { id: (r.id ?? r._id ?? r.key ?? title).toString(), - type: type || (coords ? "place" : "item"), + type: kind, + kind: kind, // Keep both for compatibility title, subtitle: (r.subtitle ?? r.sub ?? r.extra ?? r.category ?? "").toString(), coords, + lat, + lon, raw: r, }; }