-
Notifications
You must be signed in to change notification settings - Fork 39
[유용민] sprint7 #206
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
[유용민] sprint7 #206
The head ref may contain hidden characters: "React-\uC720\uC6A9\uBBFC-sprint7"
Conversation
GANGYIKIM
left a comment
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.
용민님 7번째 미션 작업 고생하셨습니다.
Date 관련 로직들도 분리해주시고 가독성을 신경쓰신 부분들이 많이 보여 좋았습니다.
다음 미션도 화이팅입니다!
수정하기는 해당 댓글을 수정할 수 있도록 input만 나오도록 해 놓았는데, 이는 원래 로그인 한 사람만 가능하게 해야 하지 않을까 싶어서 api까지 구현해 놓지는 않았습니다.:
말씀하신 것처럼 댓글 디자인에 유저 정보가 있어 로그인 한 사람만 댓글을 달 수 있는 것이 맞습니다. 추후 로그인 기능을 구현하시고 12주차에서 댓글 달기, 수정, 삭제 기능을 구현할 수 있게 되어 있으니 그때 추가하시면 될 것 같아요!
| const now = new Date().getTime(); | ||
| const diff = Math.round((time - now) / dayInMs); | ||
|
|
||
| const formatter = new Intl.RelativeTimeFormat("ko"); |
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.
👍 칭찬
내장 메소드로 간단하게 코드 작성하신 것 너무 좋아요~
다만 지금 코드의 경우 ${day}일 전의 형태로만 나오고 있어요.
디자인을 확인해보시면, days, months 등의 다양한 형태로 나오고 있으니
추후 기획대로 변경해보시면 더 좋을 것 같아요!
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.
👍 칭찬
이런 formatting 로직들은 사이트에서 재사용되는 경우가 대부분이니 따로 분리해주신 점 좋아요!
| return formatter.format(diff, "days"); | ||
| } | ||
|
|
||
| export function formatDateToYMD(dateString) { |
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.
💊 제안
formatToTimeAgo 함수에서 Intl 을 이용하신 것처럼 지금 함수에서도 Intl.DateTimeFormat을 이용해서 작성하실 수 있습니다~
https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat
| {item.tags && | ||
| item.tags.map((tag) => ( |
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.
💊 제안
item 의 기본값이 null이므로 아래처럼 optional chaining을 이용해서 작성하셔도 됩니다~
| {item.tags && | |
| item.tags.map((tag) => ( | |
| {item?.tags?.map((tag) => ( | |
| <div className="flex border border-[#E5E7EB] rounded-full px-2 py-0.5"> | ||
| <HeartIcon /> | ||
| <p>{item.favoriteCount}</p> | ||
| </div> |
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.
💊 제안
추후 좋아요 버튼으로 활용될 영역이니 button 태그가 더 적절할 것 같아요~
| <button | ||
| type="submit" | ||
| className={`py-2.5 px-4 rounded-md transition-all text-white cursor-pointer | ||
| ${ | ||
| commentText.trim() === "" | ||
| ? "bg-gray-300 cursor-not-allowed" | ||
| : "bg-[#3692FF] hover:scale-120" | ||
| } | ||
| `} |
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.
💊 제안
| <button | |
| type="submit" | |
| className={`py-2.5 px-4 rounded-md transition-all text-white cursor-pointer | |
| ${ | |
| commentText.trim() === "" | |
| ? "bg-gray-300 cursor-not-allowed" | |
| : "bg-[#3692FF] hover:scale-120" | |
| } | |
| `} | |
| <button | |
| type="submit" | |
| className={`py-2.5 px-4 rounded-md transition-all text-white cursor-pointer ${commentText.trim() === "" ? "bg-gray-300 cursor-not-allowed" : "bg-[#3692FF] hover:scale-120"}`} | |
| value={commentText} | ||
| onChange={(e) => setCommentText(e.target.value)} |
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.
💊 제안
지금처럼 textarea 값을 useState로 제어하면 사용자가 입력할 때마다 컴포넌트가 리렌더링됩니다.
지금 코드상에서는 textarea 값을 바꿔주는 것이 아니라 제어 컴포넌트로 관리할 필요가 없을 것 같아요!
이를 비제어 컴포넌트로 바꾸셔서 불필요한 리렌더링을 줄이시는 것을 추천드려요!
등록 버튼의 활성화를 위해서는 isValidComment와 같은 다른 props를 만드시는게 더 적절할 것 같아요.
| comments.map((comment) => ( | ||
| <div className="flex flex-col gap-10 border-b border-b-gray-200 pb-5"> |
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.
❗️ 수정요청
| comments.map((comment) => ( | |
| <div className="flex flex-col gap-10 border-b border-b-gray-200 pb-5"> | |
| comments.map((comment) => ( | |
| <div key={comment.id} className="flex flex-col gap-10 border-b border-b-gray-200 pb-5"> |
| 취소 | ||
| </button> | ||
| <button | ||
| className="text-[1rem] font-[600] px-5 py-2 bg-[#3692FF] text-white rounded-xl" |
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.
❗️ 수정요청
| className="text-[1rem] font-[600] px-5 py-2 bg-[#3692FF] text-white rounded-xl" | |
| className="text-[1rem] font-[600] px-5 py-2 bg-[#3692FF] text-white rounded-xl cursor-pointer" |
| <VerticalEllipsis /> | ||
| </button> | ||
| {openMenuId === comment.id && ( | ||
| <div className="absolute right-0 mt-2 w-32 bg-white border border-gray-200 rounded shadow-md z-10"> |
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.
💊 제안
메뉴 외의 영역을 눌렀을때도 닫히게 해주시면 더 사용성이 좋아질 것 같아요.
요구사항
https://15-sprint-mission-tawny.vercel.app/
기본
상품 상세
=> favoriteCount : 하트 개수
=> images : 상품 이미지
=> tags : 상품태그
=> name : 상품 이름
=> description : 상품 설명
상품 문의 댓글
=> image : 작성자 이미지
=> nickname : 작성자 닉네임
=> content : 작성자가 남긴 문구
=> description : 상품 설명
=> updatedAt : 문의글 마지막 업데이트 시간
심화
주요 변경사항
스크린샷
멘토에게
수정하기는 해당 댓글을 수정할 수 있도록 input만 나오도록 해 놓았는데, 이는 원래 로그인 한 사람만 가능하게 해야 하지 않을까 싶어서 api까지 구현해 놓지는 않았습니다.
셀프 코드 리뷰를 통해 질문 이어가겠습니다.