From 32d39cabcd895a298229a6b9fea2d2334fabb003 Mon Sep 17 00:00:00 2001 From: Arthur Lefebvre Date: Tue, 31 Mar 2026 17:35:32 +0200 Subject: [PATCH] Add existing book fields in "create book" form --- front/src/AddBook.vue | 90 +++++++++++++++++++++++++++++- front/src/api.js | 5 +- front/src/locales/en.json | 2 + front/src/locales/fr.json | 2 + internal/apitest/post_book_test.go | 47 +++++++++++++++- internal/dto/in.go | 11 +++- internal/routes/bookpostcreate.go | 24 +++++--- 7 files changed, 162 insertions(+), 19 deletions(-) diff --git a/front/src/AddBook.vue b/front/src/AddBook.vue index 7de5dcf..b5d141f 100644 --- a/front/src/AddBook.vue +++ b/front/src/AddBook.vue @@ -9,6 +9,11 @@ const router = useRouter() const book = ref({ title: '', author: '', + isbn: '', + inventaireid: '', + openlibraryid: '', + shortdescription: '', + summary: '', coverId: null, }) const errors = ref(null) @@ -18,11 +23,26 @@ const titleError = computed(() => { const authorError = computed(() => { return extractFormErrorFromField('Author', errors.value) }) +const isbnError = computed(() => { + return extractFormErrorFromField('ISBN', errors.value) +}) +const inventaireError = computed(() => { + return extractFormErrorFromField('InventaireID', errors.value) +}) +const openLibraryError = computed(() => { + return extractFormErrorFromField('OpenLibraryId', errors.value) +}) +const shortDescError = computed(() => { + return extractFormErrorFromField('ShortDescription', errors.value) +}) +const summaryError = computed(() => { + return extractFormErrorFromField('ShortDescription', errors.value) +}) function onSubmit(e) { postBook(book).then((res) => { if (res.ok) { - router.push('/') + res.json().then((json) => router.push('/book/' + json.id)) return } else { res.json().then((json) => (errors.value = json)) @@ -37,7 +57,7 @@ function onSubmit(e) {
{{ $t('addbook.author') }}

{{ authorError }}

+
+ +
+ +
+

{{ shortDescError }}

+
+
+ +
+