@@ -9,7 +9,7 @@ import FlexBox from '../../../../ui/FlexBox';
9
9
10
10
export default function Upload ( ) {
11
11
const [ postText , setPostText ] = useState ( '' ) ;
12
- const [ isLoading , setIsLoading ] = useState ( false ) ;
12
+ const [ isUploading , setIsUploading ] = useState ( false ) ;
13
13
14
14
const maxCharacters = 100 ;
15
15
const isOverMaxChar = postText . length > maxCharacters ;
@@ -21,17 +21,15 @@ export default function Upload() {
21
21
// 데이터 전송을 위한 함수
22
22
const onUploadBoard = async ( ) => {
23
23
if ( ! postText || isOverMaxChar ) {
24
- return ; // Don't proceed if postText is empty or over the character limit.
24
+ return ;
25
25
}
26
-
27
- setIsLoading ( true ) ;
26
+ setIsUploading ( true ) ;
28
27
try {
29
28
const response = await postBoard ( {
30
29
title : 'title' ,
31
30
content : postText ,
32
31
} ) ;
33
- console . log ( response ) ;
34
- if ( response . ok ) {
32
+ if ( response . content ) {
35
33
Toast . success ( '게시물이 성공적으로 업로드되었습니다.' ) ;
36
34
setPostText ( '' ) ;
37
35
} else {
@@ -40,7 +38,7 @@ export default function Upload() {
40
38
} catch ( error ) {
41
39
Toast . error ( '오류가 발생했습니다. 잠시 후 다시 시도해주세요.' ) ;
42
40
} finally {
43
- setIsLoading ( false ) ;
41
+ setIsUploading ( false ) ;
44
42
}
45
43
} ;
46
44
@@ -78,14 +76,18 @@ export default function Upload() {
78
76
>
79
77
파일
80
78
</ Button >
81
- < Button
82
- size = "lg"
83
- disabled = { isOverMaxChar }
84
- className = "w-40"
85
- onClickAction = { ( ) => onUploadBoard ( ) }
86
- >
87
- 업로드
88
- </ Button >
79
+ { isUploading ? (
80
+ < div > 업로드 중</ div >
81
+ ) : (
82
+ < Button
83
+ size = "lg"
84
+ disabled = { isOverMaxChar }
85
+ className = "w-40"
86
+ onClickAction = { ( ) => onUploadBoard ( ) }
87
+ >
88
+ 업로드
89
+ </ Button >
90
+ ) }
89
91
< div className = "mt-4" id = "renderedText" />
90
92
</ FlexBox >
91
93
</ form >
0 commit comments