peer-at-code-web/app/dashboard/puzzles/page.tsx
2023-09-04 13:39:18 +02:00

29 lines
670 B
TypeScript

import { cookies } from 'next/headers';
import Puzzles from '@/ui/Puzzles';
import SWRFallback from '@/ui/SWRFallback';
import { getPuzzles } from '@/lib/puzzles';
import { notFound } from 'next/navigation';
export const metadata = {
title: 'Puzzles'
};
export default async function Page() {
const cookieStore = cookies();
const token = cookieStore.get('token')!.value;
const puzzles = await getPuzzles({ token });
if (!puzzles) {
notFound();
}
return (
<section className="flex w-full flex-col space-y-6">
<SWRFallback fallback={{ ['puzzles']: puzzles }}>
<Puzzles token={token!} />
</SWRFallback>
</section>
);
}