File tree 1 file changed +20
-4
lines changed
components/pages/main/Feed/FeedHeader
1 file changed +20
-4
lines changed Original file line number Diff line number Diff line change 2
2
3
3
import { useState } from 'react' ;
4
4
import Toast from '@/utils/notification' ;
5
+ import { postBoard } from '@/service/board' ;
5
6
import Avatar from '../../../../ui/Avatar' ;
6
7
import Button from '../../../../ui/Button' ;
7
8
import FlexBox from '../../../../ui/FlexBox' ;
8
9
9
10
export default function Upload ( ) {
10
11
const [ postText , setPostText ] = useState ( '' ) ;
12
+ const [ isLoading , setIsLoading ] = useState ( false ) ;
11
13
12
14
const maxCharacters = 100 ;
13
15
const isOverMaxChar = postText . length > maxCharacters ;
@@ -16,10 +18,24 @@ export default function Upload() {
16
18
setPostText ( event . target . value ) ;
17
19
} ;
18
20
21
+ const onUploadBoard = async ( data : string ) => {
22
+ setIsLoading ( true ) ;
23
+ try {
24
+ const response = await postBoard ( {
25
+ title : 'title' ,
26
+ content : data ,
27
+ } ) ;
28
+ } catch ( error ) {
29
+ Toast . error ( '잠시 후 다시 시도해주세요.' ) ;
30
+ } finally {
31
+ setIsLoading ( false ) ;
32
+ }
33
+ } ;
34
+
19
35
return (
20
- < FlexBox
21
- direction = "column"
22
- className = "bg-primary-50 p-5 border-[1px] border-primary-300 rounded-[10px] w-full"
36
+ < form
37
+ onSubmit = { onUploadBoard }
38
+ className = "flex flex-col bg-primary-50 p-5 border-[1px] border-primary-300 rounded-[10px] w-full"
23
39
>
24
40
< FlexBox justify = "between" className = "w-full gap-[24px]" >
25
41
< Avatar
@@ -63,6 +79,6 @@ export default function Upload() {
63
79
</ Button >
64
80
< div className = "mt-4" id = "renderedText" />
65
81
</ FlexBox >
66
- </ FlexBox >
82
+ </ form >
67
83
) ;
68
84
}
You can’t perform that action at this time.
0 commit comments