Skip to content

Commit

Permalink
Add Edit Post form
Browse files Browse the repository at this point in the history
  • Loading branch information
pahans committed May 21, 2024
1 parent 18f7297 commit 28d4f13
Show file tree
Hide file tree
Showing 10 changed files with 450 additions and 193 deletions.
4 changes: 3 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
"it": true,
"author": true,
"expect": true,
"jest": true
"jest": true,
"beforeEach": true,
"afterEach": true
},
"rules": {
"no-unused-vars": "off",
Expand Down
245 changes: 123 additions & 122 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"next": "14.2.3",
"next-themes": "^0.3.0",
"react": "^18",
"react-dom": "^18",
"react-dom": "^18.3.1",
"react-hook-form": "^7.51.4",
"react-intersection-observer": "^9.10.2",
"tailwind-merge": "^2.3.0",
Expand Down
6 changes: 1 addition & 5 deletions src/app/admin/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { EditPost } from "@/components/app/edit-post";
import { fetchPost } from "@/lib/data";
import { PostsTable } from "@/components/app/posts-table";
import { Suspense } from "react";
import { PostsTableSkeleton } from "@/components/app/posts-table/skeleton";
Expand All @@ -16,13 +15,10 @@ interface AdminPageProps {
// https://nextjs.org/docs/app/api-reference/file-conventions/page
// Need to check the next package if there are types for page components.
const AdminPage: React.FC<AdminPageProps> = async ({ searchParams }) => {
const postId = Number(searchParams?.id);
const editingPost = isNaN(postId) ? undefined : await fetchPost(postId);
const currentPage = Number(searchParams?.page) || 1;
return (
<div className="mb-10">
{/* post = undefined handles new post */}
<EditPost post={editingPost} />
<EditPost />
<Suspense fallback={<PostsTableSkeleton />}>
<PostsTable currentPage={currentPage} />
</Suspense>
Expand Down
Loading

0 comments on commit 28d4f13

Please sign in to comment.