forked from admin/zeropost-tool
29 lines
774 B
JavaScript
29 lines
774 B
JavaScript
import { notFound, redirect } from 'next/navigation';
|
|
import { requireUser } from '@/lib/session';
|
|
import { engine } from '@/lib/engine';
|
|
import Header from '@/components/Header';
|
|
import ChannelHistory from '@/components/ChannelHistory';
|
|
|
|
export default async function ChannelHistoryPage({ params }) {
|
|
const user = await requireUser();
|
|
if (!user) redirect('/login');
|
|
|
|
const { id } = await params;
|
|
|
|
let channel, posts;
|
|
try {
|
|
channel = await engine.getChannel(user.id, id);
|
|
posts = await engine.listUserPosts(user.id, { channel_id: id, status: 'published', limit: 100 });
|
|
} catch {
|
|
notFound();
|
|
}
|
|
if (!channel) notFound();
|
|
|
|
return (
|
|
<>
|
|
<Header user={user} />
|
|
<ChannelHistory channel={channel} posts={posts || []} />
|
|
</>
|
|
);
|
|
}
|