added rating books

This commit is contained in:
2025-10-29 22:38:38 +01:00
parent b4df375e4c
commit 26df6417b1
14 changed files with 353 additions and 153 deletions

View File

@@ -42,11 +42,15 @@ export function getBook(id) {
}
export function postBook(book) {
return genericPostCall('/book', book.value)
return genericPayloadCall('/book', book.value, 'POST')
}
export async function postReadBook(userbook) {
return genericPostCall('/book/read', userbook)
export async function putReadBook(bookId) {
return putBookUpdate(bookId, {read: true})
}
export async function putBookUpdate(bookId, payload) {
return genericPayloadCall('/book/' + bookId, payload, 'PUT')
}
export function postLogin(user) {
@@ -84,12 +88,12 @@ export function genericPostCallNoAuth(apiRoute, object) {
})
}
export function genericPostCall(apiRoute, object) {
export function genericPayloadCall(apiRoute, object, method) {
const { user } = useAuthStore();
if (user != null) {
return fetch(baseUrl + apiRoute, {
method: 'POST',
method: method,
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer ' + user.token