Feat: enable deals search by gush+plot
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) <noreply@anthropic.com>
This commit is contained in:
+21
-4
@@ -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) {
|
function useDeals(query: SearchQuery | null) {
|
||||||
|
const address = dealsSearchAddress(query);
|
||||||
return useQuery({
|
return useQuery({
|
||||||
queryKey: ["deals", query],
|
queryKey: ["deals", address],
|
||||||
queryFn: () =>
|
queryFn: () =>
|
||||||
api.searchDeals({
|
api.searchDeals({
|
||||||
address: query!.address!,
|
address: address!,
|
||||||
years_back: 3,
|
years_back: 3,
|
||||||
radius_meters: 100,
|
radius_meters: 100,
|
||||||
max_deals: 50,
|
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 && (
|
{!deals.isFetching && !deals.error && !deals.data && (
|
||||||
<div className="text-center py-12 text-muted-foreground">
|
<div className="text-center py-12 text-muted-foreground">
|
||||||
חיפוש עסקאות זמין רק לפי כתובת.
|
חיפוש עסקאות זמין לפי כתובת או גוש+חלקה. חיפוש לפי שם שמאי מציג רק החלטות שמאי.
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</TabsContent>
|
</TabsContent>
|
||||||
|
|||||||
Reference in New Issue
Block a user