From b3c63defb348f334240c84bd27ac50c7cd72682c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Keviin=20=C3=85berg=20Kultalahti?= Date: Wed, 12 May 2021 11:33:04 +0200 Subject: [PATCH] sets up invite action in onboarding modal --- .../manage/users/_components/AddUserModal.svelte | 10 +++++++--- packages/builder/src/stores/portal/users.js | 14 +++----------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/packages/builder/src/pages/builder/portal/manage/users/_components/AddUserModal.svelte b/packages/builder/src/pages/builder/portal/manage/users/_components/AddUserModal.svelte index 084af34e53..8646da9c06 100644 --- a/packages/builder/src/pages/builder/portal/manage/users/_components/AddUserModal.svelte +++ b/packages/builder/src/pages/builder/portal/manage/users/_components/AddUserModal.svelte @@ -17,9 +17,13 @@ const [email, error, touched] = createValidationStore("", emailValidator) async function createUserFlow() { - const response = await users.invite(email) - console.log(response) - notifications.success("Email sent.") + const res = await users.invite($email) + console.log(res) + if (res.status) { + notifications.error(res.message) + } else { + notifications.success(res.message) + } } diff --git a/packages/builder/src/stores/portal/users.js b/packages/builder/src/stores/portal/users.js index d4dc7618b5..d5833c43e1 100644 --- a/packages/builder/src/stores/portal/users.js +++ b/packages/builder/src/stores/portal/users.js @@ -6,22 +6,14 @@ export function createUsersStore() { const { subscribe, set } = writable([]) async function init() { - try { - const response = await api.get(`/api/admin/users`) - const json = await response.json() - set(json) - } catch (error) { - console.log(error) - } + const response = await api.get(`/api/admin/users`) + const json = await response.json() + set(json) } 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 }) {