- Improved import organization and formatting in PlaylistsPage, RegisterPage, SoundsPage, SettingsPage, and UsersPage for better readability. - Added error handling and user feedback with toast notifications in SoundsPage and SettingsPage. - Enhanced user experience by implementing debounced search functionality in PlaylistsPage and SoundsPage. - Updated the layout and structure of forms in SettingsPage and UsersPage for better usability. - Improved accessibility and semantics by ensuring proper labeling and descriptions in forms. - Fixed minor bugs related to state management and API calls in various components.
59 lines
1.3 KiB
TypeScript
59 lines
1.3 KiB
TypeScript
import { apiClient } from '../client'
|
|
|
|
export interface ExtractionInfo {
|
|
id: number
|
|
url: string
|
|
status: 'pending' | 'processing' | 'completed' | 'failed'
|
|
title?: string
|
|
service?: string
|
|
service_id?: string
|
|
sound_id?: number
|
|
user_id: number
|
|
error?: string
|
|
created_at: string
|
|
updated_at: string
|
|
}
|
|
|
|
export interface CreateExtractionResponse {
|
|
message: string
|
|
extraction: ExtractionInfo
|
|
}
|
|
|
|
export interface GetExtractionsResponse {
|
|
extractions: ExtractionInfo[]
|
|
}
|
|
|
|
export class ExtractionsService {
|
|
/**
|
|
* Create a new extraction job
|
|
*/
|
|
async createExtraction(url: string): Promise<CreateExtractionResponse> {
|
|
const response = await apiClient.post<CreateExtractionResponse>(
|
|
`/api/v1/extractions/?url=${encodeURIComponent(url)}`,
|
|
)
|
|
return response
|
|
}
|
|
|
|
/**
|
|
* Get extraction by ID
|
|
*/
|
|
async getExtraction(extractionId: number): Promise<ExtractionInfo> {
|
|
const response = await apiClient.get<ExtractionInfo>(
|
|
`/api/v1/extractions/${extractionId}`,
|
|
)
|
|
return response
|
|
}
|
|
|
|
/**
|
|
* Get user's extractions
|
|
*/
|
|
async getUserExtractions(): Promise<ExtractionInfo[]> {
|
|
const response = await apiClient.get<GetExtractionsResponse>(
|
|
'/api/v1/extractions/',
|
|
)
|
|
return response.extractions
|
|
}
|
|
}
|
|
|
|
export const extractionsService = new ExtractionsService()
|