forked from admin/zeropost-tool
feat: channel history page — published posts with search
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
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 || []} />
|
||||
</>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user