Skip to content

Commit

Permalink
refactor(useMyPage): useToggle 사용하도록 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
simorimi committed Oct 16, 2024
1 parent ae9be47 commit 01b6786
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions frontend/src/components/pages/my/hooks/useMyPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { usePostUploadImages } from "@queries/usePostUploadImages";
import usePutProfile from "@queries/usePutProfile";
import { useUserProfile } from "@queries/useUserProfile";

import useToggle from "@hooks/useToggle";

import { FORM_VALIDATIONS_MAP } from "@constants/formValidation";

const useMyPage = () => {
Expand All @@ -24,10 +26,10 @@ const useMyPage = () => {
const [isModifying, setIsModifying] = useState(false);
const [isProfileImageLoading, setIsProfileImageLoading] = useState(false);

const [isModalOpen, setIsModalOpen] = useState(false);
const [isModalOpen, handleOpenModal, handleCloseModal] = useToggle();

const handleClickEditModalOpenButton = () => setIsModalOpen(true);
const handleClickEditModalCloseButton = () => setIsModalOpen(false);
const handleClickEditModalOpenButton = () => handleOpenModal();
const handleClickEditModalCloseButton = () => handleCloseModal();

const handleClickProfileEditButton = () => setIsModifying(true);
const handleClickProfileImageEditButton = () => profileImageFileInputRef.current?.click();
Expand All @@ -36,7 +38,7 @@ const useMyPage = () => {

const handleChangeProfileImage = async (e: React.ChangeEvent<HTMLInputElement>) => {
setIsProfileImageLoading(true);
setIsModalOpen(false);
handleCloseModal();

const files = Array.from(e.target.files as FileList);
const profileImage = await mutateAddImage(files);
Expand All @@ -51,7 +53,7 @@ const useMyPage = () => {
const handleClickProfileImageDeleteButton = () => {
setProfileImageUrl("");

setIsModalOpen(false);
handleCloseModal();
};

const handleClickProfileEditConfirmButton = () => {
Expand Down

0 comments on commit 01b6786

Please sign in to comment.