Skip to content

Commit 8ad84e2

Browse files
authored
Merge pull request #146 from luannguyenQV/feat/update-post
Update schema
2 parents 76fd813 + ed7a2ad commit 8ad84e2

File tree

6 files changed

+260
-232
lines changed

6 files changed

+260
-232
lines changed

apps/admin/app/[lang]/layout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import "./globals.css"
1+
// import "./globals.css"
22

33
import AuthProvider from "providers/authProvider"
44
import { ToastContainer } from "react-toastify"
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { getUserById } from "@/actions/public/authors"
2+
import FollowerItem from "@/molecules/follower/follower-item"
3+
import UserProfile from "@/molecules/follower/user-profile"
4+
5+
export const metadata = {
6+
title: "Follower",
7+
description: "List of followers",
8+
}
9+
10+
export default async function Page({ params }: { params: { authorId: string } }) {
11+
const author = await getUserById(params?.authorId as string)
12+
13+
return (
14+
<div className="grid grid-cols-12 gap-10">
15+
<UserProfile author={author} />
16+
<div className="col-span-8 flex flex-col gap-4">
17+
<FollowerItem />
18+
</div>
19+
</div>
20+
)
21+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { getUserById } from "@/actions/public/authors"
2+
import UserProfile from "@/molecules/follower/user-profile"
3+
import PostItem from "@/molecules/posts/post-item"
4+
5+
export const metadata = {
6+
title: "Author",
7+
description: "A list of posts by the author",
8+
}
9+
10+
export default async function Page({ params }: { params: { authorId: string } }) {
11+
const author = await getUserById(params?.authorId as string)
12+
13+
return (
14+
<div className="grid grid-cols-12 gap-10">
15+
<UserProfile author={author} />
16+
<div className="col-span-8 rounded-md">
17+
{author?.post?.map((post) => (
18+
<PostItem
19+
key={post?.id}
20+
post={post}
21+
/>
22+
))}
23+
</div>
24+
</div>
25+
)
26+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import { NextRequest } from "next/server"
2+
3+
import { postSelect } from "@/types/posts"
4+
5+
export async function GET(request: NextRequest, { params }: { params: { postIdOrSlug: string } }) {
6+
try {
7+
const post = await prisma.post.findUnique({
8+
where: {
9+
// postStatus: PostStatus.PUBLISHED,
10+
// id: params.postIdOrSlug,
11+
slug: params.postIdOrSlug,
12+
// OR: [
13+
// {
14+
// id: params.postIdOrSlug,
15+
// },
16+
// {
17+
// slug: params.postIdOrSlug,
18+
// },
19+
// ],
20+
},
21+
select: postSelect,
22+
})
23+
24+
if (!post)
25+
return Response.json({
26+
status: 404,
27+
message: "Post not found",
28+
})
29+
30+
return Response.json(post, { status: 200 })
31+
} catch (error) {
32+
return Response.error()
33+
}
34+
}

0 commit comments

Comments
 (0)