From 2ee7b7478d704a3a697cc8bc69d9d8db520ace17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=86=8C=EC=9A=B8=EC=B9=98=ED=82=A8?= <90738604+soulchicken@users.noreply.github.com> Date: Thu, 19 Oct 2023 21:38:51 +0900 Subject: [PATCH] =?UTF-8?q?Feat:=20Toast=EB=A5=BC=20=ED=86=B5=ED=95=B4?= =?UTF-8?q?=EC=84=9C=20=EA=B2=8C=EC=8B=9C=EA=B8=80=20=EC=9C=A0=ED=9A=A8?= =?UTF-8?q?=EC=84=B1=20=EB=B6=88=ED=86=B5=EC=8B=9C=20=EB=A9=94=EC=8B=9C?= =?UTF-8?q?=EC=A7=80=20=EB=9D=84=EC=9A=B0=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/community/[character_id]/edit.tsx | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/pages/community/[character_id]/edit.tsx b/src/pages/community/[character_id]/edit.tsx index 459de14..61c03f5 100644 --- a/src/pages/community/[character_id]/edit.tsx +++ b/src/pages/community/[character_id]/edit.tsx @@ -6,23 +6,32 @@ import DivideLine from '@/components/common/divideLine/DivideLine'; import Button from '@/components/common/button/Button'; import { createPost } from '@/utils/api/boards'; import { useRouter } from 'next/router'; +import Toast from '@/components/common/toast/Toast'; const Post = () => { const [title, setTitle] = useState(''); const [content, setContent] = useState(''); + const [toastMessage, setToastMessage] = useState(''); const router = useRouter(); const { character_id: characterId } = router.query; + const handleToastClose = () => { + setToastMessage(''); + }; + const messageHandler = (message: string) => { + setToastMessage(message); + }; + const handleSubmit = async (e: FormEvent) => { e.preventDefault(); if (characterId && typeof characterId === 'string') { if (title === '' || title.length > 30) { - alert('제목을 30자 이내로 작성해주세요! :)'); + messageHandler('제목을 30자 이내로 작성해주세요! :)'); return; } if (content === '' || content.length > 3000) { - alert('내용은 3000자 이내로 작성해주세요! :)'); + messageHandler('내용은 3000자 이내로 작성해주세요! :)'); return; } @@ -34,7 +43,7 @@ const Post = () => { }); return; } - alert('게시글 작성에 실패했습니다 :('); + messageHandler('게시글 작성에 실패했습니다 :('); } router.push({ pathname: '/community', @@ -60,6 +69,11 @@ const Post = () => { + { + toastMessage + ? + : null + } ); };