feat(web): complete du-an project pages, neighborhood components, and public notification bell
- 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>
This commit is contained in:
39
apps/web/lib/hooks/use-du-an.ts
Normal file
39
apps/web/lib/hooks/use-du-an.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
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,
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user