|
1 | 1 | <script lang="ts"> |
2 | | - import { type ComponentProps, type Snippet } from 'svelte'; |
| 2 | + import { type ComponentProps, type Snippet, onMount } from 'svelte'; |
3 | 3 | import { sdk } from '$lib/stores/sdk'; |
4 | 4 | import type { Models } from '@appwrite.io/console'; |
5 | 5 | import { AvatarInitials } from '../'; |
|
34 | 34 | role: string; |
35 | 35 | placement?: ComponentProps<Popover>['placement']; |
36 | 36 | children?: Snippet; |
| 37 | + onNotFound?: (role: string) => void; |
37 | 38 | } |
38 | 39 |
|
39 | | - let { role, placement = 'bottom-start', children }: Props = $props(); |
| 40 | + let { role, placement = 'bottom-start', children, onNotFound }: Props = $props(); |
40 | 41 |
|
41 | 42 | type ParsedPermission = { |
42 | 43 | type: 'user' | 'team' | 'other'; |
|
111 | 112 | return fetchPromise; |
112 | 113 | } |
113 | 114 |
|
| 115 | + async function verifyExistence() { |
| 116 | + try { |
| 117 | + const data = await getData(role); |
| 118 | + if (data?.notFound) { |
| 119 | + onNotFound?.(role); |
| 120 | + } |
| 121 | + } catch { |
| 122 | + // Intentionally ignore fetch/parse errors; UI handles missing data state |
| 123 | + } |
| 124 | + } |
| 125 | +
|
| 126 | + onMount(() => { |
| 127 | + verifyExistence(); |
| 128 | + }); |
| 129 | +
|
114 | 130 | let isMouseOverTooltip = $state(false); |
115 | 131 | function hidePopover(hideTooltip: () => void, timeout = true) { |
116 | 132 | if (!timeout) { |
|
162 | 178 | {:then data} |
163 | 179 | {formatName( |
164 | 180 | data.name ?? data?.email ?? data?.phone ?? '-', |
165 | | - $isSmallViewport ? 16 : 18 |
| 181 | + $isSmallViewport ? 16 : 20 |
166 | 182 | )} |
167 | 183 | {/await} |
168 | 184 | </Typography.Text> |
|
281 | 297 | <Divider /> |
282 | 298 | <Layout.Stack gap="xxs" alignItems="flex-start"> |
283 | 299 | {#if data.email} |
284 | | - <Typography.Text |
285 | | - size="xs" |
286 | | - variant="m-400" |
| 300 | + <Typography.Caption |
| 301 | + variant="400" |
287 | 302 | color="--fgcolor-neutral-secondary"> |
288 | | - Email: {data.email} |
289 | | - </Typography.Text> |
| 303 | + Email: {formatName( |
| 304 | + data.email, |
| 305 | + $isSmallViewport ? 24 : 32 |
| 306 | + )} |
| 307 | + </Typography.Caption> |
290 | 308 | {/if} |
291 | 309 | {#if data.phone} |
292 | | - <Typography.Text |
293 | | - size="xs" |
294 | | - variant="m-400" |
| 310 | + <Typography.Caption |
| 311 | + variant="400" |
295 | 312 | color="--fgcolor-neutral-secondary"> |
296 | 313 | Phone: {data.phone} |
297 | | - </Typography.Text> |
| 314 | + </Typography.Caption> |
298 | 315 | {/if} |
299 | 316 | </Layout.Stack> |
300 | 317 | {/if} |
|
0 commit comments