import { ref, type Ref } from "vue"; import { defineStore } from "pinia"; import * as kgService from "@/services/knowledgeGraph.service"; import * as searchService from "@/services/search.service"; import type { Property } from "@/types/knowledgeGraph.types"; import type { SearchResult } from "@/types/search.types"; export const useKnowledgeGraphStore = defineStore('knowledge-graph', () => { const property: Ref = ref({} as Property); const searchResult: Ref = ref(null); function fetchProperty(id: number) { kgService.fetchProperty(id).then((resp) => { property.value = resp.data.data; }) } function search(name: string) { searchService.search(`TP=("${name}")`).then((resp) => { searchResult.value = resp.data.data; }); } return { property, searchResult, fetchProperty, search, } });