---
import AdminLayout from '@layouts/admin/AdminLayout.astro';
import Settings from '@app/admin/settings/Settings.svelte';
import { db } from '@db/database.ts';
import { Session } from '@util/session.ts';
import { Permissions } from '@util/permissions.ts';
import { BASE_PATH } from 'astro:env/server';

const session = Session.sessionFromCookies(Astro.cookies, Permissions.Settings);
if (!session) return Astro.redirect(`${BASE_PATH}/admin`);

const settings = await db.getSettings({});
---

<AdminLayout title="Einstellungen">
  <Settings {settings} client:load />
</AdminLayout>
