-
Notifications
You must be signed in to change notification settings - Fork 37
[송형진] Sprint7 #300
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 #300
The head ref may contain hidden characters: "React-\uC1A1\uD615\uC9C4"
Conversation
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.
수고하셨습니다 :)
} | ||
|
||
export async function postCommentData({ productId, editContent }) { | ||
const token = |
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.
토큰의 경우 github 에 올리시기보다 환경변수로 로컬에서 관리해주셔야해요!
https://velog.io/@milkboy2564/Next.js-env%ED%99%98%EA%B2%BD-%EB%B3%80%EC%88%98-%EC%A0%95%EB%A6%AC
/> | ||
</div> | ||
<ul className={`all-product-list ${mode}`}> | ||
{allItemList.map((item) => ( |
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.
여기서 구조분해 할당해서 가져와도 좋겠네요!
{allItemList.map((item) => ( | |
{allItemList.map(({id, images, name, price}) => ( |
ownerNickname, | ||
createdAt, | ||
}) { | ||
const [users, setUsers] = useState([]); |
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.
user 타입 정의해주시면 좋을 거 같아요!
const formatDate = (dateString) => { | ||
const date = new Date(dateString); | ||
const year = date.getFullYear(); | ||
// getMonth()는 0부터 시작하므로 +1을 해주고, padStart로 2자리 맞추기 | ||
const month = String(date.getMonth() + 1).padStart(2, "0"); | ||
const day = String(date.getDate()).padStart(2, "0"); | ||
|
||
return `${year}.${month}.${day}`; | ||
}; |
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.
이 부분은 실제 로직과 관련없는 계산부라 util 함수로 빼도 좋을 거 같아요!
//..시간 전으로 렌더링되게. | ||
function getTimeDifference(createdAt, updatedAt) { | ||
const created = new Date(createdAt); | ||
const updated = new Date(updatedAt); | ||
|
||
// 밀리초 단위의 차이를 시간으로 변환 | ||
const diffInHours = Math.floor((updated - created) / (1000 * 60 * 60)); | ||
|
||
if (diffInHours === 0) { | ||
// 1시간 미만인 경우 분 단위로 표시 | ||
const diffInMinutes = Math.floor((updated - created) / (1000 * 60)); | ||
return `${diffInMinutes}분 전`; | ||
} else if (diffInHours < 24) { | ||
// 24시간 미만인 경우 | ||
return `${diffInHours}시간 전`; | ||
} else { | ||
// 24시간 이상인 경우 일 단위로 표시 | ||
const diffInDays = Math.floor(diffInHours / 24); | ||
return `${diffInDays}일 전`; | ||
} | ||
} |
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.
여기도 util 함수인 거 같아요!
요구사항
기본
심화
주요 변경사항
스크린샷
멘토에게