wrongmove/frontend/src/services/taskService.ts
Viktor Barzin eafbc1ac52
Flatten repo structure: move crawler/ to root, remove vqa/ and immoweb/
The crawler subdirectory was the only active project. Moving it to the
repo root simplifies paths and removes the unnecessary nesting. The
vqa/ and immoweb/ directories were legacy/unused and have been removed.

Updated .drone.yml, .gitignore, .claude/ docs, and skills to reflect
the new flat structure.
2026-02-07 23:01:20 +00:00

58 lines
1.4 KiB
TypeScript

// Task service for fetching task status
import type { AuthUser } from '@/auth/types';
import type { TaskStatusResponse } from '@/types';
import { apiRequest } from './apiClient';
import { API_ENDPOINTS } from '@/constants';
export interface CancelTaskResponse {
success: boolean;
message: string;
}
export interface ClearAllTasksResponse {
success: boolean;
count: number;
message: string;
}
/**
* Fetch all active tasks for the current user
*/
export async function fetchTasksForUser(user: AuthUser): Promise<string[]> {
return apiRequest<string[]>(user, API_ENDPOINTS.TASKS_FOR_USER);
}
/**
* Fetch the status of a specific task
*/
export async function fetchTaskStatus(
user: AuthUser,
taskId: string
): Promise<TaskStatusResponse> {
return apiRequest<TaskStatusResponse>(user, API_ENDPOINTS.TASK_STATUS, {
params: { task_id: taskId },
});
}
/**
* Cancel a running task
*/
export async function cancelTask(
user: AuthUser,
taskId: string
): Promise<CancelTaskResponse> {
return apiRequest<CancelTaskResponse>(user, API_ENDPOINTS.CANCEL_TASK, {
method: 'POST',
params: { task_id: taskId },
});
}
/**
* Clear all tasks for the current user
*/
export async function clearAllTasks(user: AuthUser): Promise<ClearAllTasksResponse> {
return apiRequest<ClearAllTasksResponse>(user, API_ENDPOINTS.CLEAR_ALL_TASKS, {
method: 'POST',
});
}