- ์์ฑํ๊ธฐ
+ {EMPTY_DIARY_TEXT.button}
)}
diff --git a/client/src/components/leaf/LeafDateInfo.tsx b/client/src/components/leaf/LeafDateInfo.tsx
index 8f49e35a..9fb51f43 100644
--- a/client/src/components/leaf/LeafDateInfo.tsx
+++ b/client/src/components/leaf/LeafDateInfo.tsx
@@ -1,3 +1,4 @@
+import { LEAF_DATE_INFO_TEXT } from '@/constants/contents';
import useLeafStore from '@/stores/leafStore';
import { getDayElapsed } from '@/utils/getDayElapsed';
@@ -11,13 +12,13 @@ export default function LeafDateInfo() {
return (
- ํค์ฐ๊ธฐ ์์ํ ์ง :{' '}
+ {LEAF_DATE_INFO_TEXT.firstLine}
{(daysSinceStart as number) + 1}์ผ ์งธ
- ์ต๊ทผ ๊ด๋ฆฌ :{' '}
+ {LEAF_DATE_INFO_TEXT.secondLine}
{recentManaged !== null ? recentManaged + '์ผ ์ ' : '-'}
diff --git a/client/src/components/leaf/LeafDiary.tsx b/client/src/components/leaf/LeafDiary.tsx
index 1ea30fb3..13d9cb1a 100644
--- a/client/src/components/leaf/LeafDiary.tsx
+++ b/client/src/components/leaf/LeafDiary.tsx
@@ -4,10 +4,9 @@ import { DiaryDataInfo } from '@/types/data';
interface LeafDiaryProps {
diaries: DiaryDataInfo[];
- pathUserId: string;
}
-export default function LeafDiary({ diaries, pathUserId }: LeafDiaryProps) {
+export default function LeafDiary({ diaries }: LeafDiaryProps) {
return (
{diaries.map((diary) => (
@@ -18,7 +17,6 @@ export default function LeafDiary({ diaries, pathUserId }: LeafDiaryProps) {
imageUrl={diary.imageUrl}
content={diary.content}
title={diary.title}
- pathUserId={pathUserId}
/>
))}
diff --git a/client/src/components/leaf/LeafInfo.tsx b/client/src/components/leaf/LeafInfo.tsx
index e222655a..dd17aeea 100644
--- a/client/src/components/leaf/LeafInfo.tsx
+++ b/client/src/components/leaf/LeafInfo.tsx
@@ -2,17 +2,16 @@ import Image from 'next/image';
import { useRouter } from 'next/navigation';
import useLeafStore from '@/stores/leafStore';
+import useModalStore from '@/stores/modalStore';
-import PageTitle from '../common/PageTitle';
-import CommonButton from '../common/CommonButton';
+import { PageTitle, CommonButton } from '@/components/common';
+import { LEAF_INFO_TEXT } from '@/constants/contents';
interface LeafInfoProps {
pathUserId: string;
leafName: string;
imageUrl: string;
content: string;
- createdAt: string;
- userId: string | null;
}
export default function LeafInfo({
@@ -20,20 +19,17 @@ export default function LeafInfo({
imageUrl,
content,
pathUserId,
- userId,
}: LeafInfoProps) {
const router = useRouter();
- const setModalCategory = useLeafStore((state) => state.setModalCategory);
- const modalOpen = useLeafStore((state) => state.modalOpen);
-
- const isOwner = userId === pathUserId;
+ const { isOwner } = useLeafStore();
+ const { open, changeType } = useModalStore();
const navigateToGarden = () => router.push(`/garden/${pathUserId}`);
const AddDiary = () => {
- setModalCategory('add');
- modalOpen();
+ changeType('add');
+ open();
};
return (
@@ -53,10 +49,10 @@ export default function LeafInfo({
{isOwner && (
- ์ ์์ ์ค์นํ๊ธฐ
+ {LEAF_INFO_TEXT.button[0]}
- ์ผ์ง ์์ฑ
+ {LEAF_INFO_TEXT.button[1]}
)}
diff --git a/client/src/components/leaf/LeafModal.tsx b/client/src/components/leaf/LeafModal.tsx
index 1abcb7b9..f15b7d72 100644
--- a/client/src/components/leaf/LeafModal.tsx
+++ b/client/src/components/leaf/LeafModal.tsx
@@ -1,12 +1,14 @@
import useLeafStore from '@/stores/leafStore';
import DiaryForm from './DiaryForm';
-import { DiaryDeleteModal } from './DiaryDeleteModal';
+import DiaryDeleteModal from './DiaryDeleteModal';
import ModalPortal from '../common/ModalPortal';
import Modal from '../common/Modal';
+import { ModalType } from '@/stores/modalStore';
+
interface LeafModalProps {
- modalCategory: 'add' | 'edit' | 'delete' | 'share' | null;
+ modalCategory: ModalType;
leafId: string;
userId: string;
}
diff --git a/client/src/components/leaf/index.ts b/client/src/components/leaf/index.ts
new file mode 100644
index 00000000..d4337dd9
--- /dev/null
+++ b/client/src/components/leaf/index.ts
@@ -0,0 +1,19 @@
+import Diary from './Diary';
+import DiaryDeleteModal from './DiaryDeleteModal';
+import DiaryForm from './DiaryForm';
+import EmptyDiary from './EmptyDiary';
+import LeafDateInfo from './LeafDateInfo';
+import LeafDiary from './LeafDiary';
+import LeafInfo from './LeafInfo';
+import LeafModal from './LeafModal';
+
+export {
+ Diary,
+ DiaryDeleteModal,
+ DiaryForm,
+ EmptyDiary,
+ LeafDateInfo,
+ LeafDiary,
+ LeafInfo,
+ LeafModal,
+};
diff --git a/client/src/components/leafs/AddLeafButton.tsx b/client/src/components/leafs/AddLeafButton.tsx
index e7f61c88..1f651fc6 100644
--- a/client/src/components/leafs/AddLeafButton.tsx
+++ b/client/src/components/leafs/AddLeafButton.tsx
@@ -6,7 +6,7 @@ import Link from 'next/link';
import { motion } from 'framer-motion';
interface AddLeafButtonProps {
- userId: number;
+ userId: string;
}
export default function AddLeafButton({ userId }: AddLeafButtonProps) {
diff --git a/client/src/components/leafs/LeafDeleteModal.tsx b/client/src/components/leafs/LeafDeleteModal.tsx
index f7d26c6c..4749a380 100644
--- a/client/src/components/leafs/LeafDeleteModal.tsx
+++ b/client/src/components/leafs/LeafDeleteModal.tsx
@@ -1,58 +1,50 @@
import useLeafsStore from '@/stores/leafsStore';
+import useModalStore from '@/stores/modalStore';
-import useDeleteLeafMutation from '@/hooks/useDeleteLeafMutaion';
+import useDeleteLeafMutation from '@/hooks/mutation/useDeleteLeafMutaion';
-import CommonButton from '../common/CommonButton';
-import ModalPortal from '../common/ModalPortal';
-import Modal from '../common/Modal';
+import { CommonButton, ModalPortal, Modal } from '@/components/common';
+import { LEAF_DELETE_MODAL_TEXT } from '@/constants/contents';
-interface LeafDeleteModalProps {
- pathUserId: string;
- userId: string | null;
-}
-
-export default function LeafDeleteModal({
- userId,
- pathUserId,
-}: LeafDeleteModalProps) {
- if (userId !== pathUserId) return null;
+export default function LeafDeleteModal() {
+ const { isOwner } = useLeafsStore();
+ const { deleteTargetLeafsId } = useLeafsStore();
+ const { close } = useModalStore();
- const { mutate } = useDeleteLeafMutation();
-
- const { deleteTargetLeafsId, modalClose } = useLeafsStore();
+ const { mutate: deleteLeaf } = useDeleteLeafMutation();
const handleLeafDelete = () => {
if (!deleteTargetLeafsId) return;
-
- mutate(deleteTargetLeafsId);
- modalClose();
+ deleteLeaf(deleteTargetLeafsId);
+ close();
};
const handleModalCancel = () => {
- modalClose();
+ close();
};
+ if (!isOwner) return null;
return (
- ์ ์์ ์ค์น๋ ์๋ฌผ ์นด๋๋
+ {LEAF_DELETE_MODAL_TEXT.firstLine[0]}
- ์ฐ๊ฒฐ์ด ํด์
+ {LEAF_DELETE_MODAL_TEXT.firstLine[1]}
- ๋ฉ๋๋ค.
+ {LEAF_DELETE_MODAL_TEXT.firstLine[2]}
- ๊ทธ๋๋ ์ญ์ ํ์๊ฒ ์ต๋๊น?
+ {LEAF_DELETE_MODAL_TEXT.secondLine}
- ์ญ์
+ {LEAF_DELETE_MODAL_TEXT.button[0]}
- ์ทจ์
+ {LEAF_DELETE_MODAL_TEXT.button[1]}
diff --git a/client/src/components/leafs/index.ts b/client/src/components/leafs/index.ts
new file mode 100644
index 00000000..1a836a4f
--- /dev/null
+++ b/client/src/components/leafs/index.ts
@@ -0,0 +1,4 @@
+import AddLeafButton from './AddLeafButton';
+import LeafDeleteModal from './LeafDeleteModal';
+
+export { AddLeafButton, LeafDeleteModal };
diff --git a/client/src/components/post/Comment.tsx b/client/src/components/post/Comment.tsx
index 8f34be08..9ad86c78 100644
--- a/client/src/components/post/Comment.tsx
+++ b/client/src/components/post/Comment.tsx
@@ -1,16 +1,17 @@
import { useForm } from 'react-hook-form';
import usePostStore from '@/stores/postStore';
+import useUserStore from '@/stores/userStore';
-import useEditCommentMutation from '@/hooks/useEditCommentMutation';
+import useEditCommentMutation from '@/hooks/mutation/useEditCommentMutation';
-import PostProfile from './PostProfile';
-import DateAndControlSection from './DateAndControlSection';
+import { PostProfile, DateAndControlSection } from '@/components/post';
import CommonButton from '../common/CommonButton';
import { CommentDataInfo } from '@/types/data';
import { CommentInputValue } from '@/types/common';
-import useUserStore from '@/stores/userStore';
+
+import { COMMENT } from '@/constants/contents';
interface CommentProps {
comment: CommentDataInfo | null;
@@ -25,10 +26,6 @@ export default function Comment({ comment, boardId }: CommentProps) {
const { mutate: editComment } = useEditCommentMutation({ boardId, targetId });
- const isEdit = editMode && String(comment.commentId) === targetId;
-
- const isOwner = userId === String(comment.accountId);
-
const {
register,
handleSubmit,
@@ -39,6 +36,10 @@ export default function Comment({ comment, boardId }: CommentProps) {
},
});
+ const isEdit = editMode && String(comment.commentId) === targetId;
+
+ const isOwner = userId === String(comment.accountId);
+
const submitCommentForm = (data: CommentInputValue) => {
editComment(data);
setEditMode(false);
@@ -70,8 +71,8 @@ export default function Comment({ comment, boardId }: CommentProps) {
className="w-full px-[0.875rem] py-[0.75rem] bg-brown-10 border-2 border-brown-50 rounded-xl text-black-50 text-xs left-3 common-drop-shadow outline-none max-[500px]:py-[0.5rem] max-[500px]:text-[0.5rem]"
{...register('comment', {
maxLength: {
- value: 200,
- message: '์ต๋ 200์๋ฅผ ๋์ ์ ์์ต๋๋ค.',
+ value: COMMENT.maxLength.value,
+ message: COMMENT.maxLength.errorMessage,
},
})}
/>
diff --git a/client/src/components/post/CommentDeleteModal.tsx b/client/src/components/post/CommentDeleteModal.tsx
index a6b612c3..1c1ab26b 100644
--- a/client/src/components/post/CommentDeleteModal.tsx
+++ b/client/src/components/post/CommentDeleteModal.tsx
@@ -1,13 +1,13 @@
'use client';
import usePostStore from '@/stores/postStore';
-import usePostModalStore from '@/stores/postModalStore';
+import useModalStore from '@/stores/modalStore';
-import useDeleteCommentMutation from '@/hooks/useDeleteCommentMutation';
+import useDeleteCommentMutation from '@/hooks/mutation/useDeleteCommentMutation';
-import Modal from '@/components/common/Modal';
-import ModalPortal from '@/components/common/ModalPortal';
-import CommonButton from '@/components/common/CommonButton';
+import { Modal, ModalPortal, CommonButton } from '@/components/common';
+
+import { COMMENT_DELETE_MODAL_TEXT } from '@/constants/contents';
interface CommentDeleteModalProps {
boardId: string | null;
@@ -17,7 +17,7 @@ export default function CommentDeleteModal({
boardId,
}: CommentDeleteModalProps) {
const { targetId } = usePostStore();
- const { close } = usePostModalStore();
+ const { close } = useModalStore();
if (!targetId || !boardId) return null;
@@ -26,7 +26,6 @@ export default function CommentDeleteModal({
boardId,
});
- // brwon-40 border
const handleDelete = () => {
deleteComment();
close();
@@ -39,9 +38,12 @@ export default function CommentDeleteModal({
- ๋๊ธ์
+ {COMMENT_DELETE_MODAL_TEXT.firstLine}
- ์ญ์ ํ์๊ฒ ์ต๋๊น?
+
+ {COMMENT_DELETE_MODAL_TEXT.secondLine[0]}
+
+ {COMMENT_DELETE_MODAL_TEXT.secondLine[1]}
diff --git a/client/src/components/post/CommentProfileImage.tsx b/client/src/components/post/CommentProfileImage.tsx
index bf834c9e..53ba1d70 100644
--- a/client/src/components/post/CommentProfileImage.tsx
+++ b/client/src/components/post/CommentProfileImage.tsx
@@ -1,6 +1,7 @@
-import useUserStore from '@/stores/userStore';
import Image from 'next/image';
+import useUserStore from '@/stores/userStore';
+
export default function CommentProfileImage() {
const { profileImageUrl } = useUserStore();
return (
diff --git a/client/src/components/post/ControlMenu.tsx b/client/src/components/post/ControlMenu.tsx
index c4f2cda8..1dfaabef 100644
--- a/client/src/components/post/ControlMenu.tsx
+++ b/client/src/components/post/ControlMenu.tsx
@@ -5,9 +5,9 @@ import { useRouter } from 'next/navigation';
import { motion } from 'framer-motion';
-import usePostModalStore from '@/stores/postModalStore';
import usePostStore from '@/stores/postStore';
import useUserStore from '@/stores/userStore';
+import useModalStore from '@/stores/modalStore';
interface ContolMenuProps {
usage: 'post' | 'comment';
@@ -23,11 +23,10 @@ export default function ControlMenu({
const userId = useUserStore((state) => state.userId);
const { setEditMode, setTargetId } = usePostStore();
+ const { open, changeType } = useModalStore();
if (userId !== ownerId) return null;
- const { open, setType } = usePostModalStore();
-
const handleEdit = () => {
if (usage === 'post') return router.push(`/post/edit/${targetId}`);
@@ -37,9 +36,8 @@ export default function ControlMenu({
};
const handleDelete = () => {
- // ์ญ์ ๋ชจ๋ฌ
open();
- setType(usage);
+ changeType(usage);
setTargetId(targetId);
};
diff --git a/client/src/components/post/DateAndControlSection.tsx b/client/src/components/post/DateAndControlSection.tsx
index a3f1a304..fb39787a 100644
--- a/client/src/components/post/DateAndControlSection.tsx
+++ b/client/src/components/post/DateAndControlSection.tsx
@@ -1,6 +1,7 @@
-import getDateFormat from '@/utils/getDateFormat';
import ControlMenu from './ControlMenu';
+import getDateFormat from '@/utils/getDateFormat';
+
interface DateAndControlProps {
date?: Date;
usage: 'post' | 'comment';
@@ -43,6 +44,6 @@ const SECTION_STYLE = {
},
comment: {
container: 'max-[500px]:pr-0',
- dayText: 'max-[500px]:text-[0.4rem] ',
+ dayText: 'max-[500px]:text-[0.6rem] ',
},
};
diff --git a/client/src/components/post/PostDeleteModal.tsx b/client/src/components/post/PostDeleteModal.tsx
index d46600e5..07eba929 100644
--- a/client/src/components/post/PostDeleteModal.tsx
+++ b/client/src/components/post/PostDeleteModal.tsx
@@ -6,12 +6,11 @@ import { useMutation } from '@tanstack/react-query';
import { deletePost } from '@/api/post';
-import usePostModalStore from '@/stores/postModalStore';
-
-import Modal from '@/components/common/Modal';
-import ModalPortal from '@/components/common/ModalPortal';
-import CommonButton from '@/components/common/CommonButton';
import usePostStore from '@/stores/postStore';
+import useModalStore from '@/stores/modalStore';
+
+import { Modal, ModalPortal, CommonButton } from '@/components/common';
+import { POST_DELETE_MODAL_TEXT } from '@/constants/contents';
interface DeletePostParameters {
targetId: string;
@@ -20,7 +19,7 @@ interface DeletePostParameters {
export default function PostDeleteModal() {
const router = useRouter();
- const { close } = usePostModalStore();
+ const { close } = useModalStore();
const { targetId } = usePostStore();
if (!targetId) return;
@@ -42,9 +41,12 @@ export default function PostDeleteModal() {
- ๊ฒ์๊ธ์
+ {POST_DELETE_MODAL_TEXT.firstLine[0]}
- ์ญ์ ํ์๊ฒ ์ต๋๊น?
+
+ {POST_DELETE_MODAL_TEXT.firstLine[1]}
+
+ {POST_DELETE_MODAL_TEXT.firstLine[2]}
diff --git a/client/src/components/post/PostForm.tsx b/client/src/components/post/PostForm.tsx
index b1c185eb..483d5b8e 100644
--- a/client/src/components/post/PostForm.tsx
+++ b/client/src/components/post/PostForm.tsx
@@ -5,15 +5,17 @@ import { useState } from 'react';
import { useForm } from 'react-hook-form';
-import useAddPost from '@/hooks/useAddPost';
-import useEditPost from '@/hooks/useEditPost';
+import useAddPostMutation from '@/hooks/mutation/useAddPostMutation';
+import useEditPostMutation from '@/hooks/mutation/useEditPostMutation';
import useEffectOnce from '@/hooks/useEffectOnce';
-import TextInput from '@/components/common/TextInput';
-import ImageUpload from '@/components/common/ImageUpload';
-import TextArea from '@/components/common/TextArea';
-import TagInput from '@/components/common/TagInput';
-import CommonButton from '@/components/common/CommonButton';
+import {
+ TextInput,
+ ImageUpload,
+ TextArea,
+ TagInput,
+ CommonButton,
+} from '@/components/common';
import { InputValues } from '@/types/common';
import { RawPostInfo } from '@/types/data';
@@ -30,9 +32,9 @@ export default function PostForm({ post, postId, mode }: PostFormProps) {
const [isImageUpdated, setIsImageUpdated] = useState(false);
const [tags, setTags] = useState
([]);
- const { addPostMutate } = useAddPost();
+ const { addPostMutate } = useAddPostMutation();
- const { editPostMutate } = useEditPost(postId as string);
+ const { editPostMutate } = useEditPostMutation(postId as string);
const {
register,
diff --git a/client/src/components/post/index.ts b/client/src/components/post/index.ts
new file mode 100644
index 00000000..e7659f81
--- /dev/null
+++ b/client/src/components/post/index.ts
@@ -0,0 +1,27 @@
+import Comment from '@/components/post/Comment';
+import CommentDeleteModal from './CommentDeleteModal';
+import CommentForm from './CommentForm';
+import CommentProfileImage from './CommentProfileImage';
+import ControlMenu from './ControlMenu';
+import DateAndControlSection from './DateAndControlSection';
+import HashTags from './HashTags';
+import PostContent from './PostContent';
+import PostDeleteModal from './PostDeleteModal';
+import PostForm from './PostForm';
+import PostImage from './PostImage';
+import PostProfile from './PostProfile';
+
+export {
+ Comment,
+ CommentDeleteModal,
+ CommentForm,
+ CommentProfileImage,
+ ControlMenu,
+ DateAndControlSection,
+ HashTags,
+ PostContent,
+ PostDeleteModal,
+ PostForm,
+ PostImage,
+ PostProfile,
+};
diff --git a/client/src/components/profile/ChangeNicknameModal.tsx b/client/src/components/profile/ChangeNicknameModal.tsx
deleted file mode 100644
index 84a0dbee..00000000
--- a/client/src/components/profile/ChangeNicknameModal.tsx
+++ /dev/null
@@ -1,34 +0,0 @@
-import useSignModalStore from '@/stores/signModalStore';
-
-import CommonButton from '../common/CommonButton';
-import Modal from '../common/Modal';
-import ModalPortal from '../common/ModalPortal';
-
-export default function ChangeNicknameModal() {
- const close = useSignModalStore((state) => state.close);
-
- return (
-
-
-
-
-
- ๋๋ค์์ด
-
{' '}
- ๋ณ๊ฒฝ๋์์ต๋๋ค!
-
-
-
-
-
-
-
-
- );
-}
diff --git a/client/src/components/profile/ChangePasswordModal.tsx b/client/src/components/profile/ChangePasswordModal.tsx
deleted file mode 100644
index fbff2fae..00000000
--- a/client/src/components/profile/ChangePasswordModal.tsx
+++ /dev/null
@@ -1,34 +0,0 @@
-import useSignModalStore from '@/stores/signModalStore';
-
-import CommonButton from '../common/CommonButton';
-import Modal from '../common/Modal';
-import ModalPortal from '../common/ModalPortal';
-
-export default function ChangePasswordModal() {
- const close = useSignModalStore((state) => state.close);
-
- return (
-
-
-
-
-
- ๋น๋ฐ๋ฒํธ๊ฐ
-
{' '}
- ๋ณ๊ฒฝ๋์์ต๋๋ค!
-
-
-
-
-
-
-
-
- );
-}
diff --git a/client/src/components/profile/ChangeProfileModal.tsx b/client/src/components/profile/ChangeProfileModal.tsx
new file mode 100644
index 00000000..19bef4dc
--- /dev/null
+++ b/client/src/components/profile/ChangeProfileModal.tsx
@@ -0,0 +1,37 @@
+import useModalStore from '@/stores/modalStore';
+
+import { CommonButton, Modal } from '../common';
+
+import { PROFILE_MODAL_TEXT } from '@/constants/contents';
+
+interface ChangeProfileModalProps {
+ type: 'password' | 'nickname' | 'image';
+}
+
+export default function ChangeProfileModal({ type }: ChangeProfileModalProps) {
+ const { close } = useModalStore();
+
+ return (
+
+
+
+
+ {PROFILE_MODAL_TEXT[type]}
+
+ ๋ณ๊ฒฝ๋์์ต๋๋ค!
+
+
+
+
+
+ ๋ซ๊ธฐ
+
+
+
+
+ );
+}
diff --git a/client/src/components/profile/ImageForm.tsx b/client/src/components/profile/ImageForm.tsx
index 3e1a98a3..6b24df5f 100644
--- a/client/src/components/profile/ImageForm.tsx
+++ b/client/src/components/profile/ImageForm.tsx
@@ -1,67 +1,24 @@
'use client';
-import { useRef, useState } from 'react';
import Image from 'next/image';
-import { updateUserProfileImage } from '@/api/profile';
-
-import useUserStore from '@/stores/userStore';
-
import useClient from '@/hooks/useClient';
+import useChangeImageMutation from '@/hooks/mutation/useChangeImageMutation';
-import CommonButton from '../common/CommonButton';
+import { CommonButton } from '../common';
import { DefaultProps } from '@/types/common';
export default function ImageForm({ className }: DefaultProps) {
const isClient = useClient();
+ const {
+ imageUploadRef,
+ imageUrl,
+ isDisabled,
- const { profileImageUrl, setProfileImageUrl, setAccessToken } =
- useUserStore();
-
- const [image, setImage] = useState();
- const [imageUrl, setImageUrl] = useState(profileImageUrl);
- const [isDisabled, setIsDisabled] = useState(true);
-
- const imageUploadRef = useRef(null);
-
- const checkFileSize = (file: File) => {
- if (file && file.type.startsWith('image/')) {
- if (file.size <= 2 * 1024 * 1024) {
- return true;
- }
- }
-
- alert('2mb ์ดํ์ ์ด๋ฏธ์ง๋ง ๋ฑ๋ก์ด ๊ฐ๋ฅํฉ๋๋ค.');
- return false;
- };
-
- const onImageChange = (event: React.ChangeEvent) => {
- const file = event.target.files;
-
- if (!file) return;
-
- if (file[0] && checkFileSize(file[0])) {
- setImage(file);
-
- const newFileURL = URL.createObjectURL(file[0]);
- setImageUrl(newFileURL);
- setIsDisabled(false);
- }
- };
-
- const onImageSubmit = async () => {
- if (image && !isDisabled) {
- const response = await updateUserProfileImage(image[0]);
-
- setProfileImageUrl(imageUrl);
- setIsDisabled(true);
-
- if (response.status === 204) {
- setAccessToken(response.headers?.authorization);
- }
- }
- };
+ onImageChange,
+ onImageSubmit,
+ } = useChangeImageMutation();
return (
<>
@@ -77,6 +34,7 @@ export default function ImageForm({ className }: DefaultProps) {
priority
onClick={() => imageUploadRef.current?.click()}
/>
+
+
์ด๋ฏธ์ง ๋ฑ๋ก
+
2mb ์ดํ์ ์ด๋ฏธ์ง๋ง ๋ฑ๋ก์ด ๊ฐ๋ฅํฉ๋๋ค.
diff --git a/client/src/components/profile/NicknameForm.tsx b/client/src/components/profile/NicknameForm.tsx
index c6f10b3d..629beb19 100644
--- a/client/src/components/profile/NicknameForm.tsx
+++ b/client/src/components/profile/NicknameForm.tsx
@@ -3,29 +3,22 @@
import { useEffect } from 'react';
import { useForm } from 'react-hook-form';
-import { updateUserNickname } from '@/api/profile';
+import useChangeNicknameMutation from '@/hooks/mutation/useChangeNicknameMutation';
-import useUserStore from '@/stores/userStore';
-import useSignModalStore from '@/stores/signModalStore';
-
-import TextInput from '../common/TextInput';
-import CommonButton from '../common/CommonButton';
+import { CommonButton, TextInput } from '../common';
import { InputValues } from '@/types/common';
export default function NicknameForm() {
- const { setDisplayName, displayName } = useUserStore();
const {
register,
handleSubmit,
formState: { errors, isSubmitting },
watch,
- reset,
setValue,
} = useForm();
- const changeState = useSignModalStore((state) => state.changeState);
- const setAccessToken = useUserStore((state) => state.setAccessToken);
+ const { updateNickName, displayName } = useChangeNicknameMutation();
const nickname = watch('nickname');
@@ -33,23 +26,9 @@ export default function NicknameForm() {
setValue('nickname', displayName);
}, [displayName]);
- const updateNickName = async () => {
- if (!nickname) return;
-
- const response = await updateUserNickname(nickname);
- setDisplayName(nickname);
-
- if (response.status === 204) {
- setAccessToken(response.headers?.authorization);
- }
-
- reset();
- changeState('ChangeNicknameModal');
- };
-
return (