Skip to content

Commit

Permalink
feat: display warning when creating a member with an existing name
Browse files Browse the repository at this point in the history
  • Loading branch information
Draconizations committed Sep 30, 2024
1 parent becda2f commit d4f5faf
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
17 changes: 16 additions & 1 deletion src/components/dash/groups/create/GroupCreate.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts">
import { dash } from "$lib/dash/dash.svelte"
import { IconLoader, IconPlus } from "@tabler/icons-svelte"
import { IconLoader, IconPlus, IconAlertTriangle } from "@tabler/icons-svelte"
import { untrack } from "svelte"
import type { Group, GroupPrivacy } from "$api/types"
import { fade } from "svelte/transition"
Expand Down Expand Up @@ -44,6 +44,10 @@
let success: boolean = $state(false)
let icon = $state("")
let duplicate = $derived(
dash.groups.list.raw.find((g) => g.name?.toLowerCase() === group.name?.toLowerCase())
)
</script>

<div
Expand Down Expand Up @@ -108,6 +112,17 @@
{#if openedOnce && tabbedOnce}
<GroupMemberCreate {tab} bind:members />
{/if}
{#if duplicate}
<div class="alert bg-warning/10 mb-2 w-full mx-auto px-5 py-3 mt-2">
<IconAlertTriangle class="text-warning" />
<div>
<div>
A group named <b>{duplicate.name}</b> already exists! Creating another group with this
name might lead to unexpected behavior.
</div>
</div>
</div>
{/if}
{#if err.length > 0}
{#each err as e}
{#if e}
Expand Down
17 changes: 16 additions & 1 deletion src/components/dash/members/create/MemberCreate.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script lang="ts">
import { dash } from "$lib/dash/dash.svelte"
import { createMemberCreationState } from "$lib/dash/member/edit.svelte"
import { IconLoader, IconPlus } from "@tabler/icons-svelte"
import { IconLoader, IconPlus, IconAlertTriangle } from "@tabler/icons-svelte"
import { untrack } from "svelte"
import MemberViewCreate from "./MemberViewCreate.svelte"
import MemberInfoCreate from "./MemberInfoCreate.svelte"
Expand Down Expand Up @@ -46,6 +46,10 @@
let avatar = $state("")
let proxyAvatar = $state("")
let duplicate = $derived(
dash.members.list.raw.find((m) => m.name?.toLowerCase() === member.name?.toLowerCase())
)
</script>

<div
Expand Down Expand Up @@ -110,6 +114,17 @@
{#if openedOnce && tabbedOnce}
<MemberGroupCreate {tab} bind:groups />
{/if}
{#if duplicate}
<div class="alert bg-warning/10 mb-2 w-full mx-auto px-5 py-3 mt-2">
<IconAlertTriangle class="text-warning" />
<div>
<div>
A member named <b>{duplicate.name}</b> already exists! Creating another member with this
name might lead to unexpected behavior.
</div>
</div>
</div>
{/if}
{#if err.length > 0}
{#each err as e}
{#if e}
Expand Down

0 comments on commit d4f5faf

Please sign in to comment.