- Add interactive Mapbox map to /khu-cong-nghiep landing page with park markers and popups - Build compare page at /khu-cong-nghiep/so-sanh with recharts RadarChart and detailed comparison table - Build listing search page at /khu-cong-nghiep/cho-thue with filters for property type, lease type, area, and price - Add IndustrialListing types, API client functions, and React Query hooks Co-Authored-By: Paperclip <noreply@paperclip.ing>
63 lines
1.8 KiB
TypeScript
63 lines
1.8 KiB
TypeScript
import { useQuery } from '@tanstack/react-query';
|
|
import {
|
|
industrialApi,
|
|
type SearchIndustrialListingsParams,
|
|
type SearchIndustrialParksParams,
|
|
} from '@/lib/khu-cong-nghiep-api';
|
|
|
|
export const industrialKeys = {
|
|
all: ['industrial'] as const,
|
|
search: (params: SearchIndustrialParksParams) => ['industrial', 'search', params] as const,
|
|
detail: (slug: string) => ['industrial', 'detail', slug] as const,
|
|
stats: () => ['industrial', 'stats'] as const,
|
|
market: () => ['industrial', 'market'] as const,
|
|
compare: (ids: string[]) => ['industrial', 'compare', ids] as const,
|
|
listings: (params: SearchIndustrialListingsParams) => ['industrial', 'listings', params] as const,
|
|
};
|
|
|
|
export function useIndustrialParksSearch(params: SearchIndustrialParksParams = {}) {
|
|
return useQuery({
|
|
queryKey: industrialKeys.search(params),
|
|
queryFn: () => industrialApi.search(params),
|
|
});
|
|
}
|
|
|
|
export function useIndustrialParkDetail(slug: string) {
|
|
return useQuery({
|
|
queryKey: industrialKeys.detail(slug),
|
|
queryFn: () => industrialApi.getBySlug(slug),
|
|
enabled: !!slug,
|
|
});
|
|
}
|
|
|
|
export function useIndustrialStats() {
|
|
return useQuery({
|
|
queryKey: industrialKeys.stats(),
|
|
queryFn: () => industrialApi.getStats(),
|
|
staleTime: 5 * 60 * 1000,
|
|
});
|
|
}
|
|
|
|
export function useIndustrialMarket() {
|
|
return useQuery({
|
|
queryKey: industrialKeys.market(),
|
|
queryFn: () => industrialApi.getMarket(),
|
|
staleTime: 5 * 60 * 1000,
|
|
});
|
|
}
|
|
|
|
export function useIndustrialCompare(ids: string[]) {
|
|
return useQuery({
|
|
queryKey: industrialKeys.compare(ids),
|
|
queryFn: () => industrialApi.compare(ids),
|
|
enabled: ids.length >= 2,
|
|
});
|
|
}
|
|
|
|
export function useIndustrialListingsSearch(params: SearchIndustrialListingsParams = {}) {
|
|
return useQuery({
|
|
queryKey: industrialKeys.listings(params),
|
|
queryFn: () => industrialApi.searchListings(params),
|
|
});
|
|
}
|