feat: add comparison workspace
This commit is contained in:
@@ -288,6 +288,42 @@ export type NeighborhoodDetail = {
|
||||
watchlist_items: WatchlistItem[];
|
||||
};
|
||||
|
||||
export type ComparisonMetricValue = {
|
||||
id: string;
|
||||
value: number | null;
|
||||
};
|
||||
|
||||
export type ComparisonMetric = {
|
||||
key: string;
|
||||
label: string;
|
||||
unit: string;
|
||||
direction: "higher" | "lower" | "neutral";
|
||||
values: ComparisonMetricValue[];
|
||||
};
|
||||
|
||||
export type AreaComparison = {
|
||||
month: string;
|
||||
requested_ids: string[];
|
||||
missing_ids: string[];
|
||||
items: AreaScore[];
|
||||
metrics: ComparisonMetric[];
|
||||
};
|
||||
|
||||
export type NeighborhoodComparisonItem = NeighborhoodScore & {
|
||||
built_year: number | null;
|
||||
property_type: string;
|
||||
metro_distance_m: number | null;
|
||||
school_quality: string | null;
|
||||
};
|
||||
|
||||
export type NeighborhoodComparison = {
|
||||
month: string;
|
||||
requested_ids: string[];
|
||||
missing_ids: string[];
|
||||
items: NeighborhoodComparisonItem[];
|
||||
metrics: ComparisonMetric[];
|
||||
};
|
||||
|
||||
const API_BASE_URL =
|
||||
process.env.NEXT_PUBLIC_API_BASE_URL?.replace(/\/$/, "") ?? "http://127.0.0.1:8080";
|
||||
|
||||
@@ -318,6 +354,24 @@ export async function fetchNeighborhoodDetail(
|
||||
);
|
||||
}
|
||||
|
||||
export async function fetchAreaComparison(
|
||||
areaIds: string[],
|
||||
month: string,
|
||||
): Promise<AreaComparison> {
|
||||
return fetchJson(
|
||||
`/api/v1/compare/areas?month=${encodeURIComponent(month)}&ids=${encodeURIComponent(areaIds.join(","))}`,
|
||||
);
|
||||
}
|
||||
|
||||
export async function fetchNeighborhoodComparison(
|
||||
neighborhoodIds: string[],
|
||||
month: string,
|
||||
): Promise<NeighborhoodComparison> {
|
||||
return fetchJson(
|
||||
`/api/v1/compare/neighborhoods?month=${encodeURIComponent(month)}&ids=${encodeURIComponent(neighborhoodIds.join(","))}`,
|
||||
);
|
||||
}
|
||||
|
||||
export async function fetchWatchlistItems(): Promise<WatchlistItem[]> {
|
||||
return fetchJson("/api/v1/watchlist");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user