fix: reactive mutable page.ts data now is $state
This commit is contained in:
1 parent
f390e6b844
commit
f6214b6640
4 files changed
+29
-19
No files matched your search
@@ -65,6 +65,8 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import type { HTMLButtonAttributes } from 'svelte/elements'
|
||||||
|
|
||||||
import Spinner from '../loader/Spinner.svelte'
|
import Spinner from '../loader/Spinner.svelte'
|
||||||
|
|
||||||
type ButtonRoundness = 'pill' | 'xl' | 'lg' | 'md' | 'none'
|
type ButtonRoundness = 'pill' | 'xl' | 'lg' | 'md' | 'none'
|
||||||
@@ -129,6 +131,7 @@
|
|||||||
prefix?: import('svelte').Snippet
|
prefix?: import('svelte').Snippet
|
||||||
children?: import('svelte').Snippet
|
children?: import('svelte').Snippet
|
||||||
suffix?: import('svelte').Snippet
|
suffix?: import('svelte').Snippet
|
||||||
|
onclick?: HTMLButtonAttributes['onclick']
|
||||||
[key: string]: any
|
[key: string]: any
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,6 +27,8 @@
|
|||||||
|
|
||||||
let { data } = $props()
|
let { data } = $props()
|
||||||
|
|
||||||
|
let inbox = $state(data.data)
|
||||||
|
|
||||||
let markingAsRead = $state(false)
|
let markingAsRead = $state(false)
|
||||||
|
|
||||||
async function markAllAsRead() {
|
async function markAllAsRead() {
|
||||||
@@ -164,14 +166,14 @@ items-center px-2 w-max"
|
|||||||
<div
|
<div
|
||||||
class="flex flex-col list-none flex-1 h-full divide-y divide-slate-200 dark:divide-zinc-900 *:py-4"
|
class="flex flex-col list-none flex-1 h-full divide-y divide-slate-200 dark:divide-zinc-900 *:py-4"
|
||||||
>
|
>
|
||||||
{#if !data.data || (data.data?.length ?? 0) == 0}
|
{#if !inbox || (inbox?.length ?? 0) == 0}
|
||||||
<Placeholder
|
<Placeholder
|
||||||
icon={Inbox}
|
icon={Inbox}
|
||||||
title={$t('routes.inbox.empty.title')}
|
title={$t('routes.inbox.empty.title')}
|
||||||
description={$t('routes.inbox.empty.description')}
|
description={$t('routes.inbox.empty.description')}
|
||||||
/>
|
/>
|
||||||
{:else}
|
{:else}
|
||||||
{#each data.data as item, index (item.id)}
|
{#each inbox as item, index (item.id)}
|
||||||
<div
|
<div
|
||||||
class="-mx-4 sm:-mx-6 px-4 sm:px-6
|
class="-mx-4 sm:-mx-6 px-4 sm:px-6
|
||||||
{item.read ? '' : 'bg-yellow-50/50 dark:bg-blue-500/5'}"
|
{item.read ? '' : 'bg-yellow-50/50 dark:bg-blue-500/5'}"
|
||||||
@@ -183,7 +185,7 @@ items-center px-2 w-max"
|
|||||||
delay: index * 50,
|
delay: index * 50,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<InboxItem bind:item={data.data[index]} />
|
<InboxItem bind:item={inbox[index]} />
|
||||||
</div>
|
</div>
|
||||||
{/each}
|
{/each}
|
||||||
{/if}
|
{/if}
|
||||||
@@ -194,7 +196,7 @@ items-center px-2 w-max"
|
|||||||
>
|
>
|
||||||
<Tabs routes={[]} class="mx-auto">
|
<Tabs routes={[]} class="mx-auto">
|
||||||
<Pageination
|
<Pageination
|
||||||
hasMore={!(!data.data || (data.data?.length ?? 0) < data.limit)}
|
hasMore={!(!data.data || (inbox?.length ?? 0) < data.limit)}
|
||||||
page={data.page}
|
page={data.page}
|
||||||
on:change={(p) => searchParam($page.url, 'page', p.detail.toString())}
|
on:change={(p) => searchParam($page.url, 'page', p.detail.toString())}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -18,6 +18,8 @@
|
|||||||
import Header from '$lib/components/ui/layout/pages/Header.svelte'
|
import Header from '$lib/components/ui/layout/pages/Header.svelte'
|
||||||
|
|
||||||
let { data = $bindable() } = $props()
|
let { data = $bindable() } = $props()
|
||||||
|
|
||||||
|
let reports = $state(data.items)
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="mb-4 flex flex-col gap-4">
|
<div class="mb-4 flex flex-col gap-4">
|
||||||
@@ -29,7 +31,7 @@
|
|||||||
bind:value={data.type}
|
bind:value={data.type}
|
||||||
on:change={() => searchParam($page.url, 'type', data.type, 'page')}
|
on:change={() => searchParam($page.url, 'type', data.type, 'page')}
|
||||||
>
|
>
|
||||||
{#snippet label()}
|
{#snippet customLabel()}
|
||||||
<span class="flex items-center gap-1">
|
<span class="flex items-center gap-1">
|
||||||
<Icon src={Funnel} size="15" mini />
|
<Icon src={Funnel} size="15" mini />
|
||||||
{$t('filter.filter')}
|
{$t('filter.filter')}
|
||||||
@@ -46,22 +48,23 @@
|
|||||||
{/snippet}
|
{/snippet}
|
||||||
</Header>
|
</Header>
|
||||||
</div>
|
</div>
|
||||||
{#if data.items && data.items.length > 0}
|
{#if reports && reports.length > 0}
|
||||||
<div class="flex flex-col gap-4">
|
<div class="flex flex-col gap-4">
|
||||||
{#each data.items as item}
|
{#each reports as item}
|
||||||
<div in:fly={{ y: -6, opacity: 0, duration: 500 }}>
|
<div
|
||||||
<Material class="flex flex-col gap-4 text-sm">
|
in:fly={{ y: -6, opacity: 0, duration: 500 }}
|
||||||
<div class="flex flex-col gap-1.5">
|
class="flex flex-col gap-1 text-sm"
|
||||||
<span class="text-xs font-bold dark:text-zinc-400 text-slate-600">
|
>
|
||||||
Report from
|
<div class="flex flex-col gap-1.5">
|
||||||
</span>
|
<span class="text-xs font-bold dark:text-zinc-400 text-slate-600">
|
||||||
<span class="font-bold">
|
Report from
|
||||||
<UserLink avatar user={item.creator} />
|
</span>
|
||||||
</span>
|
<span class="font-bold">
|
||||||
</div>
|
<UserLink avatar user={item.creator} />
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
<Report {item} />
|
<Report {item} />
|
||||||
</Material>
|
|
||||||
</div>
|
</div>
|
||||||
{/each}
|
{/each}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -138,6 +138,8 @@
|
|||||||
: ''}"
|
: ''}"
|
||||||
loading={resolving}
|
loading={resolving}
|
||||||
disabled={resolving}
|
disabled={resolving}
|
||||||
|
rounding="pill"
|
||||||
|
color="ghost"
|
||||||
>
|
>
|
||||||
{#snippet prefix()}
|
{#snippet prefix()}
|
||||||
<Icon src={CheckCircle} micro={item.resolved} size="18" />
|
<Icon src={CheckCircle} micro={item.resolved} size="18" />
|
||||||
|
|||||||
Reference in new issue
Block a user