feat: enable registration toggle and update Navbar to reflect registration status

This commit is contained in:
2026-01-04 11:16:09 -05:00
parent f5de211611
commit 159fcc2a89
4 changed files with 21 additions and 6 deletions
@@ -3,6 +3,7 @@
import { resolve } from '$app/paths';
import { page } from '$app/state';
import { clearTokens } from '$lib/utils/auth';
import type { PageData } from '../../routes/$types';
function logout() {
clearTokens();
@@ -10,6 +11,10 @@
window.location.href = '/';
}
export let data: PageData;
console.log(data);
let currentPath = page.url.pathname;
let returnParam =
currentPath !== '/' && !currentPath.startsWith('/login') && !currentPath.startsWith('/register')
@@ -35,12 +40,18 @@
{:else}
<div class="ml-auto flex items-center space-x-4">
<a
href={resolve(`/login${returnParam}`)}
class="rounded bg-neutral-700 px-3 py-1 text-white hover:bg-neutral-800">Login</a
href={data.options?.registration_enabled ? resolve(`/login${returnParam}`) : '#'}
class="rounded bg-neutral-700 px-3 py-1 text-white hover:bg-neutral-800 {data.options
?.registration_enabled
? ''
: 'cursor-not-allowed bg-neutral-800 text-neutral-500!'}">Login</a
>
<a
href={resolve(`/register${returnParam}`)}
class="rounded bg-neutral-700 px-3 py-1 text-white hover:bg-neutral-800">Register</a
href={data.options?.registration_enabled ? resolve(`/register${returnParam}`) : '#'}
class="rounded bg-neutral-700 px-3 py-1 text-white hover:bg-neutral-800 {data.options
?.registration_enabled
? ''
: 'cursor-not-allowed bg-neutral-800 text-neutral-500!'}">Register</a
>
</div>
{/if}