@@ -10,7 +10,6 @@ import Download from '@/assets/icons/download.svg';
1010import { useBusinessStore } from '@/store/business.store' ;
1111import { downloadPDF } from '@/lib/pdfDownload' ;
1212import { patchBusinessPlanTitle } from '@/api/business' ;
13- import { usePostGrade } from '@/hooks/mutation/usePostGrade' ;
1413
1514const BusinessHeaderContent = ( ) => {
1615 const router = useRouter ( ) ;
@@ -27,7 +26,6 @@ const BusinessHeaderContent = () => {
2726 loadTitleFromAPI,
2827 } = useBusinessStore ( ) ;
2928
30- // URL의 planId 또는 store의 planId로 제목 조회
3129 useEffect ( ( ) => {
3230 const planIdParam = searchParams . get ( 'planId' ) ;
3331 const targetPlanId = planIdParam ? parseInt ( planIdParam , 10 ) : planId ;
@@ -37,13 +35,13 @@ const BusinessHeaderContent = () => {
3735 return ;
3836 }
3937
40- // planId가 변경되었을 때만 제목 로드 (중복 요청 방지)
4138 let isCancelled = false ;
4239 loadTitleFromAPI ( targetPlanId )
4340 . then ( ( loadedTitle ) => {
4441 if ( ! isCancelled && loadedTitle ) {
45- // 제목이 로드되었을 때만 업데이트 (planId가 변경되지 않았는지 확인)
46- const currentPlanId = planIdParam ? parseInt ( planIdParam , 10 ) : planId ;
42+ const currentPlanId = planIdParam
43+ ? parseInt ( planIdParam , 10 )
44+ : planId ;
4745 if ( currentPlanId === targetPlanId ) {
4846 setTitle ( loadedTitle ) ;
4947 }
@@ -60,7 +58,6 @@ const BusinessHeaderContent = () => {
6058 } ;
6159 } , [ searchParams , planId , loadTitleFromAPI , setTitle ] ) ;
6260
63- // 제목 변경 시 API 요청 (debounce 적용)
6461 useEffect ( ( ) => {
6562 const trimmedTitle = title . trim ( ) ;
6663
@@ -87,7 +84,7 @@ const BusinessHeaderContent = () => {
8784 const [ isModalOpen , setIsModalOpen ] = useState ( false ) ;
8885 const isSaving = useBusinessStore ( ( state ) => state . isSaving ) ;
8986
90- const { mutate : postGradeMutate , isPending : isGrading } = usePostGrade ( ) ;
87+ const [ gradingPlanId , setGradingPlanId ] = useState < number | null > ( null ) ;
9188
9289 const handleOpenModal = ( ) => setIsModalOpen ( true ) ;
9390 const handleCloseModal = ( ) => setIsModalOpen ( false ) ;
@@ -115,11 +112,10 @@ const BusinessHeaderContent = () => {
115112 if ( id == null ) throw new Error ( 'planId 생성에 실패했습니다.' ) ;
116113
117114 await saveAllItems ( id ) ;
115+ setGradingPlanId ( id ) ;
118116 handleOpenModal ( ) ;
119- postGradeMutate ( id , {
120- onSuccess : ( ) => router . push ( '/report' ) ,
121- onError : ( e ) => console . error ( '채점 실패:' , e ) ,
122- } ) ;
117+ } catch ( error ) {
118+ console . error ( '채점 준비 중 오류:' , error ) ;
123119 } finally {
124120 setIsSaving ( false ) ;
125121 }
@@ -142,14 +138,13 @@ const BusinessHeaderContent = () => {
142138 < div className = "flex w-full items-center justify-between px-8 pt-3" >
143139 < div
144140 onClick = { ( ) => {
145- // 미리보기 모드일 때는 작성 화면으로 전환
146141 if ( isPreview ) {
147142 setPreview ( false ) ;
148143 } else {
149144 router . back ( ) ;
150145 }
151146 } }
152- className = "flex cursor-pointer items-center justify-center gap-1 rounded-[8px] px-4 py-[6px] active:bg-gray-200"
147+ className = "flex cursor-pointer items-center justify-center gap-1 rounded-lg px-4 py-1.5 active:bg-gray-200"
153148 >
154149 < Back />
155150 < span className = "ds-text font-medium whitespace-nowrap text-gray-600" >
@@ -176,7 +171,7 @@ const BusinessHeaderContent = () => {
176171 placeholder = "제목을 입력하세요."
177172 aria-label = "문서 제목"
178173 style = { { width : inputWidth } }
179- className = "ds-text hover:border-primary-200 rounded-[8px] bg-white px-3 py-[6px] text-start font-medium overflow-ellipsis transition-[width] duration-200 ease-out placeholder:text-gray-400 hover:border-[1.2px] focus:outline-none"
174+ className = "ds-text hover:border-primary-200 rounded-lg bg-white px-3 py-1.5 text-start font-medium overflow-ellipsis transition-[width] duration-200 ease-out placeholder:text-gray-400 hover:border-[1.2px] focus:outline-none"
180175 />
181176 </ >
182177 ) }
@@ -188,17 +183,16 @@ const BusinessHeaderContent = () => {
188183 < button
189184 type = "button"
190185 onClick = { handleDownloadPDF }
191- className = "flex h-[33px] w-[33px] cursor-pointer items-center justify-center rounded-[8px] border-[1.2px] border-gray-200 transition-colors hover:bg-gray-100 focus:outline-none"
186+ className = "flex h-[33px] w-[33px] cursor-pointer items-center justify-center rounded-lg border-[1.2px] border-gray-200 transition-colors hover:bg-gray-100 focus:outline-none"
192187 >
193188 < Download />
194189 </ button >
195- < div className = "h-[32px] w-[1.6px] bg-gray-200" />
190+ < div className = "h-8 w-[1.6px] bg-gray-200" />
196191 < Button
197- text = { isGrading ? '채점 중...' : ' 채점하기' }
192+ text = " 채점하기"
198193 size = "M"
199194 color = "primary"
200- className = { `ds-subtext h-[33px] rounded-[8px] px-4 py-[6px] ${ isGrading ? 'pointer-events-none opacity-50' : '' } ` }
201- disabled = { isGrading }
195+ className = "ds-subtext h-[33px] rounded-lg px-4 py-1.5"
202196 onClick = { handleGrade }
203197 />
204198 </ >
@@ -208,7 +202,6 @@ const BusinessHeaderContent = () => {
208202 < button
209203 type = "button"
210204 onClick = { ( ) => {
211- // window에 등록된 토글 함수 호출
212205 if ( typeof window !== 'undefined' ) {
213206 const win = window as Window & {
214207 togglePreview ?: ( ) => void ;
@@ -218,12 +211,12 @@ const BusinessHeaderContent = () => {
218211 }
219212 }
220213 } }
221- className = "flex h-[33px] w-[33px] cursor-pointer items-center justify-center rounded-[8px] border-[1.2px] border-gray-200 transition-colors hover:bg-gray-100 focus:outline-none"
214+ className = "flex h-[33px] w-[33px] cursor-pointer items-center justify-center rounded-lg border-[1.2px] border-gray-200 transition-colors hover:bg-gray-100 focus:outline-none"
222215 >
223216 < Eye />
224217 </ button >
225218 < div className = "pointer-events-none absolute top-10 left-1/2 hidden -translate-x-1/2 group-hover:block" >
226- < div className = "relative h-[44px] w-[73px] select-none" >
219+ < div className = "relative h-11 w-[73px] select-none" >
227220 < Image
228221 src = "/images/bubble.png"
229222 alt = "미리보기 호버 말풍선"
@@ -243,24 +236,30 @@ const BusinessHeaderContent = () => {
243236 type = "button"
244237 onClick = { handleSave }
245238 disabled = { isSaving }
246- className = { `text-primary-500 border-primary-500 ds-subtext flex h-[33px] items-center justify-center rounded-[8px] border-[1.2px] px-3 py-2 font-medium transition ${ isSaving ? 'cursor-not-allowed opacity-50' : 'hover:bg-primary-50 cursor-pointer' } ` }
239+ className = { `text-primary-500 border-primary-500 ds-subtext flex h-[33px] items-center justify-center rounded-[8px] border-[1.2px] px-3 py-2 font-medium transition ${
240+ isSaving
241+ ? 'cursor-not-allowed opacity-50'
242+ : 'hover:bg-primary-50 cursor-pointer'
243+ } `}
247244 >
248245 { isSaving ? '저장 중...' : '임시 저장' }
249246 </ button >
250247 < Button
251- text = { isGrading ? '채점 중...' : ' 채점하기' }
248+ text = " 채점하기"
252249 size = "M"
253250 color = "primary"
254- className = { `ds-subtext h-[33px] rounded-[8px] px-4 py-[6px] ${ isSaving || isGrading ? 'pointer-events-none opacity-50' : '' } ` }
255- disabled = { isSaving || isGrading }
251+ className = { `ds-subtext h-[33px] rounded-lg px-4 py-1.5 ${
252+ isSaving ? 'pointer-events-none opacity-50' : ''
253+ } `}
254+ disabled = { isSaving }
256255 onClick = { handleGrade }
257256 />
258257 </ div >
259258 </ >
260259 ) }
261260 </ div >
262261
263- { isModalOpen && (
262+ { isModalOpen && gradingPlanId && (
264263 < CreateModal
265264 title = "AI로 사업계획서 채점하기"
266265 imageSrc = "/images/grading_Image.png"
@@ -269,9 +268,9 @@ const BusinessHeaderContent = () => {
269268 imageHeight = { 202 }
270269 subtitle = { `방금 작성하신 사업계획서를 항목별로 분석해 점수·강점·리스크를 즉시 제공해드려요.\n70점 이상이면, 아이템에 맞는 전문가 추천까지 제공해드려요.` }
271270 onClose = { handleCloseModal }
272- buttonText = { isGrading ? '채점 중...' : '결과 보기' }
271+ buttonText = "채점하기"
273272 onClick = { ( ) => {
274- if ( ! isGrading ) router . push ( '/report' ) ;
273+ router . push ( `/loading?planId= ${ gradingPlanId } ` ) ;
275274 } }
276275 />
277276 ) }
0 commit comments