fix loading show form page (#361)
Co-authored-by: Julien Nahum <julien@nahum.net>
This commit is contained in:
12
client/stores/forms.js
vendored
12
client/stores/forms.js
vendored
@@ -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,
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user