Integrate users and books
- new table userbook linking users and book - moved rating to users book - updated demo data and tests - updated front to hide routes from non connected users
This commit is contained in:
@@ -17,15 +17,12 @@
|
||||
<RouterLink to="/" class="navbar-item" activeClass="is-active">
|
||||
Home
|
||||
</RouterLink>
|
||||
<RouterLink to="/add" class="navbar-item" activeClass="is-active">
|
||||
<RouterLink v-if="authStore.user" to="/add" class="navbar-item" activeClass="is-active">
|
||||
Add Book
|
||||
</RouterLink>
|
||||
<a class="navbar-item">
|
||||
Books
|
||||
</a>
|
||||
<a class="navbar-item">
|
||||
Locations
|
||||
</a>
|
||||
<RouterLink v-if="authStore.user" to="/books" class="navbar-item" activeClass="is-active">
|
||||
My Books
|
||||
</RouterLink>
|
||||
</div>
|
||||
<div class="navbar-end">
|
||||
</div>
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<script setup>
|
||||
import BookCard from './BookCard.vue';
|
||||
import { getBooks } from './api.js'
|
||||
import { getMyBooks } from './api.js'
|
||||
|
||||
const { data, error } = getBooks();
|
||||
const { data, error } = getMyBooks();
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
19
front/src/Home.vue
Normal file
19
front/src/Home.vue
Normal file
@@ -0,0 +1,19 @@
|
||||
<script setup>
|
||||
import { useAuthStore } from './auth.store.js'
|
||||
|
||||
const authStore = useAuthStore();
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div v-if="authStore.user">
|
||||
Welcome {{ authStore.user.username }} !
|
||||
</div>
|
||||
<div v-else>
|
||||
Welcome to PersonalLibraryManager. Please login ou sign in to continue.
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
||||
<style scoped>
|
||||
</style>
|
||||
@@ -24,8 +24,8 @@ function useFetch(url) {
|
||||
return { data, error }
|
||||
}
|
||||
|
||||
export function getBooks() {
|
||||
return useFetch(baseUrl + '/books');
|
||||
export function getMyBooks() {
|
||||
return useFetch(baseUrl + '/mybooks');
|
||||
}
|
||||
|
||||
export function postBook(book) {
|
||||
|
||||
@@ -6,10 +6,12 @@ import BooksBrowser from './BooksBrowser.vue'
|
||||
import AddBook from './AddBook.vue'
|
||||
import SignUp from './SignUp.vue'
|
||||
import LogIn from './LogIn.vue'
|
||||
import Home from './Home.vue'
|
||||
|
||||
|
||||
const routes = [
|
||||
{ path: '/', component: BooksBrowser },
|
||||
{ path: '/', component: Home },
|
||||
{ path: '/books', component: BooksBrowser },
|
||||
{ path: '/add', component: AddBook },
|
||||
{ path: '/signup', component: SignUp },
|
||||
{ path: '/login', component: LogIn },
|
||||
|
||||
Reference in New Issue
Block a user