Added inventaire import from ISBN
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<script setup>
|
||||
import { ref, computed } from 'vue'
|
||||
import { putReadBook, getImagePathOrDefault } from './api.js'
|
||||
import { putReadBook, getImagePathOrDefault, postImportBook } from './api.js'
|
||||
import { useRouter } from 'vue-router'
|
||||
|
||||
const router = useRouter();
|
||||
@@ -8,6 +8,7 @@
|
||||
const props = defineProps({
|
||||
id: Number,
|
||||
inventaireid: String,
|
||||
isinventaireedition: Boolean,
|
||||
title: String,
|
||||
author: String,
|
||||
description: String,
|
||||
@@ -19,20 +20,32 @@
|
||||
const imagePathOrDefault = computed(() => getImagePathOrDefault(props.coverPath));
|
||||
const error = ref(null)
|
||||
|
||||
async function onUserBookRead() {
|
||||
const res = await putReadBook(props.id);
|
||||
if (res.ok) {
|
||||
router.push('/books')
|
||||
} else {
|
||||
res.json().then((json) => (error.value = json));
|
||||
async function onUserBookRead() {
|
||||
const res = await putReadBook(props.id);
|
||||
if (res.ok) {
|
||||
router.push('/books')
|
||||
} else {
|
||||
res.json().then((json) => (error.value = json));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function openBook() {
|
||||
if (props.id != 0) {
|
||||
router.push(`/book/${props.id}`);
|
||||
async function openBook() {
|
||||
if (props.id != 0) {
|
||||
router.push(`/book/${props.id}`);
|
||||
} else if (props.isinventaireedition) {
|
||||
importInventaireEdition()
|
||||
} else if (props.inventaireid != "") {
|
||||
router.push(`/import/inventaire/${props.inventaireid}`)
|
||||
}
|
||||
}
|
||||
|
||||
async function importInventaireEdition(inventaireid) {
|
||||
const res = await postImportBook(props.inventaireid, navigator.language.substring(0,2));
|
||||
const json = await res.json();
|
||||
if (res.ok) {
|
||||
router.push(`/book/${json.id}`);
|
||||
} else {
|
||||
router.push(`/import/inventaire/${props.inventaireid}`)
|
||||
error.value = json;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user