From 12a6757df3e15d7f33d75a9c70aff52b5051f5f5 Mon Sep 17 00:00:00 2001
From: Arthur DANJOU
Date: Thu, 14 Dec 2023 20:12:27 +0100
Subject: [PATCH] Use NuxtUI tabs for my talents and bookmarks page
---
src/pages/bookmarks.vue | 40 +++++++++++++++++++---------------------
src/pages/talents.vue | 41 +++++++++++++++++++++--------------------
2 files changed, 40 insertions(+), 41 deletions(-)
diff --git a/src/pages/bookmarks.vue b/src/pages/bookmarks.vue
index bdb64f8..3850289 100644
--- a/src/pages/bookmarks.vue
+++ b/src/pages/bookmarks.vue
@@ -21,15 +21,20 @@ const {
watch: [isFavorite, getCategory],
})
-function isCategory(category: string) {
- return getCategory.value === category
-}
-
const {
data: getCategories,
} = await useFetch>('/api/categories', { method: 'GET', query: { type: 'BOOKMARK' } })
getCategories.value!.forEach((category: any) => categories.value.push({ label: category.name, slug: category.slug }))
+const selected = computed({
+ get() {
+ return categories.value.findIndex(category => getCategory.value === category.slug) || 0
+ },
+ set(index) {
+ setCategory(categories.value[index].slug || categories.value[0].slug)
+ },
+})
+
const appConfig = useAppConfig()
function getColor() {
return `text-${appConfig.ui.primary}-500`
@@ -46,26 +51,22 @@ function getColor() {
You will find a selection of some of the most inspiring and complete content I have read through my research and work experience.
-
-
+
+
+
+
+ {{ item.label }}
+
+
+
+
-
- {{ bookmark.content }}
-
diff --git a/src/pages/talents.vue b/src/pages/talents.vue
index 8cfca09..24dd8f4 100644
--- a/src/pages/talents.vue
+++ b/src/pages/talents.vue
@@ -7,7 +7,7 @@ useHead({
title: 'Discover new talents • Arthur Danjou',
})
-const categories = ref>([{ label: 'All', slug: 'all' }])
+const categories = ref>([{ label: 'All', slug: 'all', id: 0 }])
const { getCategory, setCategory, isFavorite, toggleFavorite } = useTalentsStore()
const { loggedIn, clear } = useUserSession()
@@ -23,14 +23,19 @@ const {
watch: [isFavorite, getCategory],
})
-function isCategory(category: string) {
- return getCategory.value === category
-}
-
const {
data: getCategories,
} = await useFetch>('/api/categories', { method: 'GET', query: { type: 'TALENT' } })
-getCategories.value!.forEach((category: any) => categories.value.push({ label: category.name, slug: category.slug }))
+getCategories.value!.forEach((category: any) => categories.value.push({ label: category.name, slug: category.slug, id: category.id }))
+
+const selected = computed({
+ get() {
+ return categories.value.find(category => getCategory.value === category.slug)?.id || categories.value[0].id
+ },
+ set(value) {
+ setCategory(categories.value.find(category => category.id === value)?.slug || categories.value[0].slug)
+ },
+})
const appConfig = useAppConfig()
function getColor() {
@@ -123,26 +128,22 @@ async function suggest() {
/>
-
-
+
+
+
+
+ {{ item.label }}
+
+
+
+