File tree Expand file tree Collapse file tree 2 files changed +11
-11
lines changed
Expand file tree Collapse file tree 2 files changed +11
-11
lines changed Original file line number Diff line number Diff line change 1- 'use client' ;
2-
31import React , { Suspense } from 'react' ;
4- import { useSession } from 'next-auth/react ' ;
2+ import { getServerSession } from 'next-auth' ;
53import '@/styles/pages/community/community.scss' ;
64import ErrorBoundary from '@/components/common/ErrorBoundary' ;
75import LoadingSpinner from '@/components/common/LoadingSpinner' ;
86import EditPostContent from '@/components/community/EditPostContent' ;
7+ import { authOptions } from '@/app/auth/authOptions' ;
98import { ERROR_MESSAGES } from '@/constants/errors' ;
109
11- export default function EditPostPage ( { params } : { params : { id : string } } ) {
12- const { data : session } = useSession ( ) ;
13- const userId = session ?. user ?. id ;
14-
15- if ( ! userId ) {
10+ export default async function EditPostPage ( { params } : { params : { id : string } } ) {
11+ const session = await getServerSession ( authOptions ) ;
12+
13+ if ( ! session ?. user ?. id ) {
1614 throw new Error ( ERROR_MESSAGES . LOGIN_REQUIRED ) ;
1715 }
16+
17+ const userId = session . user . id ;
1818
1919 return (
2020 < ErrorBoundary >
Original file line number Diff line number Diff line change @@ -7,11 +7,11 @@ import { ALERT_MESSAGES } from '@/constants/alertMessage';
77import { ERROR_MESSAGES } from '@/constants/errors' ;
88
99// 게시글 데이터 가져오기
10- export function usePostEditData ( id : string , userId : string | undefined ) {
10+ export function usePostEditData ( id : string , userId : string ) {
1111 const router = useRouter ( ) ;
1212
1313 return useSuspenseQuery ( {
14- queryKey : [ 'post-edit' , id ] ,
14+ queryKey : [ 'post-edit' , id , userId ] ,
1515 queryFn : async ( ) => {
1616 const response = await axiosInstance . get ( `${ API_URLS . POSTS } /${ id } ` ) ;
1717 const post = response . data ;
@@ -86,7 +86,7 @@ export function useDeletePost(id: string) {
8686 } ) ;
8787}
8888
89- export const usePostEdit = ( id : string , userId : string | undefined ) => {
89+ export const usePostEdit = ( id : string , userId : string ) => {
9090 const [ title , setTitle ] = useState ( '' ) ;
9191 const [ content , setContent ] = useState ( '' ) ;
9292
You can’t perform that action at this time.
0 commit comments