feat: add hub
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
export default defineAppConfig({
|
||||
hub: {
|
||||
wishlist: { title: 'Wunschzettel', icon: 'i-lucide-gift', to: '/wishlist' }
|
||||
}
|
||||
})
|
||||
@@ -1,5 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
useHead({ title: 'Wunschzettel', htmlAttrs: { lang: 'de' } })
|
||||
useHead({ title: 'Wunschzettel' })
|
||||
|
||||
const search = ref('')
|
||||
const sort = ref<WishlistSort>('title')
|
||||
@@ -35,8 +35,11 @@ onBeforeUnmount(() => observer?.disconnect())
|
||||
Überrasch mich gern auch mit etwas, das hier nicht zu finden ist <3
|
||||
</p>
|
||||
</div>
|
||||
<div ref="headerControls" class="hidden w-96 sm:block">
|
||||
<WishlistControls v-model:search="search" v-model:sort="sort" />
|
||||
<div class="flex shrink-0 items-center gap-2">
|
||||
<div ref="headerControls" class="hidden w-96 sm:block">
|
||||
<WishlistControls v-model:search="search" v-model:sort="sort" />
|
||||
</div>
|
||||
<AppHeaderActions />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -9,13 +9,13 @@ export default defineEventHandler(async (event) => {
|
||||
const id = Number(getRouterParam(event, 'id'))
|
||||
const body = coverSchema.safeParse(await readBody(event))
|
||||
if (!Number.isInteger(id) || !body.success) {
|
||||
throw createError({ statusCode: 400, statusMessage: 'Invalid cover' })
|
||||
throw createError({ statusCode: 400, statusMessage: 'Ungültiges Cover' })
|
||||
}
|
||||
|
||||
const table = wishlistTable(event)
|
||||
const rows = await listRows<WishlistRow>(event, table)
|
||||
const row = rows.find(row => row.id === id)
|
||||
if (!row) throw createError({ statusCode: 404, statusMessage: 'No such book' })
|
||||
if (!row) throw createError({ statusCode: 404, statusMessage: 'Buch nicht gefunden' })
|
||||
if (row.cover) return toWishlistBook(row)
|
||||
|
||||
return toWishlistBook(await updateRow<WishlistRow>(event, table, id, { cover: body.data.cover }))
|
||||
|
||||
@@ -24,7 +24,7 @@ export async function wishlistBooksTable(event: H3Event): Promise<string> {
|
||||
const fields = await listFields<Field>(event, wishlistTable(event))
|
||||
const id = fields.find(field => field.name === 'books')?.link_row_table_id
|
||||
if (!id) {
|
||||
throw createError({ statusCode: 500, statusMessage: 'The wishlist table has no "books" link field' })
|
||||
throw createError({ statusCode: 500, statusMessage: 'Die Wunschzettel-Tabelle hat kein Verknüpfungsfeld "books"' })
|
||||
}
|
||||
booksTable = String(id)
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ export interface WishlistRow {
|
||||
export function wishlistTable(event: H3Event): string {
|
||||
const { baserowWishlistTableId } = useRuntimeConfig(event)
|
||||
if (!baserowWishlistTableId) {
|
||||
throw createError({ statusCode: 500, statusMessage: 'NUXT_BASEROW_WISHLIST_TABLE_ID is not set' })
|
||||
throw createError({ statusCode: 500, statusMessage: 'NUXT_BASEROW_WISHLIST_TABLE_ID ist nicht gesetzt' })
|
||||
}
|
||||
return baserowWishlistTableId
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user