Skip to content
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

[ 4주차 기본/심화/공유 과제 ] 로그인/회원가입/마이페이지 #5

Open
wants to merge 21 commits into
base: main
Choose a base branch
from

Conversation

Kjiw0n
Copy link
Contributor

@Kjiw0n Kjiw0n commented May 10, 2024

🧩 기본 과제

  1. 메인 페이지
    • 메인 이미지 or 비디오 넣기
  • 로그인페이지와 회원가입 페이지로 이동할 수 있는 버튼 구현
  1. 로그인 페이지

    • 아이디와 비밀번호를 입력할 수 있는 input구현
    • Login page 이미지 넣기
    • 로그인 버튼(기능)과 회원가입 페이지 이동 버튼 구현
    • 로그인 실패시 해당 에러메세지를 alert로 띄어주기
    • useParam 활용해서 id값 보유하고 있기.
  2. 회원가입 페이지

    • 아이디, 패스워드, 닉네임, 핸드폰 번호를 입력 받는 페이지 구현
    • 회원가입 버튼 클릭시 post api 통신을 진행하고 성공시 회원가입이 완료되었다는 메시지를 보여주는 alert 띄워준 후, 로그인 메인페이지로 이동
    • 아이디 중복, 비밀번호 형식 오류, 전화번호 형식 오류 등 모든 에러 alert로 메세지 보여주기
    • 비밀번호와 전화번호 형식은 input 아래에 보여주기
  3. 마이페이지

    • get 메소드를 사용해 사용자 정보를 가져오기
    • 서버에서 받아온 ID, 닉네임, 전화번호 데이터를 렌더링
    • 비밀번호 변경 토글을 사용해 비밀번호 변경 폼을 on/off할 수 있도록 구현
    • 기존 비밀번호 입력, 새로운 비밀번호 입력, 새로운 비밀번호 확인 input 구현
    • input이 비어있을 경우 api 작동되지 않도록 구현
    • 에러 발생시 api error객체 안 error message를 사용해 alert 띄우기
    • 홈 이동 버튼 구현

🔥 심화 과제

  1. 메인페이지

    • 비디오에 여러 기능을 적용
  2. 로그인 페이지

    • input이 비어있을 경우 api요청 보내지 않고 아래 error message를 띄워주기
  3. 회원가입 페이지
    input이 비어있는 상태로 api연결 시도했을시

    • 해당 input 테두리 색상 변경

    • input에 focus 맞추기

    • api요청 금지

    • 전화번호 양식 정규표현식으로 자동입력되도록 설정 (숫자만 입력해도 "-"가 붙도록)

    • 비밀번호 검증 유틸 함수 구현 (검증 통과되지 않을시 api요청 금지)

공유과제

  • prettier, eslint, styleLint에 대해

링크 첨부(팀 블로그 링크) : https://forweber.palms.blog/week4-lint

📌 내가 새로 알게 된 부분

  • 라우터를 사용하는 것, axios를 이용해 api를 연결하는 방법에 대해 새로 알게되었습니다!
  • 디렉토리를 분리하여 공통 파일을 관리하는 방법을 고민하며 구현하였습니다.

💎 구현과정에서의 고민과정(어려웠던 부분) 공유!

  • 동영상 처리가 안되는데, 해결 방법을 공유해주시면 감사하겠습니다 😭😭

🥺 소요 시간

  • 8h

🌈 구현 결과물

https://silk-title-f5a.notion.site/4-3d257b71281f4347a55061f97a506a5b

@Kjiw0n Kjiw0n added the 4주차 label May 10, 2024
@Kjiw0n Kjiw0n self-assigned this May 10, 2024
Comment on lines +14 to +21
<Router>
<Routes>
<Route path="/" element={<MainPage />} />
<Route path="/login" element={<LoginPage />} />
<Route path="/join" element={<JoinPage />} />
<Route path="/info/:memberId" element={<MyPage />} />
</Routes>
</Router>
Copy link
Member

Choose a reason for hiding this comment

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

router 공식문서를 살펴보신 적이 있으실까요?
공식문서에서는 createBrowswerRouter 사용을 권장하고 있습니다.

한 번 살펴보세요~

https://reactrouter.com/en/main/start/overview

@@ -0,0 +1,8 @@
const BASE_URL = 'http://34.64.233.12:8080';
Copy link
Member

Choose a reason for hiding this comment

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

이런 예민한 정보들은 .env를 만들고 그 안에 넣어주시면 보안에 더 좋습니당 ㅎㅎ

Comment on lines +3 to +8
export const API = {
JOIN: `${BASE_URL}/member/join`,
INFO: `${BASE_URL}/member/info`,
LOGIN: `${BASE_URL}/member/login`,
PASSWORD: `${BASE_URL}/member/password`,
};
Copy link
Member

Choose a reason for hiding this comment

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

오 이렇게 url을 따로 상수로 빼주는 것 매우 좋네요!
👍👍👍

Comment on lines +3 to +27
export function useNavigation() {
const navigate = useNavigate();

const goBack = () => {
navigate(-1);
}

const goHome = () => {
navigate('/');
}

const navigateToJoin = () => {
navigate('/join');
}

const navigateToLogin = () => {
navigate('/login');
}

const navigateToInfo = (memberId) => {
navigate(`/info/${memberId}`);
}

return { goBack, goHome, navigateToJoin, navigateToLogin, navigateToInfo };
}
Copy link
Member

Choose a reason for hiding this comment

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

navigate 커스텀 훅 너무 좋습니다!
이렇게 하면 확실히 더 안전한 navigate가 가능해요.
취향의 차이일 수 있는데, 이 파일을 util에서 관리할지,
hooks 폴더를 만들고 그 안에서 관리할지 이야기 나눠보면 좋을 것 같습니다.

const [id, setId] = useState('');
const [password, setPassword] = useState('');
const [idError, setIdError] = useState('');
const [passwordError, setPasswordError] = useState('');
Copy link
Member

Choose a reason for hiding this comment

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

상태들이 다른 곳에서도 쓰이는 경우가 있네요.
이럴경우에 대비해서 커스텀훅에 기능을 위임하는게 재사용성을 높이는 아주 좋은 방법입니다 ㅎㅎ!

한 번 정의해두면, 거기서 꺼내다 쓸 수 있겠죵??

Comment on lines +66 to +74
<button onClick={toggleChangePassword}>비밀번호 변경</button>
{showChangeToggle && (
<>
<C.InputBox type="text" placeholder="기존 비밀번호" value={currentPassword} onChange={e => setCurrentPassword(e.target.value)} />
<C.InputBox type="text" placeholder="새 비밀번호" value={newPassword} onChange={e => setNewPassword(e.target.value)} />
<C.InputBox type="text" placeholder="새 비밀번호 확인" value={newPasswordVerification} onChange={e => setNewPasswordVerification(e.target.value)} />
<C.Btn onClick={handleChangePassword}>비밀번호 변경</C.Btn>
</>
)}
Copy link
Member

Choose a reason for hiding this comment

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

html에 details 태그를 아시나요?
이 태그를 이용하면 토글을 간단하게 구현할 수 있슴다 ㅎㅎ
물론 스타일 적인 부분은 포기해야한다는 단점이 있지만 ㅠ
한 번 살펴보고 가세요~
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/details

Copy link

Choose a reason for hiding this comment

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

정안님 코드 보면서 이런 태그를 사용할 수도 있구나! 하나 알아갔는데
링크까지 주셨네요! 저도 공부해갑니다~~!

Copy link
Member

@ExceptAnyone ExceptAnyone left a comment

Choose a reason for hiding this comment

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

4주차 과제 고생하셨습니다.
전반적으로 navigate를 따로 유틸로 분리하시는 것과 api 관련 코드들 모아놓는 모습을 보면서, 정말 웹만 처음이고 개발 자체를 잘하는 사람이 맞구나 느껴졌습니다.
이번 기수가 지나면 엄청난 성장을 할 지원님의 모습이 보이네요.
또한 커스텀훅으로 분리하는 연습만 조금 해보시면 너무 깔끔한 컴포넌트들이 될 것 같습니다.
다만 아쉬운점은, 공통 스타일로 분리하신 스타일 코드들을,
공통 컴포넌트로 분리하셨다면 더 좋지 않았을까 조심스레 의견을 내봅니다.
또한 타입스크립트를 사용하셨다면, 합동 세미나 전에 타입스크립트에 조금 익숙해지고
더 좋은 리뷰를 남겨드릴 수 있었을 것 같은데 그 부분이 아쉬운 점인 것 같아요 ㅠ!!

앞으로 펼쳐질 합동세미나 잘 부탁드립니다!

Copy link

@imddoy imddoy left a comment

Choose a reason for hiding this comment

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

폴더 구조도 잘 나누시고 코드도 간단하게 잘 작성해주셔서 감탄하고 갑니다!!
덕분에 새로운 것들도 많이 배워갔습니다. 감사합니다.
과제 열심히 하느라 수고하셨어요!!

`;

export const InputBox = styled.input`
border: 1px solid ${({error}) => (error ? 'red' : 'transparent')};
Copy link

Choose a reason for hiding this comment

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

오 이런 방식도 있었네요!

<button onClick={() => setPlaying(!playing)}>
{playing ? 'Pause' : 'Play'}
</button>
{/* <S.MainImg src="./src/assets/잠만보.jpg" /> */}
Copy link

Choose a reason for hiding this comment

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

필요없는 주석은 없애도 좋을 것 같아요!

Comment on lines +66 to +74
<button onClick={toggleChangePassword}>비밀번호 변경</button>
{showChangeToggle && (
<>
<C.InputBox type="text" placeholder="기존 비밀번호" value={currentPassword} onChange={e => setCurrentPassword(e.target.value)} />
<C.InputBox type="text" placeholder="새 비밀번호" value={newPassword} onChange={e => setNewPassword(e.target.value)} />
<C.InputBox type="text" placeholder="새 비밀번호 확인" value={newPasswordVerification} onChange={e => setNewPasswordVerification(e.target.value)} />
<C.Btn onClick={handleChangePassword}>비밀번호 변경</C.Btn>
</>
)}
Copy link

Choose a reason for hiding this comment

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

정안님 코드 보면서 이런 태그를 사용할 수도 있구나! 하나 알아갔는데
링크까지 주셨네요! 저도 공부해갑니다~~!

Copy link

Choose a reason for hiding this comment

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

이렇게 utils에 따로 코드를 분리하니 코드도 간단하고 유지보수하기도 좋겠네요! 최고입니다~! 배워가요

`;

export const Info = styled.h3`
color: black;
Copy link

Choose a reason for hiding this comment

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

자주 사용하는 색은 theme에 같이 넣어주는 것은 어떨까요??

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants