Skip to content

Commit 430b214

Browse files
committed
Feat: 이미지 업로드 1 #65
1 parent dbb8d19 commit 430b214

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

components/pages/main/Feed/FeedHeader/Upload.tsx

+16-10
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
'use client';
22

33
import { useEffect, useState } from 'react';
4-
import Toast from '@/utils/notification';
54
import usePostBoard from '@/hooks/mutations/usePostBoard';
5+
import useImageUpload from '@/hooks/common/useImageUpload';
66
import Avatar from '../../../../ui/Avatar';
77
import Button from '../../../../ui/Button';
88
import FlexBox from '../../../../ui/FlexBox';
@@ -16,6 +16,7 @@ export default function Upload({
1616
}) {
1717
const [postText, setPostText] = useState('');
1818
const { mutate: postBoard, isLoading, isSuccess } = usePostBoard(postText);
19+
const { handleImageUpload, imageFile, imagePreview } = useImageUpload();
1920

2021
const maxCharacters = 100;
2122
const isOverMaxChar = postText.length > maxCharacters;
@@ -52,15 +53,21 @@ export default function Upload({
5253
</div>
5354
</FlexBox>
5455
<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"
6159
>
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>
6471
<Button
6572
size="lg"
6673
disabled={postText.length === 0 || isOverMaxChar || isLoading}
@@ -69,7 +76,6 @@ export default function Upload({
6976
>
7077
{isLoading ? '업로드 중입니다' : '업로드'}
7178
</Button>
72-
<div className="mt-4" id="renderedText" />
7379
</FlexBox>
7480
</form>
7581
);

0 commit comments

Comments
 (0)