@@ -12,6 +12,7 @@ const WhitebookUpdateModal = ({ trigger, whitebook }) => {
12
12
const [ showOnlyLogin , setShowOnlyLogin ] = useState ( whitebook . show_only_login ) ;
13
13
const [ inputType , setInputType ] = useState ( whitebook . link ? 'link' : 'pdf' ) ;
14
14
const [ link , setLink ] = useState ( whitebook . link || '' ) ;
15
+ const [ uploadedPDFLink , setUploadedPDFLink ] = useState ( null ) ;
15
16
const [ pdfFile , setPdfFile ] = useState ( null ) ;
16
17
17
18
const handleModalOpen = ( ) => {
@@ -20,11 +21,8 @@ const WhitebookUpdateModal = ({ trigger, whitebook }) => {
20
21
if ( whitebook . link && whitebook . link . includes ( 'whitebook' ) ) {
21
22
const link = whitebook . link ;
22
23
setLink ( '' ) ;
24
+ setUploadedPDFLink ( link ) ;
23
25
setInputType ( 'pdf' ) ;
24
- fetch ( link )
25
- . then ( ( res ) => res . blob ( ) )
26
- . then ( ( blob ) => setPdfFile ( blob ) )
27
- . catch ( ( err ) => console . error ( err ) ) ;
28
26
}
29
27
} ;
30
28
@@ -133,16 +131,18 @@ const WhitebookUpdateModal = ({ trigger, whitebook }) => {
133
131
onChange = { ( e ) => handleFileChange ( e . target . files [ 0 ] ) }
134
132
/>
135
133
< label >
136
- { pdfFile && (
134
+ { ( pdfFile || uploadedPDFLink ) && (
137
135
< a
138
- href = { URL . createObjectURL ( pdfFile ) }
136
+ href = {
137
+ pdfFile ? URL . createObjectURL ( pdfFile ) : uploadedPDFLink
138
+ }
139
139
target = "_blank"
140
140
rel = "noopener noreferrer"
141
141
style = { {
142
142
textDecoration : 'underline' ,
143
143
} }
144
144
>
145
- 업로드한 PDF 확인
145
+ { pdfFile ? pdfFile . name : '기존 PDF 확인' }
146
146
</ a >
147
147
) }
148
148
</ label >
0 commit comments