File tree 4 files changed +28
-12
lines changed
features/post/detail/post
4 files changed +28
-12
lines changed Original file line number Diff line number Diff line change 1
1
'use client'
2
2
3
- import { useAdminSession , useProgressBar } from '@/lib/hooks'
3
+ import { useProgressBar } from '@/lib/hooks'
4
4
import { mainPath } from '@/lib/route'
5
5
import { Button } from '@/lib/ui/button'
6
6
import { Pencil } from 'lucide-react'
Original file line number Diff line number Diff line change 1
1
export * from './delete-post-button'
2
2
export * from './edit-post-button'
3
3
export * from './floating-menu'
4
+ export * from './post-author-buttons'
Original file line number Diff line number Diff line change
1
+ 'use client'
2
+
3
+ import type { FC } from 'react'
4
+ import { EditPostButton } from './edit-post-button'
5
+ import { DeletePostButton } from './delete-post-button'
6
+ import { useAdminSession } from '@/lib/hooks'
7
+
8
+ interface Props {
9
+ postId : string
10
+ }
11
+
12
+ export const PostAuthorButtons : FC < Props > = ( { postId } ) => {
13
+ const { isAdminAuthorized } = useAdminSession ( )
14
+
15
+ return (
16
+ isAdminAuthorized && (
17
+ < div className = 'flex gap-4' >
18
+ < EditPostButton id = { postId } />
19
+ < DeletePostButton id = { postId } />
20
+ </ div >
21
+ )
22
+ )
23
+ }
Original file line number Diff line number Diff line change 1
- import { DeletePostButton , EditPostButton } from '@/features/post/detail/post '
2
- import { getServerAuth } from '@/lib/auth '
1
+ import type { FC } from 'react '
2
+ import { PostAuthorButtons } from '@/features/post/detail/post '
3
3
import { Badge } from '@/lib/ui/badge'
4
4
import { formatDateToFull , textSanitizing } from '@/lib/utils'
5
5
import { Post } from '@prisma/client'
6
- import type { FC } from 'react'
7
6
8
7
interface Props {
9
8
post : Post
10
9
}
11
10
12
11
export const DetailPostWidget : FC < Props > = async ( { post } ) => {
13
- const { isAdminAuthorized } = await getServerAuth ( )
14
-
15
12
return (
16
13
< article className = 'flex flex-col gap-7 text-white rounded-lg pb-14' >
17
14
< section className = 'flex flex-col gap-4 border-b border-b-slate-700 pb-7' >
@@ -34,12 +31,7 @@ export const DetailPostWidget: FC<Props> = async ({ post }) => {
34
31
< div className = 'flex justify-between items-center h-8' >
35
32
< time className = 'text-sm text-gray-500' > { formatDateToFull ( post . createdAt ) } </ time >
36
33
37
- { isAdminAuthorized && (
38
- < div className = 'flex gap-4' >
39
- < EditPostButton id = { post . id } />
40
- < DeletePostButton id = { post . id } />
41
- </ div >
42
- ) }
34
+ < PostAuthorButtons postId = { post . id } />
43
35
</ div >
44
36
</ div >
45
37
</ section >
You can’t perform that action at this time.
0 commit comments