- Add grid/map view toggle on /du-an listing page with Mapbox project markers - Enhance du-an detail with master plan viewer, neighborhood radar chart, POI map, and price history chart - Create neighborhood component suite: radar chart (Recharts), POI map (Mapbox), score badges - Add du-an API client, server-side fetching, and React Query hooks - Wire NotificationBell into public layout header for authenticated users - Fix missing PROJECT_STATUS_COLORS import in du-an detail client Co-Authored-By: Paperclip <noreply@paperclip.ing>
40 lines
1.1 KiB
TypeScript
40 lines
1.1 KiB
TypeScript
import { useQuery } from '@tanstack/react-query';
|
|
import {
|
|
duAnApi,
|
|
type SearchProjectsParams,
|
|
} from '@/lib/du-an-api';
|
|
|
|
export const projectKeys = {
|
|
all: ['projects'] as const,
|
|
search: (params: SearchProjectsParams) => ['projects', 'search', params] as const,
|
|
detail: (slug: string) => ['projects', 'detail', slug] as const,
|
|
linkedListings: (projectId: string, page: number) =>
|
|
['projects', 'listings', projectId, page] as const,
|
|
};
|
|
|
|
export function useProjectsSearch(params: SearchProjectsParams = {}) {
|
|
return useQuery({
|
|
queryKey: projectKeys.search(params),
|
|
queryFn: () => duAnApi.search(params),
|
|
});
|
|
}
|
|
|
|
export function useProjectDetail(slug: string) {
|
|
return useQuery({
|
|
queryKey: projectKeys.detail(slug),
|
|
queryFn: () => duAnApi.getBySlug(slug),
|
|
enabled: !!slug,
|
|
});
|
|
}
|
|
|
|
export function useProjectLinkedListings(
|
|
projectId: string,
|
|
page: number = 1,
|
|
) {
|
|
return useQuery({
|
|
queryKey: projectKeys.linkedListings(projectId, page),
|
|
queryFn: () => duAnApi.getLinkedListings(projectId, { page, limit: 12 }),
|
|
enabled: !!projectId,
|
|
});
|
|
}
|