@@ -82,6 +82,7 @@ export interface PostDetail {
8282
8383const Detail = ( ) => {
8484 const [ script , setScript ] = useState < PostDetail > ( ) ;
85+ const [ description , setDescription ] = useState < string > ( "" ) ;
8586 const [ bottomBarStyle , setBottomBarStyle ] = useState < React . CSSProperties > ( {
8687 position : "fixed" ,
8788 display : "none" , // bottom bar 비활성화
@@ -124,18 +125,17 @@ const Detail = () => {
124125 setReviews ( [ ] ) ;
125126 setReviewPage ( 0 ) ;
126127
128+ const headers : Record < string , string > = {
129+ "Content-Type" : "application/json" ,
130+ } ;
131+
132+ const token = Cookies . get ( "accessToken" ) ;
133+ if ( token ) {
134+ headers [ "Authorization" ] = `Bearer ${ token } ` ;
135+ }
127136 try {
128137 setIsLoading ( true ) ;
129138
130- const headers : Record < string , string > = {
131- "Content-Type" : "application/json" ,
132- } ;
133-
134- const token = Cookies . get ( "accessToken" ) ;
135- if ( token ) {
136- headers [ "Authorization" ] = `Bearer ${ token } ` ;
137- }
138-
139139 const response = await axios . get ( `${ SERVER_URL } scripts/detail` , {
140140 headers : headers ,
141141 params : {
@@ -156,7 +156,6 @@ const Detail = () => {
156156 performancePrice : response . data . performancePrice ?? 0 ,
157157 playType : response . data . playType ,
158158 imagePath : response . data . imagePath ,
159- descriptionPath : response . data . descriptionPath ,
160159 buyStatus : response . data . buyStatus ,
161160 like : response . data . like ,
162161 likeCount : response . data . likeCount ,
@@ -187,6 +186,19 @@ const Detail = () => {
187186 console . error ( "❌ 서버 응답:" , errMsg ) ;
188187 }
189188 setIsLoading ( false ) ;
189+
190+ const { data : description } = await axios . get (
191+ `${ SERVER_URL } scripts/description` ,
192+ {
193+ headers : headers ,
194+ params : {
195+ script : id ,
196+ } ,
197+ responseType : "blob" ,
198+ }
199+ ) ;
200+
201+ setDescription ( URL . createObjectURL ( description ) ) ;
190202 } ;
191203
192204 getDetail ( ) ;
@@ -386,6 +398,29 @@ const Detail = () => {
386398 return count ;
387399 } ;
388400
401+ const renderReviewWriteButton = ( ) => {
402+ return (
403+ < button
404+ className = "p-large-medium flex justify-end items-center gap-[10px] cursor-pointer hover:text-[#6A39C0]"
405+ onClick = { ( ) => {
406+ if ( script ?. isReviewWritten ) {
407+ alert ( "이미 작성된 후기가 있습니다." ) ;
408+ return ;
409+ }
410+ if ( ! isAuthenticated ) {
411+ alert ( "로그인이 필요한 서비스입니다." ) ;
412+ navigate ( "/signin" ) ;
413+ return ;
414+ }
415+
416+ navigate ( `/list/review/${ id } ` ) ;
417+ } }
418+ >
419+ 후기 작성하기 < img src = { rightArrow } alt = ">" > </ img >
420+ </ button >
421+ ) ;
422+ } ;
423+
389424 return (
390425 < div className = " detail f-dir-column a-items-center" >
391426 < FloatingBtn style = { { bottom : "100px" } } />
@@ -732,9 +767,9 @@ const Detail = () => {
732767
733768 < div className = " j-content-center" >
734769 { /* PDF 삽입 */ }
735- { script ?. descriptionPath ? (
770+ { description ? (
736771 < Document
737- file = { script . descriptionPath }
772+ file = { description }
738773 onLoadSuccess = { onDocumentLoadSuccess }
739774 loading = { < PartialLoading /> }
740775 >
@@ -761,20 +796,7 @@ const Detail = () => {
761796 )
762797 </ p >
763798 < div className = "flex justify-end w-full" >
764- < button
765- className = "p-large-medium flex justify-end items-center gap-[10px] cursor-pointer hover:text-[#6A39C0]"
766- onClick = { ( ) => {
767- if ( ! isAuthenticated ) {
768- alert ( "로그인이 필요한 서비스입니다." ) ;
769- navigate ( "/signin" ) ;
770- return ;
771- }
772-
773- navigate ( `/list/review/${ id } ` ) ;
774- } }
775- >
776- 후기 작성하기 < img src = { rightArrow } alt = ">" > </ img >
777- </ button >
799+ { renderReviewWriteButton ( ) }
778800 </ div >
779801 </ section >
780802 < ReviewSummary stats = { script ?. reviewStatistics ! } />
@@ -829,27 +851,42 @@ const Detail = () => {
829851 ) }
830852 </ div >
831853
832- { reviews . map ( ( review ) => (
833- < ReviewList
834- key = { review . id }
835- scriptId = { script ?. id ! }
836- review = { review }
837- />
838- ) ) }
854+ { reviews . length > 0 ? (
855+ reviews . map ( ( review ) => (
856+ < ReviewList
857+ key = { review . id }
858+ scriptId = { script ?. id ! }
859+ review = { review }
860+ />
861+ ) )
862+ ) : (
863+ < div className = "flex flex-col w-full" >
864+ < hr className = "m-[0px] mb-[74px] w-full bg-[#9E9E9E]" />
865+ < p className = "p-large-bold text-center" >
866+ 작품의 후기를 남겨주세요.
867+ </ p >
868+ < div className = "mt-[25px] flex justify-center w-full" >
869+ { renderReviewWriteButton ( ) }
870+ </ div >
871+ </ div >
872+ ) }
839873 </ section >
840874 </ section >
841875
842- < ReviewPagination
843- currentPage = { reviewPage + 1 }
844- totalPages = {
845- Math . ceil ( ( script ?. reviewStatistics ?. totalReviewCount ?? 5 ) / 5 ) ??
846- 1
847- }
848- onPageChange = { ( page ) => {
849- // 0 base로 parsing 필요
850- setReviewPage ( page - 1 ) ;
851- } }
852- />
876+ { reviews . length > 0 && (
877+ < ReviewPagination
878+ currentPage = { reviewPage + 1 }
879+ totalPages = {
880+ Math . ceil (
881+ ( script ?. reviewStatistics ?. totalReviewCount ?? 5 ) / 5
882+ ) ?? 1
883+ }
884+ onPageChange = { ( page ) => {
885+ // 0 base로 parsing 필요
886+ setReviewPage ( page - 1 ) ;
887+ } }
888+ />
889+ ) }
853890 </ div >
854891
855892 { ! isDetailBtnVisible && (
0 commit comments