feat: enhance watchlist workflow
This commit is contained in:
@@ -103,16 +103,58 @@ export type WatchlistItem = {
|
||||
area_id: string | null;
|
||||
target_price_psm: number | null;
|
||||
status: string;
|
||||
label: string;
|
||||
priority: string;
|
||||
trigger_operator: string;
|
||||
trigger_price_psm: number | null;
|
||||
notes: string;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
last_reviewed_at: string | null;
|
||||
};
|
||||
|
||||
export type CreateWatchlistItem = {
|
||||
area_id?: string;
|
||||
neighborhood_id?: string;
|
||||
target_price_psm?: number;
|
||||
label?: string;
|
||||
priority?: string;
|
||||
trigger_operator?: string;
|
||||
trigger_price_psm?: number;
|
||||
notes?: string;
|
||||
};
|
||||
|
||||
export type UpdateWatchlistItem = {
|
||||
target_price_psm?: number;
|
||||
status?: "active" | "paused" | "archived";
|
||||
label?: string;
|
||||
priority?: "low" | "medium" | "high";
|
||||
trigger_operator?: "lte" | "gte";
|
||||
trigger_price_psm?: number;
|
||||
notes?: string;
|
||||
mark_reviewed?: boolean;
|
||||
};
|
||||
|
||||
export type WatchlistEvent = {
|
||||
event_id: number;
|
||||
watchlist_item_id: number;
|
||||
event_type: string;
|
||||
summary: string;
|
||||
created_at: string;
|
||||
};
|
||||
|
||||
export type CreateWatchlistEvent = {
|
||||
event_type: string;
|
||||
summary: string;
|
||||
};
|
||||
|
||||
export type WatchlistFilters = {
|
||||
status?: string;
|
||||
area_id?: string;
|
||||
neighborhood_id?: string;
|
||||
label?: string;
|
||||
};
|
||||
|
||||
export type DataSource = {
|
||||
source_id: number;
|
||||
name: string;
|
||||
@@ -372,8 +414,17 @@ export async function fetchNeighborhoodComparison(
|
||||
);
|
||||
}
|
||||
|
||||
export async function fetchWatchlistItems(): Promise<WatchlistItem[]> {
|
||||
return fetchJson("/api/v1/watchlist");
|
||||
export async function fetchWatchlistItems(
|
||||
filters: WatchlistFilters = {},
|
||||
): Promise<WatchlistItem[]> {
|
||||
const params = new URLSearchParams();
|
||||
for (const [key, value] of Object.entries(filters)) {
|
||||
if (value) {
|
||||
params.set(key, value);
|
||||
}
|
||||
}
|
||||
const query = params.toString();
|
||||
return fetchJson(`/api/v1/watchlist${query ? `?${query}` : ""}`);
|
||||
}
|
||||
|
||||
export async function createWatchlistItem(
|
||||
@@ -391,6 +442,30 @@ export async function archiveWatchlistItem(id: number): Promise<WatchlistItem> {
|
||||
});
|
||||
}
|
||||
|
||||
export async function updateWatchlistItem(
|
||||
id: number,
|
||||
payload: UpdateWatchlistItem,
|
||||
): Promise<WatchlistItem> {
|
||||
return fetchJson(`/api/v1/watchlist/${id}`, {
|
||||
method: "PATCH",
|
||||
body: JSON.stringify(payload),
|
||||
});
|
||||
}
|
||||
|
||||
export async function fetchWatchlistEvents(id: number): Promise<WatchlistEvent[]> {
|
||||
return fetchJson(`/api/v1/watchlist/${id}/events`);
|
||||
}
|
||||
|
||||
export async function createWatchlistEvent(
|
||||
id: number,
|
||||
payload: CreateWatchlistEvent,
|
||||
): Promise<WatchlistEvent> {
|
||||
return fetchJson(`/api/v1/watchlist/${id}/events`, {
|
||||
method: "POST",
|
||||
body: JSON.stringify(payload),
|
||||
});
|
||||
}
|
||||
|
||||
export async function fetchDataSources(): Promise<DataSource[]> {
|
||||
return fetchJson("/api/v1/data-sources");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user