Changed design language. Added editions, better support for authors. Base for file handling
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
import type { BookFile } from '../types'
|
||||
|
||||
export function fetchBookFiles(bookId: number): Promise<BookFile[]> {
|
||||
return fetch(`/api/books/${bookId}/files`).then(r => r.json())
|
||||
}
|
||||
|
||||
export function fetchUnmatchedFiles(): Promise<BookFile[]> {
|
||||
return fetch('/api/files?unmatched=true').then(r => r.json())
|
||||
}
|
||||
|
||||
export function assignFile(id: number, bookId: number | null, editionId: number | null): Promise<BookFile> {
|
||||
return fetch(`/api/files/${id}`, {
|
||||
method: 'PATCH',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ bookId, editionId }),
|
||||
}).then(r => r.json())
|
||||
}
|
||||
|
||||
export function deleteFile(id: number): Promise<void> {
|
||||
return fetch(`/api/files/${id}`, { method: 'DELETE' }).then(() => undefined)
|
||||
}
|
||||
|
||||
export function triggerScan(): Promise<void> {
|
||||
return fetch('/api/scan', { method: 'POST' }).then(() => undefined)
|
||||
}
|
||||
Reference in New Issue
Block a user