import { defineStore } from 'pinia' import { type Asset } from '@/types' import config from '@/config' export const useAssetStore = defineStore('assets', { state: () => ({ assets: [] as Asset[] }), actions: { setAssets(assets: Asset[]) { this.assets = assets }, async fetchAssets() { return fetch(config.server_endpoint + '/assets') .then((response) => response.json()) .then((assets) => { this.setAssets(assets) return true }) .catch((error) => { console.error('Error fetching assets:', error) return false }) } } })