diff --git a/components.d.ts b/components.d.ts index 8be9c7b..689faee 100644 --- a/components.d.ts +++ b/components.d.ts @@ -28,8 +28,6 @@ declare module 'vue' { IconToggleOn: typeof import('./src/components/icons/IconToggleOn.vue')['default'] ImagePreview: typeof import('./src/components/ImagePreview.vue')['default'] ImageTile: typeof import('./src/components/ImageTile.vue')['default'] - 'ImageTile copy': typeof import('./src/components/ImageTile copy.vue')['default'] - ImageTilePlaceholder: typeof import('./src/components/ImageTilePlaceholder.vue')['default'] InputFile: typeof import('./src/components/InputFile.vue')['default'] InputText: typeof import('./src/components/InputText.vue')['default'] InputTextArea: typeof import('./src/components/InputTextArea.vue')['default'] @@ -39,4 +37,4 @@ declare module 'vue' { } } -export {} +export { } diff --git a/src/api/routes/utils/opengraph.ts b/src/api/routes/utils/opengraph.ts index 713e540..7f82244 100644 --- a/src/api/routes/utils/opengraph.ts +++ b/src/api/routes/utils/opengraph.ts @@ -24,7 +24,7 @@ export const fetchOpenGraph = { properties: { title: { type: 'string' }, description: { type: 'string' }, - image: { type: 'string' }, + imageSrc: { type: 'string' }, }, }, }, @@ -42,7 +42,7 @@ export const fetchOpenGraph = { reply.send({ title: result.ogTitle || '', description: result.ogDescription || '', - image, + imageSrc: image, }) } }, diff --git a/src/composables/useWishlistStore.ts b/src/composables/useWishlistStore.ts index 789927a..c42cd1e 100644 --- a/src/composables/useWishlistStore.ts +++ b/src/composables/useWishlistStore.ts @@ -47,8 +47,11 @@ const deleteWishlist = async (): Promise => { } } -const createItem = async (values: WishlistItem): Promise => { - const id = state.value?.id +const createItem = async ( + values: WishlistItem, + wishlistId?: string +): Promise => { + const id = wishlistId || state.value?.id const payload = { ...values, } diff --git a/src/config/locales/de-DE.json b/src/config/locales/de-DE.json index 2ae57e6..ac961dc 100644 --- a/src/config/locales/de-DE.json +++ b/src/config/locales/de-DE.json @@ -62,6 +62,17 @@ "text": "Erstelle eine Wunschliste" } }, + "create-wishlist-item-view": { + "title": { + "text": "Eintrag hinzufügen" + }, + "loading": { + "text": "Lade Daten der übermittelten URL" + }, + "headline-wishlist-selection": { + "text": "Zu welcher Wunschliste möchten Sie etwas hinzufügen?" + } + }, "detail-view": { "main": { "empty-list": { diff --git a/src/config/locales/en-US.json b/src/config/locales/en-US.json index a283f0a..19f6c67 100644 --- a/src/config/locales/en-US.json +++ b/src/config/locales/en-US.json @@ -54,6 +54,17 @@ } } }, + "create-wishlist-item-view": { + "title": { + "text": "Add item" + }, + "loading": { + "text": "Loading data from provided URL" + }, + "headline-wishlist-selection": { + "text": "To which wish list would you like to add the new item?" + } + }, "create-wishlist-view": { "title": { "text": "Create a wishlist" diff --git a/src/router/index.ts b/src/router/index.ts index 649f2cc..9b892ec 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -2,7 +2,10 @@ import { createRouter, createWebHistory } from 'vue-router' import HomeView from '@/views/HomeView.vue' import LoginView from '@/views/LoginView.vue' import CreateWishlistView from '@/views/CreateWishlistView.vue' +import AddWishlistItemView from '@/views/AddWishlistItemView.vue' import DetailView from '@/views/DetailView.vue' +import { useAuth } from '@/composables' +const { isAuthenticated } = useAuth() const router = createRouter({ history: createWebHistory(import.meta.env.BASE_URL), @@ -11,28 +14,45 @@ const router = createRouter({ path: '/', name: 'home', component: HomeView, + meta: { requiresAuth: false }, }, { path: '/login', name: 'login', component: LoginView, + meta: { requiresAuth: false }, }, { path: '/create-wishlist', name: 'create-wishlist', component: CreateWishlistView, + meta: { requiresAuth: true }, + }, + { + path: '/add-wishlist-item', + name: 'add-wishlist--item', + component: AddWishlistItemView, + meta: { requiresAuth: true }, }, { path: '/:slug', name: 'detail', component: DetailView, + meta: { requiresAuth: false }, }, { name: 'notFound', path: '/:pathMatch(.*)*', component: () => import('@/views/NotFoundView.vue'), + meta: { requiresAuth: false }, }, ], }) +router.beforeEach((to, from) => { + if (!isAuthenticated.value && to.meta.requiresAuth === true) { + return { name: 'login' } + } +}) + export default router diff --git a/src/types.ts b/src/types.ts index c5d1cc3..e40d023 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,11 +1,11 @@ export interface WishlistItem { - id: number + id?: number title: string url: string imageSrc: string description: string bought: boolean - wishlistId: boolean + wishlistId?: boolean } export interface Wishlist { id?: string diff --git a/src/views/AddWishlistItemView.vue b/src/views/AddWishlistItemView.vue new file mode 100644 index 0000000..483a12e --- /dev/null +++ b/src/views/AddWishlistItemView.vue @@ -0,0 +1,103 @@ + + +