Skip to content

Commit

Permalink
Feat: 업로드 부분 form 태그로 변경 #65
Browse files Browse the repository at this point in the history
  • Loading branch information
jiyeeeah committed Oct 12, 2023
1 parent 97c55ef commit 042a0dd
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions components/pages/main/Feed/FeedHeader/Upload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@

import { useState } from 'react';
import Toast from '@/utils/notification';
import { postBoard } from '@/service/board';
import Avatar from '../../../../ui/Avatar';
import Button from '../../../../ui/Button';
import FlexBox from '../../../../ui/FlexBox';

export default function Upload() {
const [postText, setPostText] = useState('');
const [isLoading, setIsLoading] = useState(false);

const maxCharacters = 100;
const isOverMaxChar = postText.length > maxCharacters;
Expand All @@ -16,10 +18,24 @@ export default function Upload() {
setPostText(event.target.value);
};

const onUploadBoard = async (data: string) => {
setIsLoading(true);
try {
const response = await postBoard({
title: 'title',
content: data,
});
} catch (error) {
Toast.error('잠시 후 다시 시도해주세요.');
} finally {
setIsLoading(false);
}
};

return (
<FlexBox
direction="column"
className="bg-primary-50 p-5 border-[1px] border-primary-300 rounded-[10px] w-full"
<form
onSubmit={onUploadBoard}
className="flex flex-col bg-primary-50 p-5 border-[1px] border-primary-300 rounded-[10px] w-full"
>
<FlexBox justify="between" className="w-full gap-[24px]">
<Avatar
Expand Down Expand Up @@ -63,6 +79,6 @@ export default function Upload() {
</Button>
<div className="mt-4" id="renderedText" />
</FlexBox>
</FlexBox>
</form>
);
}

0 comments on commit 042a0dd

Please sign in to comment.