From f196f480be9e5290fd516999b9b24431c0dedd39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Keviin=20=C3=85berg=20Kultalahti?= Date: Wed, 12 May 2021 11:00:18 +0200 Subject: [PATCH] adds create user flow --- .../builder/src/helpers/validation/validation.js | 2 +- .../_components/BasicOnboardingModal.svelte | 16 ++++++++++++++-- packages/builder/src/stores/portal/users.js | 16 ++++++++++++++++ 3 files changed, 31 insertions(+), 3 deletions(-) diff --git a/packages/builder/src/helpers/validation/validation.js b/packages/builder/src/helpers/validation/validation.js index b0a169c76d..9927d1129a 100644 --- a/packages/builder/src/helpers/validation/validation.js +++ b/packages/builder/src/helpers/validation/validation.js @@ -8,7 +8,7 @@ export function createValidationStore(initialValue, ...validators) { const touchedStore = derived(value, () => { if (!touched) { touched = true - return + return false } return touched }) diff --git a/packages/builder/src/pages/builder/portal/manage/users/_components/BasicOnboardingModal.svelte b/packages/builder/src/pages/builder/portal/manage/users/_components/BasicOnboardingModal.svelte index 6a17bf09e1..501d6a1511 100644 --- a/packages/builder/src/pages/builder/portal/manage/users/_components/BasicOnboardingModal.svelte +++ b/packages/builder/src/pages/builder/portal/manage/users/_components/BasicOnboardingModal.svelte @@ -1,8 +1,10 @@ - + diff --git a/packages/builder/src/stores/portal/users.js b/packages/builder/src/stores/portal/users.js index c748ed9392..c6b5079070 100644 --- a/packages/builder/src/stores/portal/users.js +++ b/packages/builder/src/stores/portal/users.js @@ -14,6 +14,20 @@ export function createUsersStore() { } } + async function invite(email) { + try { + const response = await api.post(`/api/admin/users/invite`, { email }) + return await response.json() + } catch (error) { + return error + } + } + + async function create({ email, password }) { + const response = await api.post("/api/admin/users", { email, password, roles: {} }) + return await response.json() + } + return { subscribe, // save: async config => { @@ -26,6 +40,8 @@ export function createUsersStore() { // } // }, init, + invite, + create, } }