fix: broken unread/all applications selector
This commit is contained in:
5 files changed
+23
-17
No files matched your search
@@ -1,4 +1,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import type { Community } from '$lib/api/types'
|
||||||
|
import Avatar from '$lib/ui/generic/Avatar.svelte'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
community: Community
|
community: Community
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,6 @@
|
|||||||
</span>
|
</span>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<div class="flex flex-col gap-4 h-full">
|
|
||||||
<Tabs
|
<Tabs
|
||||||
routes={[
|
routes={[
|
||||||
{
|
{
|
||||||
@@ -44,5 +43,6 @@
|
|||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
|
<div class="flex flex-col gap-4 h-full">
|
||||||
{@render children?.()}
|
{@render children?.()}
|
||||||
</div>
|
</div>
|
||||||
@@ -1,9 +1,11 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import { page } from '$app/state'
|
||||||
import { t } from '$lib/app/i18n'
|
import { t } from '$lib/app/i18n'
|
||||||
|
import { searchParam } from '$lib/app/util.svelte'
|
||||||
import Placeholder from '$lib/ui/info/Placeholder.svelte'
|
import Placeholder from '$lib/ui/info/Placeholder.svelte'
|
||||||
import { Header, Pageination } from '$lib/ui/layout'
|
import { Header, Pageination } from '$lib/ui/layout'
|
||||||
import { Option, Select } from 'mono-svelte'
|
import { Option, Select } from 'mono-svelte'
|
||||||
import { ClipboardDocumentCheck } from 'svelte-hero-icons/dist'
|
import { ClipboardDocumentCheck, Funnel, Icon } from 'svelte-hero-icons/dist'
|
||||||
import Application from './Application.svelte'
|
import Application from './Application.svelte'
|
||||||
|
|
||||||
let { data } = $props()
|
let { data } = $props()
|
||||||
@@ -14,12 +16,19 @@
|
|||||||
<Header pageHeader>{$t('routes.admin.applications.title')}</Header>
|
<Header pageHeader>{$t('routes.admin.applications.title')}</Header>
|
||||||
<form bind:this={selectForm} action="/admin/applications" class="w-max">
|
<form bind:this={selectForm} action="/admin/applications" class="w-max">
|
||||||
<Select
|
<Select
|
||||||
name="unreadOnly"
|
bind:value={data.type.value}
|
||||||
onchange={() => selectForm?.requestSubmit?.()}
|
onchange={async () => {
|
||||||
label={$t('filter.filter')}
|
searchParam(page.url, 'type', data.type.value, 'page')
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<Option value="false">{$t('filter.location.all')}</Option>
|
{#snippet customLabel()}
|
||||||
<Option value="true">{$t('filter.unread')}</Option>
|
<span class="flex items-center gap-1">
|
||||||
|
<Icon src={Funnel} size="15" mini />
|
||||||
|
{$t('filter.filter')}
|
||||||
|
</span>
|
||||||
|
{/snippet}
|
||||||
|
<Option value="all">{$t('filter.location.all')}</Option>
|
||||||
|
<Option value="unread">{$t('filter.unread')}</Option>
|
||||||
</Select>
|
</Select>
|
||||||
</form>
|
</form>
|
||||||
{#if data.applications?.value && data.applications?.value.length > 0}
|
{#if data.applications?.value && data.applications?.value.length > 0}
|
||||||
|
|||||||
@@ -1,25 +1,19 @@
|
|||||||
import { getClient } from '$lib/api/client.svelte'
|
import { getClient } from '$lib/api/client.svelte'
|
||||||
import { profile } from '$lib/app/auth.svelte'
|
|
||||||
import { ReactiveState } from '$lib/app/util.svelte'
|
import { ReactiveState } from '$lib/app/util.svelte'
|
||||||
|
|
||||||
export async function load({ fetch, url }) {
|
export async function load({ fetch, url }) {
|
||||||
if (!profile) return
|
|
||||||
|
|
||||||
const { jwt } = profile.current!
|
|
||||||
if (!jwt) return
|
|
||||||
|
|
||||||
const page = Number(url.searchParams.get('page')) || 1
|
const page = Number(url.searchParams.get('page')) || 1
|
||||||
const unreadOnly = (url.searchParams.get('unreadOnly') || 'true') == 'true'
|
const type = url.searchParams.get('type') || 'unread'
|
||||||
|
|
||||||
const res = await getClient(undefined, fetch).listRegistrationApplications({
|
const res = await getClient(undefined, fetch).listRegistrationApplications({
|
||||||
page: page,
|
page: page,
|
||||||
limit: 40,
|
limit: 40,
|
||||||
unread_only: unreadOnly,
|
unread_only: type == 'all',
|
||||||
})
|
})
|
||||||
|
|
||||||
return {
|
return {
|
||||||
unreadOnly: unreadOnly,
|
|
||||||
page: page,
|
page: page,
|
||||||
applications: new ReactiveState(res.registration_applications),
|
applications: new ReactiveState(res.registration_applications),
|
||||||
|
type: new ReactiveState(type),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -100,7 +100,7 @@
|
|||||||
if (res.verify_email_sent) return (stage = 'verify')
|
if (res.verify_email_sent) return (stage = 'verify')
|
||||||
|
|
||||||
if (registrationMode == 'RequireApplication')
|
if (registrationMode == 'RequireApplication')
|
||||||
return stage == 'application'
|
return (stage = 'application')
|
||||||
} else {
|
} else {
|
||||||
throw new Error($t('toast.failSignup'))
|
throw new Error($t('toast.failSignup'))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user