1
0
Fork 0
mirror of synced 2024-10-03 10:36:59 +13:00
This commit is contained in:
Keviin Åberg Kultalahti 2021-05-05 18:41:16 +02:00
parent 98b1bbc655
commit 677106a58b
2 changed files with 30 additions and 30 deletions

View file

@ -1 +1 @@
export { organisation } from "./organisation"
export { organisation } from "./organisation"

View file

@ -2,36 +2,36 @@ import { writable } from "svelte/store"
import api from "builderStore/api"
export function createOrganisationStore() {
const { subscribe, set } = writable({})
const { subscribe, set } = writable({})
async function init() {
try {
const response = await api.get(`/api/admin/configs/settings`)
const json = await response.json()
set(json)
} catch (error) {
set({
platformUrl: '',
logoUrl: '',
docsUrl: '',
company: ''
})
}
}
return {
subscribe,
save: async config => {
try {
await api.post('/api/admin/configs', { type: 'settings', config})
await init()
return { status: 200 }
} catch (error) {
return { error }
}
},
init
async function init() {
try {
const response = await api.get(`/api/admin/configs/settings`)
const json = await response.json()
set(json)
} catch (error) {
set({
platformUrl: "",
logoUrl: "",
docsUrl: "",
company: "",
})
}
}
export const organisation = createOrganisationStore()
return {
subscribe,
save: async config => {
try {
await api.post("/api/admin/configs", { type: "settings", config })
await init()
return { status: 200 }
} catch (error) {
return { error }
}
},
init,
}
}
export const organisation = createOrganisationStore()