mirror of
https://github.com/ArthurDanjou/website.git
synced 2026-01-22 16:00:35 +01:00
working on talents actualisation
This commit is contained in:
@@ -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,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user