Skip to content

Commit 496f15e

Browse files
committed
feat: update post page
1 parent 4cbab2b commit 496f15e

File tree

7 files changed

+16
-11
lines changed

7 files changed

+16
-11
lines changed

apps/web/@/molecules/posts/post-detail/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import Link from "next/link"
22

3+
import { TPostItem } from "database"
34
import { Typography } from "ui"
45

56
import APP_ROUTES from "@/constants/routes"
67
import TagList from "@/molecules/tag/tag-list"
78
import PostMeta from "@/molecules/user/posts/post-meta"
8-
import { TPostItem } from "@/types/posts"
99
import { generatePath } from "@/utils/generatePath"
1010

1111
import EditPostButton from "./edit-post-button"

apps/web/@/molecules/posts/post-detail/like-button/LikeButton.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
"use client"
22

3-
import { PostOnUserType } from "database"
3+
import { PostOnUserType, TPostItem } from "database"
44
import { useTranslations } from "next-intl"
55
import { Button, cn, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "ui"
66

77
import { addRelation, removeRelation } from "@/actions/protect/postAction"
8-
import { TPostItem } from "@/types/posts"
98

109
type LikeButtonProps = {
1110
post: TPostItem

apps/web/@/molecules/posts/post-detail/like-button/index.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
import { PostOnUserType } from "database"
1+
import { PostOnUserType, TPostItem } from "database"
22

33
import { getTotalActions } from "@/actions/protect/postAction"
4-
import { TPostItem } from "@/types/posts"
54

65
import LikeButton from "./LikeButton"
76
import Liker from "./Likers"
87

9-
type LikeButtonProps = {
8+
interface LikeButtonProps {
109
post: TPostItem
1110
}
1211

apps/web/@/molecules/user/posts/post-meta.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
// generate react component meta data for post with author, date, and tags
22
import Link from "next/link"
33

4+
import { TPostItem } from "database"
45
import dayjs from "dayjs"
56
import { Avatar, AvatarFallback, AvatarImage } from "ui"
67

7-
import { TPostItem } from "@/types/posts"
8-
98
export type PostMetaProps = {
109
post: TPostItem
1110
}

apps/web/app/[lang]/(public)/page.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Suspense } from "react"
22
import { Metadata } from "next"
33

4+
import { PostStatus } from "database"
45
import { PostSkeleton } from "ui"
56

67
import Filter from "@/molecules/home/filter"
@@ -16,7 +17,11 @@ export default async function Page() {
1617
<div>
1718
<Filter />
1819
<Suspense fallback={<PostSkeleton total={10} />}>
19-
<PostList />
20+
<PostList
21+
getPostParams={{
22+
postStatus: PostStatus.PUBLISHED,
23+
}}
24+
/>
2025
</Suspense>
2126
</div>
2227
)

apps/web/app/[lang]/(public-fullwidth)/posts/[postId]/page.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ export default async function Page({
3333
const post = await getPost({ postIdOrSlug: params?.postId })
3434
const session = await getServerSession()
3535

36+
console.log(">>>>", post)
37+
3638
if (
3739
!post ||
3840
(post.data?.postStatus === PostStatus.DRAFT && session?.user?.id !== post?.data?.author?.id)

packages/database/src/posts/queries.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export const getPost = async ({
3030
})
3131

3232
if (!post) {
33-
return {
33+
throw {
3434
error: "NOT_FOUND",
3535
}
3636
}
@@ -39,8 +39,9 @@ export const getPost = async ({
3939
data: post,
4040
}
4141
} catch (error) {
42-
return {
42+
throw {
4343
error,
44+
data: null,
4445
}
4546
}
4647
}

0 commit comments

Comments
 (0)