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
@@ -27,6 +27,8 @@
|
||||
|
||||
let { data } = $props()
|
||||
|
||||
let inbox = $state(data.data)
|
||||
|
||||
let markingAsRead = $state(false)
|
||||
|
||||
async function markAllAsRead() {
|
||||
@@ -164,14 +166,14 @@ items-center px-2 w-max"
|
||||
<div
|
||||
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
|
||||
icon={Inbox}
|
||||
title={$t('routes.inbox.empty.title')}
|
||||
description={$t('routes.inbox.empty.description')}
|
||||
/>
|
||||
{:else}
|
||||
{#each data.data as item, index (item.id)}
|
||||
{#each inbox as item, index (item.id)}
|
||||
<div
|
||||
class="-mx-4 sm:-mx-6 px-4 sm:px-6
|
||||
{item.read ? '' : 'bg-yellow-50/50 dark:bg-blue-500/5'}"
|
||||
@@ -183,7 +185,7 @@ items-center px-2 w-max"
|
||||
delay: index * 50,
|
||||
}}
|
||||
>
|
||||
<InboxItem bind:item={data.data[index]} />
|
||||
<InboxItem bind:item={inbox[index]} />
|
||||
</div>
|
||||
{/each}
|
||||
{/if}
|
||||
@@ -194,7 +196,7 @@ items-center px-2 w-max"
|
||||
>
|
||||
<Tabs routes={[]} class="mx-auto">
|
||||
<Pageination
|
||||
hasMore={!(!data.data || (data.data?.length ?? 0) < data.limit)}
|
||||
hasMore={!(!data.data || (inbox?.length ?? 0) < data.limit)}
|
||||
page={data.page}
|
||||
on:change={(p) => searchParam($page.url, 'page', p.detail.toString())}
|
||||
/>
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
import Header from '$lib/components/ui/layout/pages/Header.svelte'
|
||||
|
||||
let { data = $bindable() } = $props()
|
||||
|
||||
let reports = $state(data.items)
|
||||
</script>
|
||||
|
||||
<div class="mb-4 flex flex-col gap-4">
|
||||
@@ -29,7 +31,7 @@
|
||||
bind:value={data.type}
|
||||
on:change={() => searchParam($page.url, 'type', data.type, 'page')}
|
||||
>
|
||||
{#snippet label()}
|
||||
{#snippet customLabel()}
|
||||
<span class="flex items-center gap-1">
|
||||
<Icon src={Funnel} size="15" mini />
|
||||
{$t('filter.filter')}
|
||||
@@ -46,22 +48,23 @@
|
||||
{/snippet}
|
||||
</Header>
|
||||
</div>
|
||||
{#if data.items && data.items.length > 0}
|
||||
{#if reports && reports.length > 0}
|
||||
<div class="flex flex-col gap-4">
|
||||
{#each data.items as item}
|
||||
<div in:fly={{ y: -6, opacity: 0, duration: 500 }}>
|
||||
<Material class="flex flex-col gap-4 text-sm">
|
||||
<div class="flex flex-col gap-1.5">
|
||||
<span class="text-xs font-bold dark:text-zinc-400 text-slate-600">
|
||||
Report from
|
||||
</span>
|
||||
<span class="font-bold">
|
||||
<UserLink avatar user={item.creator} />
|
||||
</span>
|
||||
</div>
|
||||
{#each reports as item}
|
||||
<div
|
||||
in:fly={{ y: -6, opacity: 0, duration: 500 }}
|
||||
class="flex flex-col gap-1 text-sm"
|
||||
>
|
||||
<div class="flex flex-col gap-1.5">
|
||||
<span class="text-xs font-bold dark:text-zinc-400 text-slate-600">
|
||||
Report from
|
||||
</span>
|
||||
<span class="font-bold">
|
||||
<UserLink avatar user={item.creator} />
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<Report {item} />
|
||||
</Material>
|
||||
<Report {item} />
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
|
||||
@@ -138,6 +138,8 @@
|
||||
: ''}"
|
||||
loading={resolving}
|
||||
disabled={resolving}
|
||||
rounding="pill"
|
||||
color="ghost"
|
||||
>
|
||||
{#snippet prefix()}
|
||||
<Icon src={CheckCircle} micro={item.resolved} size="18" />
|
||||
|
||||
Reference in new issue
Block a user