feat: initial project
This commit is contained in:
commit
eaf01cfc59
38 files changed
+5807
No files matched your search
@@ -0,0 +1,33 @@
|
||||
import { defineStore } from 'pinia'
|
||||
import { ref } from 'vue'
|
||||
import {
|
||||
fetchProductions,
|
||||
fetchProduction,
|
||||
type Production,
|
||||
type ProductionDetail
|
||||
} from '@/api/fankai'
|
||||
|
||||
export const useCatalogStore = defineStore('catalog', () => {
|
||||
const productions = ref<Production[]>([])
|
||||
const loading = ref(false)
|
||||
const error = ref<string | null>(null)
|
||||
|
||||
async function loadProductions() {
|
||||
if (productions.value.length > 0) return
|
||||
loading.value = true
|
||||
error.value = null
|
||||
try {
|
||||
productions.value = await fetchProductions()
|
||||
} catch (err) {
|
||||
error.value = err instanceof Error ? err.message : 'Erreur inconnue'
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function loadProduction(id: number, name: string): Promise<ProductionDetail> {
|
||||
return await fetchProduction(id, name)
|
||||
}
|
||||
|
||||
return { productions, loading, error, loadProductions, loadProduction }
|
||||
})
|
||||
Reference in new issue
Block a user