From 07e8e635e6b1fec1248b58ba2be9783bef6d58da Mon Sep 17 00:00:00 2001 From: Arman Date: Wed, 3 Aug 2022 14:29:56 +0200 Subject: [PATCH] feat: function works on:submit --- .../[project]/users/teams/[team]/index.svelte | 61 ++++++++----------- 1 file changed, 27 insertions(+), 34 deletions(-) diff --git a/src/routes/console/[project]/users/teams/[team]/index.svelte b/src/routes/console/[project]/users/teams/[team]/index.svelte index 57b1a3dc4..83ac0a25c 100644 --- a/src/routes/console/[project]/users/teams/[team]/index.svelte +++ b/src/routes/console/[project]/users/teams/[team]/index.svelte @@ -2,7 +2,7 @@ import { page } from '$app/stores'; import { Avatar, CardGrid, Box } from '$lib/components'; import { Container } from '$lib/layout'; - import { Button, InputText, Helper } from '$lib/elements/forms'; + import { Button, InputText, Form } from '$lib/elements/forms'; import { sdkForProject } from '$lib/stores/sdk'; import { toLocaleDateTime } from '$lib/helpers/date'; import { addNotification } from '$lib/stores/notifications'; @@ -14,9 +14,6 @@ const getAvatar = (name: string) => sdkForProject.avatars.getInitials(name, 48, 48).toString(); let showDelete = false; - let showError: false | 'name' | 'email' | 'password' = false; - let errorMessage = 'Something went wrong'; - let errorType: 'error' | 'warning' | 'success' = 'error'; let teamName: string = null; onMount(async () => { @@ -24,12 +21,6 @@ teamName ??= $team.name; }); - function addError(location: typeof showError, message: string, type: typeof errorType) { - showError = location; - errorMessage = message; - errorType = type; - } - async function updateName() { try { await sdkForProject.teams.update($page.params.team, teamName); @@ -40,7 +31,10 @@ type: 'success' }); } catch (error) { - addError('name', error.message, 'error'); + addNotification({ + message: error.message, + type: 'error' + }); } } @@ -62,31 +56,30 @@ - -
Update Name
+
+ +
Update Name
- -
    - - {#if showError === 'name'} - {errorMessage} - {/if} -
-
+ +
    + +
+
- - - -
+ + + + +