-
Notifications
You must be signed in to change notification settings - Fork 0
카카오 로그인/회원가입 기능 #122
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
카카오 로그인/회원가입 기능 #122
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,7 +29,7 @@ export type RootStackParamList = { | |
| InBodyManual: undefined; | ||
| HealthScoreTrend: undefined; | ||
| // Payment | ||
| PaymentSuccess: { sessionId?: string; orderId?: string }; | ||
| PaymentSuccess: undefined; | ||
| PaymentFail: undefined; | ||
| PaymentCancel: undefined; | ||
| }; | ||
|
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. 리뷰 코멘트:
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,13 +27,14 @@ const healthGoalOptions = [ | |
| ]; | ||
|
|
||
| const workoutDaysOptions = [ | ||
| {label: '주 1회', value: '주 1회'}, | ||
| {label: '주 2회', value: '주 2회'}, | ||
| {label: '주 3회', value: '주 3회'}, | ||
| {label: '주 4회', value: '주 4회'}, | ||
| {label: '주 5회', value: '주 5회'}, | ||
| {label: '주 6회', value: '주 6회'}, | ||
| {label: '주 7회', value: '주 7회'}, | ||
| {label: '주 1회', value: '1일'}, | ||
| {label: '주 2회', value: '2일'}, | ||
| {label: '주 3회', value: '3일'}, | ||
| {label: '주 3-4회', value: '3-4일'}, | ||
| {label: '주 4회', value: '4일'}, | ||
| {label: '주 5회', value: '5일'}, | ||
| {label: '주 6회', value: '6일'}, | ||
| {label: '주 7회', value: '7일'}, | ||
| ]; | ||
|
|
||
| const experienceLevelOptions = [ | ||
|
|
@@ -144,35 +145,53 @@ const KakaoOnboardingScreen = ({navigation}: any) => { | |
| try { | ||
| const birthDate = `${formData.birthYear}-${String(formData.birthMonth).padStart(2, '0')}-${String(formData.birthDay).padStart(2, '0')}`; | ||
|
|
||
| // 유연성향상, 체력증진, 자세교정은 "MAINTENANCE"로 변환 | ||
| const healthGoalValue = ['FLEXIBILITY', 'ENDURANCE', 'POSTURE'].includes(formData.healthGoal) | ||
| ? 'MAINTENANCE' | ||
| : formData.healthGoal; | ||
|
|
||
| const onboardingData = { | ||
| gender: formData.gender, | ||
| birthDate, | ||
| agreePrivacy: true, | ||
| agreeTerms: true, | ||
| gender: formData.gender as "M" | "F", | ||
| height: Number(formData.height), | ||
| weight: Number(formData.weight), | ||
| birthDate, | ||
| weightGoal: Number(formData.weightGoal), | ||
| healthGoal: formData.healthGoal, | ||
| healthGoal: healthGoalValue, | ||
| workoutDaysPerWeek: formData.workoutDaysPerWeek, | ||
| ...(formData.experienceLevel && {experienceLevel: formData.experienceLevel}), | ||
| ...(formData.fitnessConcerns && {fitnessConcerns: formData.fitnessConcerns}), | ||
| }; | ||
|
|
||
| const response = await authAPI.submitOnboarding(onboardingData); | ||
|
|
||
| if (response.success) { | ||
| Alert.alert('완료', '신체정보가 저장되었습니다.', [ | ||
| { | ||
| text: '확인', | ||
| onPress: () => navigation.replace('Main'), | ||
| }, | ||
| ]); | ||
| } else { | ||
| Alert.alert('오류', response.message || '신체정보 저장에 실패했습니다.'); | ||
| } | ||
| setLoading(false); | ||
|
|
||
| // 200 응답 (온보딩 완료) → Alert 없이 바로 홈으로 이동 | ||
| // response.success가 false여도 200 응답이면 성공으로 처리 | ||
| setTimeout(() => { | ||
| navigation.replace('Main'); | ||
| }, 100); | ||
| return; | ||
| } catch (error: any) { | ||
| console.error('온보딩 제출 실패:', error); | ||
| Alert.alert('오류', error.message || '신체정보 저장에 실패했습니다.'); | ||
| } finally { | ||
| setLoading(false); | ||
|
|
||
| // 400 에러 (이미 온보딩 완료됨) → Alert 없이 홈으로 이동 | ||
| if (error.status === 400) { | ||
| setTimeout(() => { | ||
| navigation.replace('Main'); | ||
| }, 100); | ||
| return; | ||
| } | ||
|
|
||
| // 401 에러 (인증 필요) → 로그인 화면으로 이동 | ||
| if (error.status === 401) { | ||
| navigation.replace('Login'); | ||
| return; | ||
| } | ||
|
|
||
| // 기타 에러만 Alert 표시 | ||
| Alert.alert('오류', error.message || '신체정보 저장에 실패했습니다.'); | ||
| } | ||
| }; | ||
|
|
||
|
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 comment
The reason will be displayed to describe this comment to others. Learn more.
코드 패치를 검토한 결과, 몇 가지 잠재적인 문제와 개선 사항을 발견했습니다.
비동기 호출의 오류 처리:
handleDeleteAccount함수 내의authAPI.deleteAccount호출에서 오류가 발생할 경우 이를 처리하는 로직이 없습니다.try-catch블록을 추가하여 서버 오류나 네트워크 문제를 처리해야 합니다.비밀번호 확인: 비밀번호와 탈퇴 사유를 입력받는 부분에서 추가적인 검증이 필요할 수 있습니다. 예를 들어, 비밀번호가 특정 길이 이상인지 확인하는 등의 추가적인 룰을 고려할 수 있습니다.
상태 관리: 사용자의 입력 상태를 관리하는 부분에서 리액트의 상태 변경 및 API 호출 후의 상태 업데이트도 마찬가지로 고려해야 합니다. 예를 들어,
setLoading(false)호출이 누락되면 로딩 상태가 유지될 수 있습니다.상수 파일 구조 개선:
ACCESS_TOKEN_KEY와REFRESH_TOKEN_KEY상수들이 어디에서 사용될지 불명확합니다. 이러한 상수들은 보안과 관련된 센티티이므로, 적절한 위치에 배치하고 코드 베이스에서의 사용을 제한할 수 있어야 합니다.AsyncStorage 사용의 의도: 코드에서
AsyncStorage가 임포트 되긴 했으나, 실제로 사용되고 있지 않습니다. 사용하지 않는다면 임포트를 제거해야 하며, 사용 계획이 있다면 이를 코드에 명확하게 반영해야 합니다.위의 문제들을 해결한 뒤에 코드 병합을 고려하는 것이 좋습니다.