Collection: new widget to add book to collection

This commit is contained in:
2026-04-04 23:15:44 +02:00
parent c7abbfe4d4
commit 2552ba8e94
11 changed files with 279 additions and 16 deletions

View File

@@ -130,6 +130,14 @@ export function postCollection(collection) {
return genericPayloadCall('/ws/collection', collection, 'POST')
}
export function postCollectionAddBook(collectionId, bookId) {
return genericPayloadCall(
'/ws/collection/' + collectionId + '/addbook',
{ bookId: bookId },
'POST',
)
}
export function putBook(id, book) {
return genericPayloadCall('/ws/book/edit/' + id, book.value, 'PUT')
}
@@ -219,10 +227,9 @@ export function genericPayloadCall(apiRoute, object, method) {
}
export function extractFormErrorFromField(fieldName, errors) {
if (errors == null) {
if (errors == null || typeof errors == 'undefined' || !Array.isArray(errors)) {
return ''
}
console.log(errors.value)
const titleErr = errors.find((e) => e['field'] === fieldName)
if (typeof titleErr !== 'undefined') {
return titleErr.error