Collection: new widget to add book to collection
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user