-
Notifications
You must be signed in to change notification settings - Fork 0
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: Discord Webhook 통신 구현 #56
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,7 @@ const Join = () => { | |
const [email, setEmail] = useState('') | ||
const [pw, setPw] = useState('') | ||
const [pwCheck, setPwCheck] = useState('') | ||
const [discord, setDiscord] = useState('') | ||
const [idError, setIdError] = useState('') | ||
const [isPwVisible, setIsPwVisible] = useState(false) | ||
const [isPwCheckVisible, setIsPwCheckVisible] = useState(false) | ||
|
@@ -20,7 +21,8 @@ const Join = () => { | |
nickname: '', | ||
email: '', | ||
pw: '', | ||
pwCheck: '' | ||
pwCheck: '', | ||
discord: '' | ||
}) | ||
|
||
const postJoin = useMutation({ | ||
|
@@ -57,6 +59,11 @@ const Join = () => { | |
setErrorMessages((prev) => ({ ...prev, pwCheck: '' })) | ||
} | ||
|
||
const handleDiscordChange = (e: React.ChangeEvent<HTMLInputElement>) => { | ||
setDiscord(e.target.value) | ||
setErrorMessages((prev) => ({ ...prev, discord: '' })) | ||
} | ||
|
||
const handleJoinSubmit = async (e: React.MouseEvent<HTMLButtonElement>) => { | ||
e.preventDefault() | ||
|
||
|
@@ -65,6 +72,7 @@ const Join = () => { | |
email: !email ? '* 이메일을 입력해주세요' : '', | ||
pw: !pw ? '* 비밀번호를 입력해주세요' : '', | ||
pwCheck: !pwCheck ? '* 비밀번호 확인을 입력해주세요' : '', | ||
discord: !discord ? '* 디스코드 Webhook url을 입력해주세요' : '' | ||
} | ||
|
||
// 회원가입 통신 코드 | ||
|
@@ -79,7 +87,7 @@ const Join = () => { | |
|
||
if (Object.values(errors).some((msg) => msg)) return | ||
|
||
await postJoin.mutateAsync({email, password: pw, nickname}) | ||
await postJoin.mutateAsync({email, password: pw, nickname, discord}) | ||
alert('회원가입에 성공하였습니다! 로그인해주세요') | ||
navigate('/login') | ||
} | ||
|
@@ -149,6 +157,18 @@ const Join = () => { | |
</Line> | ||
{errorMessages.pwCheck && <ErrorMessage>{errorMessages.pwCheck}</ErrorMessage>} | ||
</InputWrapper> | ||
<InputWrapper> | ||
<Line> | ||
<Label>디스코드 URL</Label> | ||
<Input | ||
type="text" | ||
placeholder="디스코드 Webhook URL을 입력하세요" | ||
value={discord} | ||
onChange={handleDiscordChange} | ||
/> | ||
</Line> | ||
{errorMessages.discord && <ErrorMessage>{errorMessages.discord}</ErrorMessage>} | ||
</InputWrapper> | ||
<Button onClick={handleJoinSubmit}>회원가입</Button> | ||
<Login> | ||
이미 계정이 있으신가요? <StyledLink to={'/login'}>로그인</StyledLink> | ||
|
@@ -196,7 +216,7 @@ const InputWrapper = styled.div` | |
` | ||
|
||
const Label = styled.div` | ||
width: 5.5rem; | ||
width: 5.7rem; | ||
margin-right: 2rem; | ||
` | ||
|
||
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. 변경 사항:
개선점:
|
||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
함수 postRegister가 수정되어서 discord라는 추가적인 속성을 인자로 받도록 변경되었습니다. 이 변경은 인터페이스 postRegisterProps에 discord 속성을 추가하여 반영되었습니다. 그러나 기존 코드의 에러는 종종 간과되며 누락될 수 있습니다. 따라서 discord 속성을 지정한 경우 오류가 발생할 수 있습니다. 따라서 변경된 함수 내에서 discord 속성을 사용하기 전에 discord 속성이 null 또는 undefined인지 확인하는 방어적 코딩의 추가가 필요합니다. 또한 axiosInstance.post 호출 후 응답을 처리하기 전에 응답에 대한 오류 처리를 추가하는 것이 좋습니다. 마지막으로 코드 리뷰 후에는 단위 테스트를 통해 변경된 로직이 예상대로 작동하는지 확인하는 것이 좋습니다.