Skip to content

Conversation

@Insung-Jo
Copy link

@Insung-Jo Insung-Jo commented Jun 17, 2025

📌 변경 사항 개요

  • 회원가입 페이지과 동시에 관련된 로직을 개선 했습니다!
  • (20:30 수정)현재 반응형 부분에서 문제가 있는 거 같아서 해결 후 머지 진행하겠습니다!
  • 23:24 수정 해결 완료 (글로벌 스타일에 html,body 부분에 변경이 있습니다.)

✨ 요약

  • 회원가입 페이지 구현
  • 회원가입 로직 axios + try/catch -> react-qurey 로 변경
  • useAuth signup 로직 제거
  • 공통 훅 useMounted 구현

📝 상세 내용

  • useAuth에 있는 signup 로직이 제거 되었습니다.
  • useMounted 훅 구현 했습니다.
  • 전반적으로 ✨Feat: 로그인 페이지 구현 #65 과 동일하기 때문에 자세한 내용은 해당 이슈로 확인하셔도 무방 합니다!

useSignupMutation

export function useSignupMutation() {
  const router = useRouter()

  return useMutation<User, AxiosError | Error, SignupRequest>({
    mutationFn: signup,
    onSuccess: async () => {
      showSuccess('회원가입이 완료되었습니다!')
      await new Promise((resolve) => setTimeout(resolve, 400))
      router.push('/login')
    },
    onError: (error) => {
      if (axios.isAxiosError(error)) {
        const severMessage = (
          error.response?.data as { message?: string } | undefined
        )?.message
        const fallback = error.message || '로그인 실패'
        showError(severMessage ?? fallback)
      } else {
        showError('알 수 없는 에러 발생')
      }
    },
  })
}

useMounted

import { useEffect, useState } from 'react'

export function useMounted() {
  const [mounted, setMounted] = useState(false)

  useEffect(() => {
    setMounted(true)
  }, [])

  return mounted
}
  • 기존에 하이드레이션 문제로 사용하던 로직을 훅으로 분리 했습니다.

🔗 관련 이슈

#68

🖼️ 스크린샷

White + Error

image

Dark

image

제출 시(중복 이메일)

image

✅ 체크리스트

  • 브랜치 네이밍 컨벤션을 준수했습니다
  • 커밋 컨벤션을 준수했습니다
  • 코드가 프로젝트의 스타일 가이드라인을 준수합니다

💡 참고 사항

Summary by CodeRabbit

Summary by CodeRabbit

  • 신규 기능
    • 회원가입 시 사용되는 새로운 커스텀 훅(useSignupMutation)과 마운트 상태를 확인하는 훅(useMounted)이 추가되었습니다.
  • 기능 개선
    • 로그인 및 회원가입 페이지에서 클라이언트 마운트 여부를 보다 간결하게 처리하도록 개선되었습니다.
    • 회원가입 폼 제출 로직이 mutation 기반으로 변경되어 사용자 경험이 향상되었습니다.
    • 회원가입 페이지 상단에 환영 메시지(AuthLogo)와 하단에 로그인 링크가 추가되었습니다.
    • 회원가입 페이지 레이아웃의 반응형 패딩이 모바일 기준에서 태블릿 기준으로 조정되었습니다.
  • 버그 수정
    • 로그인 폼의 불필요한 async/await 구문이 제거되어 코드가 간결해졌습니다.
  • 타입 변경
    • 사용자 정보(User)에서 createdAt, updatedAt 필드가 필수값으로 변경되었습니다.

@Insung-Jo Insung-Jo added this to the 2차 구현 기간 milestone Jun 17, 2025
@Insung-Jo Insung-Jo self-assigned this Jun 17, 2025
@Insung-Jo Insung-Jo added ✨Feat 기능 개발 🎨Style UI, 스타일 관련 수정 ♻️Refactor 리팩토링 labels Jun 17, 2025
@coderabbitai
Copy link

coderabbitai bot commented Jun 17, 2025

"""

Walkthrough

로그인 및 회원가입 페이지에서 클라이언트 마운트 감지를 위한 로직이 커스텀 훅 useMounted로 통합되었습니다. 회원가입 폼 제출 로직은 기존의 커스텀 훅에서 React Query 기반의 useSignupMutation으로 변경되었고, 관련 불필요한 코드와 타입 정의가 정리되었습니다. 또한, 회원가입 폼에 환영 메시지와 로그인 링크가 추가되었습니다.

Changes

파일/경로 요약 변경 내용 요약
src/app/(auth)/login/page.tsx, src/app/(auth)/signup/page.tsx 마운트 감지 로직을 커스텀 훅 useMounted로 통합, 회원가입 페이지에 환영 메시지 및 로그인 링크 추가
src/app/features/auth/components/LoginForm.tsx 로그인 폼의 onSubmit에서 불필요한 async/await 제거
src/app/features/auth/components/SignupForm.tsx 회원가입 폼 제출 로직을 useSignupMutation으로 변경, 상태 관리 및 버튼 처리 방식 수정
src/app/features/auth/hooks/useAuth.ts signup 함수 및 관련 반환값/임포트 제거
src/app/features/auth/hooks/useSignupMutation.ts React Query 기반 회원가입용 커스텀 훅 useSignupMutation 신설
src/app/features/auth/hooks/useSignupSubmit.ts 기존 회원가입 제출용 커스텀 훅 파일 전체 삭제
src/app/shared/hooks/useMounted.ts 마운트 감지 커스텀 훅 useMounted 신설
src/app/shared/types/user.type.ts User 타입에서 createdAt, updatedAt를 필수 속성으로 변경
src/app/(auth)/layout.tsx 외부 컨테이너 높이 및 내부 패딩 반응형 클래스 조정
src/app/globals.css htmlbody 높이를 100%로 명시하여 전체 뷰포트 높이 확보

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant SignupPage
    participant SignupForm
    participant useSignupMutation
    participant API
    participant Toast
    participant Router

    User->>SignupPage: 페이지 접속
    SignupPage->>SignupForm: 렌더링 (useMounted로 마운트 확인)
    User->>SignupForm: 폼 입력 후 제출
    SignupForm->>useSignupMutation: signupMtate(formData) 호출
    useSignupMutation->>API: signup API 요청
    API-->>useSignupMutation: 응답 (성공/실패)
    alt 성공
        useSignupMutation->>Toast: 성공 토스트 표시
        useSignupMutation->>Router: 로그인 페이지로 이동
    else 실패
        useSignupMutation->>Toast: 에러 메시지 토스트 표시
    end
Loading

Possibly related PRs

Suggested labels

🗑️Remove

Suggested reviewers

  • dkslel1225
  • yuj2n

Poem

🐰
로그인, 회원가입, 깔끔하게
마운트 훅으로 딱 정리했지!
환영 메시지, 링크도 추가
폼 제출도 mutation으로 바꿔
새로워진 코드밭에서
토끼는 춤추네, 깡총깡총!
🌱
"""

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

npm error Exit handler never called!
npm error This is an error with npm itself. Please report this error at:
npm error https://github.com/npm/cli/issues
npm error A complete log of this run can be found in: /.npm/_logs/2025-06-17T14_25_07_294Z-debug-0.log


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9cfab6b and aa01a35.

📒 Files selected for processing (2)
  • src/app/(auth)/layout.tsx (1 hunks)
  • src/app/globals.css (1 hunks)
✅ Files skipped from review due to trivial changes (2)
  • src/app/globals.css
  • src/app/(auth)/layout.tsx
✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (5)
src/app/shared/hooks/useMounted.ts (1)

3-10: 함수 반환 타입 명시로 가독성 및 타입 안정성 향상 제안

현재 useMounted 훅은 반환 타입을 명시하지 않아도 타입 추론이 가능하지만, 공용 훅인 만큼 명시적으로 boolean을 반환한다고 선언해 두면 IDE-상 가독성과 재사용 시 안정성이 높아집니다.

-export function useMounted() {
+export function useMounted(): boolean {
src/app/features/auth/components/LoginForm.tsx (1)

27-30: onSubmit 핸들러 간결화 제안

react-hook-formhandleSubmit은 콜백에 formData를 넘겨 주므로, 래퍼 화살표 함수 없이 바로 loginMutate를 전달해도 동일하게 동작합니다. 매 렌더마다 새 함수를 생성하지 않아도 되므로 미세하지만 불필요한 렌더 비용을 줄일 수 있습니다.

-      onSubmit={handleSubmit((data) => loginMutate(data))}
+      onSubmit={handleSubmit(loginMutate)}
src/app/(auth)/signup/page.tsx (1)

15-22: UX 문구 국제화(I18N)·접근성(A11Y) 대비 고려

고정 한국어 문구가 하드코딩되어 있습니다. 프로젝트 전반에 I18N을 고려하고 있다면, 해당 텍스트를 메시지 리소스 파일로 분리해 주세요. 또한 <p> 안의 링크가 색상만으로 구분되는 경우 저시력 사용자를 위해 추가적인 시각적 피드백(밑줄 유지 등)이 필요합니다.

src/app/features/auth/hooks/useSignupMutation.ts (1)

23-31: 오타 및 사용자 메시지 불일치
onError 블록에서

  1. severMessageserverMessage 철자 오류가 있습니다.
  2. 실패 토스트가 "로그인 실패"로 표기되어 회원가입 컨텍스트와 맞지 않습니다.
-        const severMessage = (
+        const serverMessage = (
...
-        const fallback = error.message || '로그인 실패'
+        const fallback = error.message || '회원가입 실패'
-        showError(severMessage ?? fallback)
+        showError(serverMessage ?? fallback)
src/app/features/auth/components/SignupForm.tsx (1)

31-32: 변수명 오타 – 가독성 저하
signupMtatesignupMutate 등 의미가 명확한 이름으로 수정하면 가독성이 향상됩니다.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bd4eac1 and 28ccba3.

📒 Files selected for processing (9)
  • src/app/(auth)/login/page.tsx (1 hunks)
  • src/app/(auth)/signup/page.tsx (1 hunks)
  • src/app/features/auth/components/LoginForm.tsx (1 hunks)
  • src/app/features/auth/components/SignupForm.tsx (4 hunks)
  • src/app/features/auth/hooks/useAuth.ts (0 hunks)
  • src/app/features/auth/hooks/useSignupMutation.ts (1 hunks)
  • src/app/features/auth/hooks/useSignupSubmit.ts (0 hunks)
  • src/app/shared/hooks/useMounted.ts (1 hunks)
  • src/app/shared/types/user.type.ts (1 hunks)
💤 Files with no reviewable changes (2)
  • src/app/features/auth/hooks/useAuth.ts
  • src/app/features/auth/hooks/useSignupSubmit.ts
🧰 Additional context used
🧠 Learnings (1)
src/app/features/auth/components/SignupForm.tsx (1)
Learnt from: Insung-Jo
PR: CoPlay-FE/coplan#57
File: src/app/features/auth/hooks/useSignupSubmit.ts:12-0
Timestamp: 2025-06-16T09:44:38.218Z
Learning: In src/app/features/auth/hooks/useSignupSubmit.ts, the developer intentionally uses SignupRequest type instead of SignupFormData for the submit function parameter to prevent sending unnecessary confirmPassword field to the API, aligning the function signature with server expectations.
🧬 Code Graph Analysis (1)
src/app/(auth)/login/page.tsx (1)
src/app/shared/hooks/useMounted.ts (1)
  • useMounted (3-11)
🔇 Additional comments (3)
src/app/shared/types/user.type.ts (1)

6-7: createdAt / updatedAt 필수화에 따른 호환성 검증 필요

두 필드를 선택형(?)에서 필수로 변경하면

  1. 서버 응답(JSON)에서 해당 필드가 누락될 경우 런타임 오류가 발생할 수 있고
  2. 기존 코드베이스에서 Partial<User> 등을 사용하던 부분이 컴파일 에러로 이어질 수 있습니다.

PR 범위를 넘어서는 영향도가 있으므로, 다음을 확인해 주세요.

  1. BE 계약 또는 Mock 데이터가 두 필드를 항상 포함하는지.
  2. 전체 레포에서 User 객체 생성·파싱 지점을 빌드 시점에 스캔해 타입 오류가 없는지.

필요 시 Pick, Omit 등 별도 타입을 도입해 단계적 마이그레이션을 고려해 주세요.

src/app/(auth)/signup/page.tsx (1)

3-12: 경로 별칭 @hooks 사용 시 tsconfig 경로 매핑 누락 여부 확인

@hooks/useMounted 별칭을 도입했지만 tsconfig.jsonpaths에 해당 매핑이 없으면
로컬 IDE/빌드 환경과 CI 환경 간 차이로 컴파일 실패가 발생할 수 있습니다.
별칭이 이미 선언되어 있다면 무시하셔도 됩니다.

src/app/(auth)/login/page.tsx (1)

3-12: useMounted 적용 LGTM

기존 로컬 상태/이펙트 코드를 훅으로 추출해 중복을 제거한 점 👍
추가 이슈는 없습니다.

Copy link
Contributor

@dkslel1225 dkslel1225 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

회원가입 페이지 구현 고생하셨습니다! 머지하면 저도 마운트 공통 함수로 교체해야겠네용

@Insung-Jo Insung-Jo merged commit 08f29f5 into develop Jun 17, 2025
2 checks passed
Copy link
Contributor

@yuj2n yuj2n left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

인성님 회원가입 구현 수고하셨습니다~👍

Comment on lines +1 to +11
import { useEffect, useState } from 'react'

export function useMounted() {
const [mounted, setMounted] = useState(false)

useEffect(() => {
setMounted(true)
}, [])

return mounted
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

마운트 상태 관리 훅을 따로 만들어주셨군요!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

✨Feat 기능 개발 ♻️Refactor 리팩토링 🎨Style UI, 스타일 관련 수정

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants