Skip to content

Commit ae9a652

Browse files
committed
Feat: 이미지 업로드 3 #65
1 parent 3cbf1af commit ae9a652

File tree

2 files changed

+19
-13
lines changed

2 files changed

+19
-13
lines changed

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

+14-8
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22

33
import { useEffect, useState } from 'react';
44
import usePostBoard from '@/hooks/mutations/usePostBoard';
5-
import useImageUpload from '@/hooks/common/useImageUpload';
6-
import Image from 'next/image';
5+
// import useImageUpload from '@/hooks/common/useImageUpload';
6+
// import Image from 'next/image';
7+
// import usePostImageBoard from '@/hooks/mutations/usePostImageBoard';
78
import Avatar from '../../../../ui/Avatar';
89
import Button from '../../../../ui/Button';
910
import FlexBox from '../../../../ui/FlexBox';
@@ -17,7 +18,7 @@ export default function Upload({
1718
}) {
1819
const [postText, setPostText] = useState('');
1920
const { mutate: postBoard, isLoading, isSuccess } = usePostBoard(postText);
20-
const { handleImageUpload, imageFile, imagePreview } = useImageUpload();
21+
// const { handleImageUpload, imageFile, imagePreview } = useImageUpload();
2122

2223
const maxCharacters = 100;
2324
const isOverMaxChar = postText.length > maxCharacters;
@@ -26,7 +27,12 @@ export default function Upload({
2627
setPostText(event.target.value);
2728
};
2829
useEffect(() => {
29-
if (isSuccess) setPostText('');
30+
if (isSuccess) {
31+
setPostText('');
32+
}
33+
// if (isSuccess && imageFile) {
34+
// const { mutate: postImage, isLoading } = usePostImageBoard();
35+
// }
3036
}, [isSuccess]);
3137

3238
return (
@@ -53,7 +59,7 @@ export default function Upload({
5359
) : null}
5460
</div>
5561
</FlexBox>
56-
{imagePreview && (
62+
{/* {imagePreview && (
5763
<div className="relative w-full m-5 h-60 ">
5864
<Image
5965
fill
@@ -63,9 +69,9 @@ export default function Upload({
6369
className="rounded-[10px] object-contain"
6470
/>
6571
</div>
66-
)}
72+
)} */}
6773
<FlexBox justify="end" className="gap-[10px] w-full">
68-
<label
74+
{/* <label
6975
htmlFor="image"
7076
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"
7177
>
@@ -79,7 +85,7 @@ export default function Upload({
7985
className="hidden"
8086
accept="image/*"
8187
/>
82-
</label>
88+
</label> */}
8389
<Button
8490
size="lg"
8591
disabled={postText.length === 0 || isOverMaxChar || isLoading}

hooks/mutations/usePostImageBoard.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { postImageBoard } from '@/service/board';
2-
// import Toast from '@/utils/notification';
2+
import Toast from '@/utils/notification';
33
import { useMutation, useQueryClient } from '@tanstack/react-query';
44

55
export default function usePostImageBoard(
@@ -10,13 +10,13 @@ export default function usePostImageBoard(
1010
const { mutate, isLoading, isSuccess } = useMutation({
1111
mutationFn: () => postImageBoard(boardId, { files: postImageUrl }),
1212
onSuccess: () => {
13-
// Toast.success('게시글이 성공적으로 업로드 되었습니다.');
13+
Toast.success('게시글이 성공적으로 업로드 되었습니다.');
1414
queryClient.invalidateQueries(['boardList']);
1515
},
1616
onError: () => {
17-
// Toast.error(
18-
// '게시글을 업로드하지 못했습니다. 잠시후 다시 시도해주세요.🥲',
19-
// );
17+
Toast.error(
18+
'게시글을 업로드하지 못했습니다. 잠시후 다시 시도해주세요.🥲',
19+
);
2020
},
2121
});
2222
return { mutate, isLoading, isSuccess };

0 commit comments

Comments
 (0)