fix loading show form page (#361)

Co-authored-by: Julien Nahum <julien@nahum.net>
This commit is contained in:
Favour Olayinka
2024-03-25 16:05:24 +01:00
committed by GitHub
parent e517cba88a
commit 2191f46214
5 changed files with 48 additions and 1 deletions

View File

@@ -2,6 +2,7 @@ import {defineStore} from 'pinia'
import {useContentStore} from "~/composables/stores/useContentStore.js";
export const formsEndpoint = '/open/workspaces/{workspaceId}/forms'
export const singleFormEndpoint = '/open/forms/{slug}'
export const useFormsStore = defineStore('forms', () => {
@@ -33,6 +34,16 @@ export const useFormsStore = defineStore('forms', () => {
throw error
})
}
const loadForm = (slug) => {
contentStore.startLoading()
return opnFetch(singleFormEndpoint.replace('{slug}', slug))
.then(response => {
contentStore.save(response)
})
.finally(() => {
contentStore.stopLoading()
})
}
const load = (workspaceId, slug) => {
contentStore.startLoading()
@@ -76,6 +87,7 @@ export const useFormsStore = defineStore('forms', () => {
publicLoad,
publicFetch,
loadAll,
loadForm,
load,
}
})