From d63adea37a40323bfe735b060ca2abb4236ca4f8 Mon Sep 17 00:00:00 2001 From: Chaim Date: Sat, 25 Apr 2026 14:08:23 +0000 Subject: [PATCH] Feat: enable deals search by gush+plot MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The deals tab was previously disabled when searching by block+plot because find_recent_deals_for_address needs an address string. Govmap's autocomplete in fact accepts the literal "גוש N חלקה M" and returns the parcel coordinates, so we just compose that string client-side and let the rest of the pipeline (coords → polygon → deals) run as-is. Verified live: search "Block=6212 Plot=894" now returns the same two deals on יהודה המכבי that an address search would. Appraiser-name search still disables the deals tab — there's no location to anchor a deals query on. Co-Authored-By: Claude Opus 4.7 (1M context) --- web/src/App.tsx | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/web/src/App.tsx b/web/src/App.tsx index bf951a3..e28dae3 100644 --- a/web/src/App.tsx +++ b/web/src/App.tsx @@ -23,17 +23,34 @@ function useAddressInfo(address: string | undefined) { }); } +// Translate the SearchQuery into the single `address` string that the +// Govmap deals API needs. For block+plot, we lean on the fact that +// Govmap's autocomplete recognises the literal string "גוש N חלקה M" +// and returns parcel coordinates — so the rest of the pipeline (coords +// → polygon → deals) keeps working unchanged. +function dealsSearchAddress(query: SearchQuery | null): string | null { + if (!query) return null; + if (query.mode === "address" && query.address) return query.address; + if (query.mode === "block_plot" && query.block) { + return query.plot + ? `גוש ${query.block} חלקה ${query.plot}` + : `גוש ${query.block}`; + } + return null; +} + function useDeals(query: SearchQuery | null) { + const address = dealsSearchAddress(query); return useQuery({ - queryKey: ["deals", query], + queryKey: ["deals", address], queryFn: () => api.searchDeals({ - address: query!.address!, + address: address!, years_back: 3, radius_meters: 100, max_deals: 50, }), - enabled: !!query && query.mode === "address" && !!query.address, + enabled: !!address, }); } @@ -191,7 +208,7 @@ export default function App() { )} {!deals.isFetching && !deals.error && !deals.data && (
- חיפוש עסקאות זמין רק לפי כתובת. + חיפוש עסקאות זמין לפי כתובת או גוש+חלקה. חיפוש לפי שם שמאי מציג רק החלטות שמאי.
)}