feat: add frontend decision service and types
This commit is contained in:
parent
3d2a24e921
commit
813f048e46
3 changed files with 45 additions and 0 deletions
32
frontend/src/services/decisionService.ts
Normal file
32
frontend/src/services/decisionService.ts
Normal 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 },
|
||||
});
|
||||
}
|
||||
|
|
@ -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';
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue