11// 코디 추천 결과랑 가상피팅 결과를 조건문 써서 2개 렌더링하기
2- import React , { useEffect , useState } from 'react' ;
2+ import React , { useEffect , useState } from 'react' ;
33import { useNavigate } from 'react-router-dom' ;
4- import { ShowResultBox , Result , DateText , InfoBoldText , InfoNormalText , InfoContainer , InfoWrapper , Line , ReviewWrapper , WriteReviewBox , ReviewButton } from './style' ;
4+ import {
5+ ShowResultBox ,
6+ Result ,
7+ DateText ,
8+ InfoBoldText ,
9+ InfoNormalText ,
10+ InfoContainer ,
11+ InfoWrapper ,
12+ Line ,
13+ ReviewWrapper ,
14+ WriteReviewBox ,
15+ ReviewButton ,
16+ } from './style' ;
517import Header from '../../components/Header' ;
618import ClickButton from '../../components/Button/ClickButton' ;
7- import { privateAxiosInstance } from " ../../apis/axiosInstance" ;
8- import { ReactComponent as Spinner } from '../../assets/spin.svg'
19+ import { privateAxiosInstance } from ' ../../apis/axiosInstance' ;
20+ import { ReactComponent as Spinner } from '../../assets/spin.svg' ;
921
1022interface Clothes {
1123 id : number ;
@@ -35,7 +47,7 @@ interface ApiData {
3547 review ?: Review ;
3648}
3749
38- const ShowResult : React . FC = ( ) => {
50+ const ShowResult : React . FC = ( ) => {
3951 const searchParams = new URLSearchParams ( window . location . search ) ;
4052 const id = parseInt ( searchParams . get ( 'id' ) || '1' , 10 ) ; // 기본값 1 , 십진수로 받아올 것//isVirtualFitting 값 가져오기
4153 const navigate = useNavigate ( ) ;
@@ -48,18 +60,18 @@ const ShowResult: React.FC= () => {
4860 if ( id ) {
4961 privateAxiosInstance
5062 . get ( `/history/${ id } ` )
51- . then ( ( response ) => {
63+ . then ( response => {
5264 if ( response . data ) {
5365 setData ( response . data ) ;
5466 setLoading ( false ) ;
5567
5668 if ( response . data . history . type ) {
5769 const type = response . data . history . type ;
58- setIsVirtualFitting ( ( type === 'FITTING' ) ) ;
70+ setIsVirtualFitting ( type === 'FITTING' ) ;
5971 }
6072 }
6173 } )
62- . catch ( ( err ) => {
74+ . catch ( err => {
6375 setError ( '데이터를 가져오는데 실패했습니다.' ) ;
6476 console . error ( '데이터를 가져오는데 실패했습니다:' , err ) ;
6577 setLoading ( false ) ;
@@ -72,7 +84,14 @@ const ShowResult: React.FC= () => {
7284
7385 if ( loading ) {
7486 return (
75- < div style = { { display : 'flex' , justifyContent : 'center' , alignItems : 'center' , height : '100vh' } } >
87+ < div
88+ style = { {
89+ display : 'flex' ,
90+ justifyContent : 'center' ,
91+ alignItems : 'center' ,
92+ height : '100vh' ,
93+ } }
94+ >
7695 < Spinner />
7796 </ div >
7897 ) ;
@@ -112,7 +131,21 @@ const ShowResult: React.FC= () => {
112131 < ShowResultBox >
113132 < Header text = { isVirtualFitting ? '가상 피팅 결과' : '코디 추천 결과' } />
114133 < Result >
115- < img src = { data . history . fittingImageURL || data . history . clothesList [ 0 ] ?. imagePath } width = { 432 } alt = "result"
134+ < img
135+ src = {
136+ data . history . fittingImageURL ||
137+ data . history . clothesList [ 0 ] ?. imagePath
138+ }
139+ width = { 432 }
140+ alt = "result"
141+ />
142+ < img
143+ src = {
144+ data . history . fittingImageURL ||
145+ data . history . clothesList [ 1 ] ?. imagePath
146+ }
147+ width = { 432 }
148+ alt = "result2"
116149 />
117150 </ Result >
118151 < InfoWrapper >
@@ -125,19 +158,23 @@ const ShowResult: React.FC= () => {
125158 < ReviewWrapper >
126159 < WriteReviewBox >
127160 < InfoBoldText > 리뷰</ InfoBoldText >
128- { ( ! data . review || ( data . review . text === '' ) ) && (
129- < ReviewButton onClick = { handleClickButton } > 리뷰 남기러 가기{ '>' } </ ReviewButton >
161+ { ( ! data . review || data . review . text === '' ) && (
162+ < ReviewButton onClick = { handleClickButton } >
163+ 리뷰 남기러 가기{ '>' }
164+ </ ReviewButton >
130165 ) }
131166 </ WriteReviewBox >
132167 < InfoNormalText >
133- { ( data . review && data . review . text !== '' ) ? data . review . text : '아직 리뷰를 남기지 않았어요!' }
168+ { data . review && data . review . text !== ''
169+ ? data . review . text
170+ : '아직 리뷰를 남기지 않았어요!' }
134171 </ InfoNormalText >
135172 </ ReviewWrapper >
136- { ! isVirtualFitting && (
137- < ClickButton variant = ' footerButton' onClick = { handleClick } >
138- 가상 피팅 하러 가기
139- </ ClickButton >
140- ) }
173+ { ! isVirtualFitting && (
174+ < ClickButton variant = " footerButton" onClick = { handleClick } >
175+ 가상 피팅 하러 가기
176+ </ ClickButton >
177+ ) }
141178 </ ShowResultBox >
142179 ) ;
143180} ;
0 commit comments