2024-01-02 16:06:55 +00:00
|
|
|
import {defineStore} from 'pinia'
|
|
|
|
import {useContentStore} from "~/composables/stores/useContentStore.js";
|
2024-01-03 16:38:11 +00:00
|
|
|
import opnformConfig from "~/opnform.config.js";
|
2024-01-02 16:06:55 +00:00
|
|
|
export const useNotionPagesStore = defineStore('notion_pages', () => {
|
|
|
|
|
|
|
|
const contentStore = useContentStore()
|
|
|
|
|
|
|
|
const load = (pageId) => {
|
|
|
|
contentStore.startLoading()
|
|
|
|
|
2024-01-03 16:38:11 +00:00
|
|
|
const apiUrl = opnformConfig.notion.worker
|
2024-01-11 16:16:50 +00:00
|
|
|
return useFetch(`${apiUrl}/page/${pageId}`)
|
|
|
|
.then(({data, error})=> {
|
2024-01-02 16:06:55 +00:00
|
|
|
const val = data.value
|
|
|
|
val['id'] = pageId
|
|
|
|
contentStore.save(val)
|
|
|
|
})
|
|
|
|
.finally(() => {
|
|
|
|
contentStore.stopLoading()
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
|
|
|
...contentStore,
|
|
|
|
load
|
|
|
|
}
|
|
|
|
})
|