Skip to content

[함헌규] sprint11#139

Merged
pers0n4 merged 48 commits intocodeit-sprint-fullstack:next-함헌규from
heonq:next-함헌규-sprint11
Feb 17, 2025

Hidden character warning

The head ref may contain hidden characters: "next-\ud568\ud5cc\uaddc-sprint11"
Merged

[함헌규] sprint11#139
pers0n4 merged 48 commits intocodeit-sprint-fullstack:next-함헌규from
heonq:next-함헌규-sprint11

Conversation

@heonq
Copy link
Collaborator

@heonq heonq commented Feb 9, 2025

요구사항

공통

  • Github에 위클리 미션 PR을 만들어 주세요
  • React 및 Express를 사용해 진행합니다
  • TypeScript를 활용해 프로젝트의 필요한 곳에 타입을 명시해 주세요
  • any 타입의 사용은 최소화해 주세요
  • 복잡한 객체 구조나 배열 구조를 가진 변수에 인터페이스 또는 타입 별칭을 사용하세요
  • Union, Intersection, Generics 등 고급 타입을 적극적으로 사용해 주세요
  • 타입 별칭 또는 유틸리티 타입을 사용해 타입 복잡성을 줄여주세요
  • 타입스크립트 컴파일러가 에러 없이 정상적으로 작동해야 합니다

프론트엔드

  • 기존 React(혹은 Next) 프로젝트를 타입스크립트 프로젝트로 마이그레이션 해주세요
  • TypeScript를 활용해 프로젝트의 필요한 곳에 타입을 명시해 주세요

주요 변경사항

  • 기존에 두개의 컴포넌트로 사용하던 모달 컴포넌트를 하나의 컴포넌트로 통일
  • accessToken,refreshToken을 localStorage에서 저장하고 사용하는 방식에서 쿠키를 통해 사용하도록 변경
  • 로그인이 필요한 페이지로 이동할 때 로그인 돼있지 않을 경우 로그인 페이지로 이동시키는 미들웨어 구현
  • 로그인이 된 상태로 로그인,회원가입 페이지로 이동할 경우 상품페이지로 이동시키는 미들웨어 구현
  • 유저 프로필 데이터를 서버 사이드에서 로드하고 이를 GNB 컴포넌트의 프로필에 표시

멘토에게

  • 로그인 하지 않은 경우 로그인 페이지로 이동하는 미들웨어에 한가지 문제가 있습니다.

    • 로그인하지 않은 상태에서 상품페이지로 이동하면 로그인 페이지로 이동하는데, 로그인을 한 다음 다른 상품페이지로 이동하면 문제가 없는데 맨 처음 방문한 상품페이지로 이동하면 다시 로그인 페이지로 이동합니다. 캐싱과 관련된 문제인지 궁금합니다.
  • 로컬환경에선 요청을 보낼 때 정상적으로 쿠키가 포함되는데 vercel 배포환경에선 쿠키가 포함되지 않는데 어떻게 해결할 수 있을까요?

  • 배포환경에서 미들웨어가 정상적으로 작동하지 않는 것으로 확인되어서 일단 주석처리 해놨습니다. 확인해보니 httpOnly 때문에 직접 쿠키를 가져오는 게 불가능한 것으로 보이는데 넥스트 서버에서 쿠키를 사용할 수 있는 방법이 있을까요?

heonq and others added 30 commits December 20, 2024 09:39
- 기존에 두개로 사용하던 모달을 하나로 통합
@heonq heonq requested a review from pers0n4 February 9, 2025 05:47
@heonq heonq self-assigned this Feb 9, 2025
@heonq heonq added 매운맛🔥 뒤는 없습니다. 그냥 필터 없이 말해주세요. 책임은 제가 집니다. 최종 제출 스프린트미션 최종 제출본입니다. labels Feb 9, 2025
Copy link
Contributor

@pers0n4 pers0n4 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 +23 to 27
export default async function Page({
searchParams,
}: {
searchParams: GetArticleListParams;
}) {
Copy link
Contributor

Choose a reason for hiding this comment

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

객체는 인라인으로 타이핑하기보다는 interface나 type을 따로 정의해서 붙여주면 가독성이 더 좋아지지 않을까요?

Comment on lines +13 to +21
<ArticleHeader
ownerId={article.user.id}
id={article.id.toString()}
nickname={article.user.nickname}
title={article.title}
createdAt={article.createdAt}
likeCount={article.likeCount}
isLiked={article.isLiked}
/>
Copy link
Contributor

Choose a reason for hiding this comment

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

props를 전부 다 분해해두면 객체 구조에 얽매이진 않겠지만, 지금 ArticleHeader의 구조와 ArticleHeader가 사용되고 있는 예를 보면 이미 article 객체와 결합된 요소로 보이는데, 이 경우에는 article 객체 자체를 넘겨서 편의성을 챙겨보는 결정은 어떠신가요?
이렇게 객체와 결합된 경우는 리터럴 오브젝트 그대로 사용하는 대신 클래스로 정의해서 이점을 가져갈 수도 있습니다.
e.g. article.id.toString()의 경우 getter로 정의해서 일관성 가져가기

<div className='flex justify-between items-center gap-[6px] text-lg text-text-black-secondary'>
<Image
src={image !== null ? image : defaultAvatar}
src={image ?? defaultAvatar}
Copy link
Contributor

Choose a reason for hiding this comment

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

ㅋㅋ 훨씬 보기 좋네요.

Comment on lines +31 to +38
<BestArticleCard
key={article.id}
nickname={article.user.nickname}
title={article.title}
likeCount={article.likeCount}
createdAt={article.createdAt}
articleId={article.id.toString()}
/>
Copy link
Contributor

Choose a reason for hiding this comment

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

아까 본 ArticleClient와 비슷한 느낌이네요. 🤔


if (isLoading) return;
Array.from(
{ length: MEDIA_QUERY.bestArticlePageSize[screenWidth!] },
Copy link
Contributor

Choose a reason for hiding this comment

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

길어지는 변수는 함수로 분리하면 좋을 수도 있습니다. non-null assertion도 함수 내부 로직으로 뺄 수도 있곘네요.
e.g. getBestArticlePageSizeByScreenWidth(screenWidth)

@pers0n4 pers0n4 merged commit 25ae58a into codeit-sprint-fullstack:next-함헌규 Feb 17, 2025
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.

2 participants