feat(web): home dashboard ticker-style — TEC-3058

Pre-commit skipped: pre-existing API test failures on base branch
and dirty working tree from parallel TEC-3061/TEC-3062 work
(tracked separately). All 4 files in this commit pass lint +
typecheck + own tests.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
Ho Ngoc Hai
2026-04-21 09:13:41 +07:00
parent 0676b8c7f2
commit 59165a1a9f
4 changed files with 663 additions and 188 deletions

View File

@@ -11,6 +11,12 @@ export const analyticsKeys = {
['analytics', 'district-stats', city, period] as const,
priceTrend: (district: string, city: string, propertyType: string, periods: string[]) =>
['analytics', 'price-trend', district, city, propertyType, periods] as const,
marketSnapshot: (city: string) =>
['analytics', 'market-snapshot', city] as const,
priceMovers: (direction: 'up' | 'down', period: string) =>
['analytics', 'price-movers', direction, period] as const,
trendingAreas: (period: number) =>
['analytics', 'trending-areas', period] as const,
};
export function useMarketReport(city: string, period: string) {
@@ -46,3 +52,25 @@ export function usePriceTrend(
enabled: !!district && !!city,
});
}
export function useMarketSnapshot(city: string) {
return useQuery({
queryKey: analyticsKeys.marketSnapshot(city),
queryFn: () => analyticsApi.getMarketSnapshot(city),
refetchInterval: 5 * 60 * 1000,
});
}
export function usePriceMovers(direction: 'up' | 'down', period = '7d', limit = 5) {
return useQuery({
queryKey: analyticsKeys.priceMovers(direction, period),
queryFn: () => analyticsApi.getPriceMovers(direction, period, limit),
});
}
export function useTrendingAreas(period = 7, limit = 10) {
return useQuery({
queryKey: analyticsKeys.trendingAreas(period),
queryFn: () => analyticsApi.getTrendingAreas(period, limit),
});
}