-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: 회원가입 api 연결 및 동작 처리 구현 #181
Changes from 9 commits
c25f9fa
8e84c66
cc866a8
83e03d9
bf06ffe
a7c7e4a
330e0a9
dbd46e1
ee5aa11
e60897e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,13 @@ | ||
import React from 'react'; | ||
import Label from '@/components/atoms/Label/Label'; | ||
import ProfileSignUp from '@/components/atoms/ProfileSetting/ProfileSetting'; | ||
import ProfileSetting from '@/components/atoms/ProfileSetting/ProfileSetting'; | ||
import { | ||
InputProfileImageProps, | ||
useCheckProfileImage, | ||
} from '@/hooks/common/inputsUserInfo/useCheckProfileImage'; | ||
import React, { useState } from 'react'; | ||
import DefaultProfileModal from '../DefaultProfileModal/DefaultProfileModal'; | ||
import { | ||
defaultProfileModalcenterStyling, | ||
profileDefaultText, | ||
profileImageSelectContainer, | ||
profileImageText, | ||
|
@@ -18,10 +20,20 @@ const InputProfileImage = ({ | |
}: InputProfileImageProps) => { | ||
const { imageSrc, isError, getRootProps, handleDefaultImage } = | ||
useCheckProfileImage({ setProfilePhoto, imgSrc }); | ||
|
||
const [defaultProfileModalOpen, setDefaultProfileModalOpen] = | ||
useState<boolean>(false); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. useState의 경우 기본 타입 추정 값이 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 해당 모달 동작 부분을 하나의 함수로 처리해도 좋을 것 같다는 의견도 제시봅시다! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. lint 관련 설정보다는 명시적으로 초기화해주는 것이 좋아 위와 같이 코드를 작성했습니다 :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 처음 의도는 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +) useState 관련해서는 희선님의 의도가 더 적절하신 거 같네요! 오히려 제가 하나 더 배워갑니다! 확인해주셔서 정말 감사드려요 👍 |
||
const handleSelectDefaultImage = (selectedImage: string | null) => { | ||
if (selectedImage) { | ||
handleDefaultImage(selectedImage); | ||
} | ||
setDefaultProfileModalOpen(false); | ||
}; | ||
return ( | ||
<div css={profileImageSelectContainer}> | ||
<Label>프로필 사진(선택)</Label> | ||
<ProfileSignUp | ||
<ProfileSetting | ||
isSetting={!!imageSrc} | ||
src={imageSrc} | ||
{...getRootProps()} | ||
|
@@ -30,14 +42,21 @@ const InputProfileImage = ({ | |
<button | ||
type="button" | ||
css={profileDefaultText} | ||
onClick={handleDefaultImage} | ||
onClick={() => setDefaultProfileModalOpen(true)} | ||
> | ||
기본 이미지로 프로필 설정하기 | ||
</button> | ||
<span css={profileImageText(isError)}> | ||
3MB 이하의 사진만 가능합니다. | ||
</span> | ||
</div> | ||
<div css={defaultProfileModalcenterStyling}> | ||
<DefaultProfileModal | ||
isOpen={defaultProfileModalOpen} | ||
onSelect={handleSelectDefaultImage} | ||
onClose={() => setDefaultProfileModalOpen(false)} | ||
/> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
export const DEFAULT_PROFILE_URL = { | ||
OCTOPUS: { | ||
CLIENT: '/octopus-profile.png', | ||
SERVER: | ||
'https://picko-image.s3.ap-northeast-2.amazonaws.com/member/2c132b00-e37a-4f71-bbf2-e064bd181915_octopus_profile.jpg', | ||
WonJuneKim marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}, | ||
JELLYFISH: { | ||
CLIENT: '/jellyfish-profile.png', | ||
SERVER: | ||
'https://picko-image.s3.ap-northeast-2.amazonaws.com/member/8fcc5073-d977-4b91-a4d1-e242e3eb2efa_jellyfilsh_profile.jpg', | ||
}, | ||
RAY: { | ||
CLIENT: '/ray-profile.png', | ||
SERVER: | ||
'https://picko-image.s3.ap-northeast-2.amazonaws.com/member/0c6c471d-420a-4632-ae9b-20be5a52097c_ray_profile.jpg', | ||
}, | ||
EEL: { | ||
CLIENT: '/eel-profile.png', | ||
SERVER: | ||
'https://picko-image.s3.ap-northeast-2.amazonaws.com/member/873fad2f-1cf5-4429-9cd0-626656b894d3_eel_profile.jpg', | ||
}, | ||
TURTLE: { | ||
CLIENT: '/turtle-profile.png', | ||
SERVER: | ||
'https://picko-image.s3.ap-northeast-2.amazonaws.com/member/4239508d-f9b3-4a3e-91be-3777024ea05a_turtle_profile.jpg', | ||
}, | ||
RABBIT: { | ||
CLIENT: '/rabbit-profile.png', | ||
SERVER: | ||
'https://picko-image.s3.ap-northeast-2.amazonaws.com/member/68f736cf-0f65-4f12-bb44-4f54c448eddc_rabbit_profile.jpg', | ||
}, | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,11 @@ | ||
import { useNavigate } from 'react-router-dom'; | ||
import { AxiosErrorResponse } from '@/api/interceptor'; | ||
import { postMember } from '@/api/member'; | ||
import { useMutation } from '@tanstack/react-query'; | ||
import { PATH } from '@/constants/path'; | ||
|
||
export const useSignUpMutation = () => { | ||
const navigate = useNavigate(); | ||
return useMutation({ | ||
mutationFn: postMember, | ||
onSuccess: () => { | ||
navigate(`/${PATH.LOGIN}`); | ||
alert('회원가입에 성공했습니다😀'); | ||
}, | ||
onSuccess: () => {}, | ||
onError: (err: AxiosErrorResponse) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 회원가입 후 로그인페이지로 이동하도록 로직이 설정되어있다고 하셨는데 제거하신 이유가 따로 있을까용? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 회원가입 성공 시 로직은 아래 파일로 이동해두었습니다! // hooks\signup\useSignupForm.ts
const { mutate: signup } = useSignUpMutation();
const handleSubmit = (e: ChangeEvent<HTMLFormElement>) => {
e.preventDefault();
if (isAllTrue(successForm)) {
const newForm = createNewForm(form);
signup(newForm, {
onSuccess: () => {
setSignupSuccess(true);
setTimeout(() => {
navigate(`/${PATH.LOGIN}`);
}, 2000);
},
});
} else {
focus(e);
}
}; 위와 같이 옮겨둔 이유는 회원 가입 성공 토스트 메시지 창이 2초간 띄워진 이후로 로그인 페이지로 이동해야 했기 때문입니당 const [signupSuccess, setSignupSuccess] = useState<boolean>(false);
|
||
console.error(err); | ||
}, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
role 매개변수의 역할이 혹시 유저와 어드민 이렇게 이후에 나누어질 구분에 대한 것인지 궁금합니당🧐
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
회원 가입 api에서 body값으로 role이라는 값을 넣어주어야 해서 추가해주었습니다! 아마 말씀하신 것처럼 차후에 유저와 어드민을 구분하기 위해서 기능을 미리 만들어 두신 게 아닐까 싶네요🤔