feat: add frontend decision service and types

This commit is contained in:
Viktor Barzin 2026-02-21 13:51:12 +00:00
parent 3d2a24e921
commit 813f048e46
No known key found for this signature in database
GPG key ID: 0EB088298288D958
3 changed files with 45 additions and 0 deletions

View file

@ -0,0 +1,32 @@
// Decision API service for managing listing decisions (like/dislike)
import type { AuthUser } from '@/auth/types';
import type { ListingDecision } from '@/types';
import { apiRequest } from './apiClient';
export async function fetchDecisions(user: AuthUser): Promise<ListingDecision[]> {
return apiRequest<ListingDecision[]>(user, '/api/decisions');
}
export async function setDecision(
user: AuthUser,
listingId: number,
decision: 'liked' | 'disliked',
listingType: 'RENT' | 'BUY' = 'RENT',
): Promise<ListingDecision> {
return apiRequest<ListingDecision>(user, `/api/decisions/${listingId}`, {
method: 'PUT',
body: { decision, listing_type: listingType },
});
}
export async function clearDecision(
user: AuthUser,
listingId: number,
listingType: 'RENT' | 'BUY' = 'RENT',
): Promise<void> {
await apiRequest(user, `/api/decisions/${listingId}`, {
method: 'DELETE',
params: { listing_type: listingType },
});
}

View file

@ -5,3 +5,4 @@ export { streamListingGeoJSON, type StreamingProgress } from './streamingService
export { fetchTasksForUser, fetchTaskStatus, cancelTask, clearAllTasks, type CancelTaskResponse, type ClearAllTasksResponse } from './taskService';
export { checkBackendHealth, type HealthStatus, type HealthCheckResult } from './healthService';
export { fetchUserPOIs, createPOI, updatePOI, deletePOI, triggerPOICalculation, fetchPOIDistances } from './poiService';
export { fetchDecisions, setDecision, clearDecision } from './decisionService';

View file

@ -178,3 +178,15 @@ export interface WSPongMessage {
}
export type WSMessage = WSInitMessage | WSTaskUpdateMessage | WSPongMessage;
// Decision types
export type DecisionType = 'liked' | 'disliked';
export interface ListingDecision {
id: number;
listing_id: number;
listing_type: 'RENT' | 'BUY';
decision: DecisionType;
created_at: string;
updated_at: string;
}