- StatusBadge component with 6 lifecycle states, compact/full variants, tooltip (#215) - DocsLibraryPage: table (Name/Status/Stores/Updated), empty state (#211) - Filter bar: status pills, store chips, debounced search, URL sync (#212) - Multi-select with sticky bulk bar: Re-chunk, Push to store modal, Delete (#213) - DocsNewPage: multi-file drop zone with per-file progress, sequential upload (#214) - Document.stores?: string[] field, formatRelativeTime(iso, locale) helper - rechunkDocument / pushDocumentToStore API + store actions (rechunk / pushToStore) - i18n keys status.*, docs.*, docsNew.* in FR + EN Closes #211, Closes #212, Closes #213, Closes #214, Closes #215
39 lines
1.2 KiB
TypeScript
39 lines
1.2 KiB
TypeScript
import type { Document } from '../../shared/types'
|
|
import { apiFetch } from '../../shared/api/http'
|
|
|
|
export function fetchDocuments(): Promise<Document[]> {
|
|
return apiFetch<Document[]>('/api/documents')
|
|
}
|
|
|
|
export function fetchDocument(id: string): Promise<Document> {
|
|
return apiFetch<Document>(`/api/documents/${id}`)
|
|
}
|
|
|
|
export async function uploadDocument(file: File): Promise<Document> {
|
|
const formData = new FormData()
|
|
formData.append('file', file)
|
|
return apiFetch<Document>('/api/documents/upload', {
|
|
method: 'POST',
|
|
body: formData,
|
|
skipContentType: true,
|
|
})
|
|
}
|
|
|
|
export function deleteDocument(id: string): Promise<unknown> {
|
|
return apiFetch(`/api/documents/${id}`, { method: 'DELETE' })
|
|
}
|
|
|
|
export function getPreviewUrl(id: string, page = 1, dpi = 150): string {
|
|
return `/api/documents/${id}/preview?page=${page}&dpi=${dpi}`
|
|
}
|
|
|
|
export function rechunkDocument(id: string): Promise<{ jobId: string }> {
|
|
return apiFetch<{ jobId: string }>(`/api/documents/${id}/rechunk`, { method: 'POST' })
|
|
}
|
|
|
|
export function pushDocumentToStore(id: string, store: string): Promise<{ jobId: string }> {
|
|
return apiFetch<{ jobId: string }>(`/api/documents/${id}/push`, {
|
|
method: 'POST',
|
|
body: JSON.stringify({ store }),
|
|
})
|
|
}
|