1
1
'use client' ;
2
2
3
3
import { useEffect , useState } from 'react' ;
4
- import Toast from '@/utils/notification' ;
5
4
import usePostBoard from '@/hooks/mutations/usePostBoard' ;
5
+ import useImageUpload from '@/hooks/common/useImageUpload' ;
6
6
import Avatar from '../../../../ui/Avatar' ;
7
7
import Button from '../../../../ui/Button' ;
8
8
import FlexBox from '../../../../ui/FlexBox' ;
@@ -16,6 +16,7 @@ export default function Upload({
16
16
} ) {
17
17
const [ postText , setPostText ] = useState ( '' ) ;
18
18
const { mutate : postBoard , isLoading, isSuccess } = usePostBoard ( postText ) ;
19
+ const { handleImageUpload, imageFile, imagePreview } = useImageUpload ( ) ;
19
20
20
21
const maxCharacters = 100 ;
21
22
const isOverMaxChar = postText . length > maxCharacters ;
@@ -52,15 +53,21 @@ export default function Upload({
52
53
</ div >
53
54
</ FlexBox >
54
55
< FlexBox justify = "end" className = "gap-[10px] w-full" >
55
- < Button
56
- size = "lg"
57
- variant = "secondary"
58
- disabled = { isOverMaxChar }
59
- className = "w-40"
60
- onClickAction = { ( ) => Toast . error ( '실패' ) }
56
+ < label
57
+ htmlFor = "image"
58
+ className = "rounded-[10px] h-[54px] w-40 p-2.5 bg-white border border-primary-200 text-primary-200 hover:border-primary-300 hover:text-primary-300 cursor-pointer text-center"
61
59
>
62
- 파일
63
- </ Button >
60
+ < div className = "flex flex-col items-center justify-center w-full h-full" >
61
+ 파일
62
+ </ div >
63
+ < input
64
+ type = "file"
65
+ id = "image"
66
+ onChange = { handleImageUpload }
67
+ className = "hidden"
68
+ accept = "image/*"
69
+ />
70
+ </ label >
64
71
< Button
65
72
size = "lg"
66
73
disabled = { postText . length === 0 || isOverMaxChar || isLoading }
@@ -69,7 +76,6 @@ export default function Upload({
69
76
>
70
77
{ isLoading ? '업로드 중입니다' : '업로드' }
71
78
</ Button >
72
- < div className = "mt-4" id = "renderedText" />
73
79
</ FlexBox >
74
80
</ form >
75
81
) ;
0 commit comments