diff --git a/packages/client/src/shared/lib/types/post.ts b/packages/client/src/shared/lib/types/post.ts index efaddd6..fb8738b 100644 --- a/packages/client/src/shared/lib/types/post.ts +++ b/packages/client/src/shared/lib/types/post.ts @@ -5,3 +5,5 @@ export interface PostData { images: string[]; like_cnt?: number; } + +export type TextStateTypes = 'DEFAULT' | 'INVALID' | 'OVER'; diff --git a/packages/client/src/widgets/postModal/ui/PostModal.tsx b/packages/client/src/widgets/postModal/ui/PostModal.tsx index 4bfcfa9..dad3bf5 100644 --- a/packages/client/src/widgets/postModal/ui/PostModal.tsx +++ b/packages/client/src/widgets/postModal/ui/PostModal.tsx @@ -6,11 +6,13 @@ import { useLocation, useNavigate, useParams } from 'react-router-dom'; import remarkGfm from 'remark-gfm'; import { instance } from 'shared/apis'; import { useCheckNickName, useFetch, useRefresh } from 'shared/hooks'; -import { PostData } from 'shared/lib'; +import { PostData, TextStateTypes } from 'shared/lib'; import { useCameraStore, useToastStore, useViewStore } from 'shared/store'; import { AlertDialog, Button, Input, Modal, TextArea } from 'shared/ui'; import { deletePost } from '../api/deletePost'; import ImageSlider from './ImageSlider'; +import { Caption } from 'shared/styles'; +import { css } from '@emotion/react'; export default function PostModal() { const [deleteModal, setDeleteModal] = useState(false); @@ -19,6 +21,8 @@ export default function PostModal() { const [title, setTitle] = useState(''); const [isDeleteButtonDisabled, setIsDeleteButtonDisabled] = useState(false); const [isSaveButtonDisabled, setIsSaveButtonDisabled] = useState(false); + const [titleState, setTitleState] = useState('DEFAULT'); + const [contentState, setContentState] = useState('DEFAULT'); const { setToast } = useToastStore(); const { setView } = useViewStore(); @@ -44,7 +48,6 @@ export default function PostModal() { const formData = new FormData(); formData.append('title', title); formData.append('content', content); - try { await instance({ url: `/post/${postId}`, @@ -105,6 +108,8 @@ export default function PostModal() { buttonType="CTA-icon" type="button" onClick={() => { + if (title === '') return setTitleState('INVALID'); + if (content === '') return setContentState('INVALID'); setIsEdit(false); handleEditSave(); }} @@ -160,21 +165,44 @@ export default function PostModal() { )} {isEdit ? ( - setTitle(e.target.value)} - /> -