fix: apply bugfix agent improvements to src/app/dashboard/posts/page.tsx
This commit is contained in:
parent
0e3158f1b7
commit
c8aa32c9a9
|
|
@ -0,0 +1,75 @@
|
|||
"use client";
|
||||
|
||||
import { useState } from "react";
|
||||
import Link from "next/link";
|
||||
import { useContentStore } from "@/store/contentStore";
|
||||
import PostsTable from "@/components/posts/PostsTable";
|
||||
import { Plus, Search } from "lucide-react";
|
||||
|
||||
export default function PostsPage() {
|
||||
const { posts } = useContentStore();
|
||||
const [search, setSearch] = useState("");
|
||||
const [statusFilter, setStatusFilter] = useState<
|
||||
"all" | "published" | "draft"
|
||||
>("all");
|
||||
|
||||
const filtered = posts.filter((post) => {
|
||||
const matchesSearch =
|
||||
post.title.toLowerCase().includes(search.toLowerCase()) ||
|
||||
post.excerpt?.toLowerCase().includes(search.toLowerCase());
|
||||
const matchesStatus =
|
||||
statusFilter === "all" || post.status === statusFilter;
|
||||
return matchesSearch && matchesStatus;
|
||||
});
|
||||
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
<div className="flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4">
|
||||
<div>
|
||||
<h1 className="text-2xl font-bold text-gray-900">Posts</h1>
|
||||
<p className="text-gray-500 mt-1">
|
||||
Manage all your blog posts and articles.
|
||||
</p>
|
||||
</div>
|
||||
<Link
|
||||
href="/dashboard/posts/new"
|
||||
className="inline-flex items-center gap-2 px-4 py-2 bg-primary-600 text-white rounded-lg hover:bg-primary-700 font-medium text-sm transition-colors"
|
||||
>
|
||||
<Plus size={16} />
|
||||
New Post
|
||||
</Link>
|
||||
</div>
|
||||
|
||||
<div className="bg-white rounded-xl shadow-sm border border-gray-200 p-4">
|
||||
<div className="flex flex-col sm:flex-row gap-3">
|
||||
<div className="relative flex-1">
|
||||
<Search
|
||||
size={16}
|
||||
className="absolute left-3 top-1/2 -translate-y-1/2 text-gray-400"
|
||||
/>
|
||||
<input
|
||||
type="text"
|
||||
placeholder="Search posts..."
|
||||
value={search}
|
||||
onChange={(e) => setSearch(e.target.value)}
|
||||
className="w-full pl-9 pr-4 py-2 border border-gray-300 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-transparent"
|
||||
/>
|
||||
</div>
|
||||
<select
|
||||
value={statusFilter}
|
||||
onChange={(e) =>
|
||||
setStatusFilter(e.target.value as "all" | "published" | "draft")
|
||||
}
|
||||
className="px-3 py-2 border border-gray-300 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-transparent bg-white"
|
||||
>
|
||||
<option value="all">All Status</option>
|
||||
<option value="published">Published</option>
|
||||
<option value="draft">Draft</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<PostsTable posts={filtered} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Loading…
Reference in New Issue