Add author books list
This commit is contained in:
@@ -2,29 +2,38 @@
|
||||
import { ref } from 'vue'
|
||||
import { getAuthor } from './api.js'
|
||||
import { onBeforeRouteUpdate } from 'vue-router'
|
||||
import SearchBook from './SearchBook.vue'
|
||||
|
||||
|
||||
const props = defineProps({
|
||||
id: String
|
||||
});
|
||||
|
||||
let data = ref(null);
|
||||
let error = ref(null);
|
||||
let author = ref(null);
|
||||
let authorfetcherror = ref(null);
|
||||
|
||||
getAuthor(data, error, props.id);
|
||||
getAuthor(author, authorfetcherror, props.id);
|
||||
|
||||
onBeforeRouteUpdate(async (to, from) => {
|
||||
getAuthor(data, error, to.params.id);
|
||||
getAuthor(author, authorfetcherror, to.params.id);
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div v-if="error">{{$t('authorform.error', {err: error.message})}}</div>
|
||||
<div v-if="data">
|
||||
<h3 class="title">{{data.name}}</h3>
|
||||
<p v-if="data.description">{{data.description}}</p>
|
||||
<div v-if="authorfetcherror">{{$t('authorform.error', {err: authorfetcherror.message})}}</div>
|
||||
<div v-if="author">
|
||||
<h3 class="title">{{author.name}}</h3>
|
||||
<p v-if="author.description">{{author.description}}</p>
|
||||
</div>
|
||||
<div class="authorbooks mt-5">
|
||||
<SearchBook :author-id="id"/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
|
||||
.authorbooks {
|
||||
border: solid;
|
||||
border-radius: 50px;
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user