Almost done
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
// app/admin/page.tsx
|
||||
import { cookies } from 'next/headers';
|
||||
import { redirect } from 'next/navigation';
|
||||
import { getConfig } from '../lib/config';
|
||||
import AdminForm from './AdminForm';
|
||||
import { logoutAction } from '../login/actions';
|
||||
import Header from '../components/Header';
|
||||
import Footer from '../components/Footer';
|
||||
|
||||
export const metadata = {
|
||||
title: 'Kontrollpanel',
|
||||
};
|
||||
|
||||
export default async function AdminPage() {
|
||||
const cookieStore = await cookies();
|
||||
if (cookieStore.get('admin_session')?.value !== 'true') redirect('/login');
|
||||
|
||||
const config = await getConfig();
|
||||
|
||||
return (
|
||||
<div className="min-h-screen flex flex-col font-sans">
|
||||
<Header />
|
||||
|
||||
<div className="grow bg-gray-100 p-4 md:p-10">
|
||||
<div className="max-w-2xl mx-auto bg-white p-6 md:p-8 rounded-xl shadow-md">
|
||||
<div className="flex justify-between items-center mb-8">
|
||||
<div className="flex flex-col">
|
||||
<h1 className="text-3xl font-bold text-[#406185]">Kontrollpanel</h1>
|
||||
</div>
|
||||
|
||||
<form action={logoutAction}>
|
||||
<button
|
||||
type="submit"
|
||||
className="text-sm font-bold text-gray-500 hover:text-red-600 border border-gray-300 hover:border-red-600 px-1 md:p-4 py-2 rounded-lg transition-all active:scale-90"
|
||||
>
|
||||
Logga ut
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<AdminForm initialConfig={config} />
|
||||
</div>
|
||||
</div>
|
||||
<Footer />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user