working on talents actualisation

This commit is contained in:
2023-09-03 23:43:29 +02:00
parent b78f79f59c
commit f382f96fee
4 changed files with 80 additions and 64 deletions

View File

@@ -1,7 +1,23 @@
import { useTalentsStore } from '~/store/talents'
export async function useTalents() {
const { $trpc } = useNuxtApp()
const { setCategory, setFavorite, getCategory, isFavorite } = useTalentsStore()
const getTalents = async (category: string, favorite: boolean) => await $trpc.talents.getTalents.query({ favorite, category })
const {
data: talents,
refresh: refreshTalents,
} = await useAsyncData('talents:talents', async () => await $trpc.talents.getTalents.query({ favorite: isFavorite.value, category: getCategory.value }))
async function switchCategory(category: string) {
setCategory(category)
await refreshTalents()
}
async function toggleFavorite() {
setFavorite()
await refreshTalents()
}
const {
data: getCategories,
@@ -12,8 +28,11 @@ export async function useTalents() {
}
return {
getTalents,
talents,
getCategories,
getCategoryById,
isFavorite,
switchCategory,
toggleFavorite,
}
}