diff --git a/frontend/src/services/decisionService.ts b/frontend/src/services/decisionService.ts new file mode 100644 index 0000000..db16dee --- /dev/null +++ b/frontend/src/services/decisionService.ts @@ -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 { + return apiRequest(user, '/api/decisions'); +} + +export async function setDecision( + user: AuthUser, + listingId: number, + decision: 'liked' | 'disliked', + listingType: 'RENT' | 'BUY' = 'RENT', +): Promise { + return apiRequest(user, `/api/decisions/${listingId}`, { + method: 'PUT', + body: { decision, listing_type: listingType }, + }); +} + +export async function clearDecision( + user: AuthUser, + listingId: number, + listingType: 'RENT' | 'BUY' = 'RENT', +): Promise { + await apiRequest(user, `/api/decisions/${listingId}`, { + method: 'DELETE', + params: { listing_type: listingType }, + }); +} diff --git a/frontend/src/services/index.ts b/frontend/src/services/index.ts index 775123c..25113bc 100644 --- a/frontend/src/services/index.ts +++ b/frontend/src/services/index.ts @@ -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'; diff --git a/frontend/src/types/index.ts b/frontend/src/types/index.ts index aa2e51b..163eee1 100644 --- a/frontend/src/types/index.ts +++ b/frontend/src/types/index.ts @@ -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; +}