diff --git a/src/components/AdminPage.vue b/src/components/AdminPage.vue index 9226ef5..97d9476 100644 --- a/src/components/AdminPage.vue +++ b/src/components/AdminPage.vue @@ -1,4 +1,175 @@ - + + + + diff --git a/src/components/BookListPage.test.ts b/src/components/BookListPage.test.ts index 898e987..45fe3a0 100644 --- a/src/components/BookListPage.test.ts +++ b/src/components/BookListPage.test.ts @@ -5,6 +5,10 @@ import * as booksApi from '../services/booksApi' import BookListPage from './BookListPage.vue' vi.mock('../services/booksApi') +vi.mock('../composables/useAuth', () => ({ + useAuth: () => ({ user: { value: null }, logout: vi.fn() }), + authedFetch: vi.fn(), +})) describe('BookListPage', () => { beforeEach(() => { diff --git a/src/components/BookListPage.vue b/src/components/BookListPage.vue index 38d39c9..a4b3e49 100644 --- a/src/components/BookListPage.vue +++ b/src/components/BookListPage.vue @@ -2,10 +2,12 @@ import { onMounted, ref } from 'vue' import * as booksApi from '../services/booksApi' import type { BookSummary } from '../services/booksApi' +import { useAuth } from '../composables/useAuth' type LoadStatus = 'loading' | 'loaded' | 'error' -const emit = defineEmits<{ open: [id: string] }>() +const emit = defineEmits<{ open: [id: string]; admin: [] }>() +const { user, logout } = useAuth() const books = ref([]) const loadStatus = ref('loading') @@ -102,7 +104,13 @@ async function removeBook(book: BookSummary): Promise { + +