add acceptInvite method to users store
This commit is contained in:
parent
ecc740b5a7
commit
b610bf446e
|
@ -1,21 +1,23 @@
|
|||
import { writable } from "svelte/store"
|
||||
import api from "builderStore/api"
|
||||
|
||||
const FALLBACK_CONFIG = {
|
||||
platformUrl: "",
|
||||
logoUrl: "",
|
||||
docsUrl: "",
|
||||
company: "",
|
||||
}
|
||||
|
||||
export function createOrganisationStore() {
|
||||
const { subscribe, set } = writable({})
|
||||
|
||||
async function init() {
|
||||
try {
|
||||
const response = await api.get(`/api/admin/configs/settings`)
|
||||
const json = await response.json()
|
||||
if (json.status === 400) {
|
||||
set({ config: FALLBACK_CONFIG})
|
||||
} else {
|
||||
set(json)
|
||||
} catch (error) {
|
||||
set({
|
||||
platformUrl: "",
|
||||
logoUrl: "",
|
||||
docsUrl: "",
|
||||
company: "",
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -27,7 +29,7 @@ export function createOrganisationStore() {
|
|||
await init()
|
||||
return { status: 200 }
|
||||
} catch (error) {
|
||||
return { error }
|
||||
return { status: error }
|
||||
}
|
||||
},
|
||||
init,
|
||||
|
|
|
@ -15,6 +15,10 @@ export function createUsersStore() {
|
|||
const response = await api.post(`/api/admin/users/invite`, { email })
|
||||
return await response.json()
|
||||
}
|
||||
async function acceptInvite(inviteCode, password) {
|
||||
const response = await api.post("/api/admin/users/invite/accept", { inviteCode, password })
|
||||
return await response.json()
|
||||
}
|
||||
|
||||
async function create({ email, password }) {
|
||||
const response = await api.post("/api/admin/users", { email, password, roles: {} })
|
||||
|
@ -30,17 +34,9 @@ export function createUsersStore() {
|
|||
|
||||
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,
|
||||
invite,
|
||||
acceptInvite,
|
||||
create,
|
||||
del
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue