[하신혜] Sprint 9#132
Merged
orlein merged 7 commits intocodeit-sprint-fullstack:next-하신혜from Dec 25, 2024
Hidden character warning
The head ref may contain hidden characters: "next-\ud558\uc2e0\ud61c-sprint9"
Merged
Conversation
orlein
approved these changes
Dec 25, 2024
Comment on lines
5
to
20
| const handleFavorite = async () => { | ||
| try { | ||
| const res = await fetch(`https://panda-market-api.vercel.app/products/${product.id}/favorite`, { | ||
| method: product.isFavorited ? 'DELETE' : 'POST', | ||
| const res = await fetch(`https://panda-market-api.vercel.app/products/${product?.id}/favorite`, { | ||
| method: product?.isFavorited ? 'DELETE' : 'POST', | ||
| headers: { Authorization: `Bearer ${localStorage.getItem('token')}` }, | ||
| }); | ||
| if (res.ok) { | ||
| alert('좋아요 상태가 변경되었습니다.'); | ||
| // 상태 업데이트 필요 | ||
| if (!res.ok) { | ||
| throw new Error('좋아요 상태 변경 실패'); | ||
| } | ||
| alert('좋아요 상태가 변경되었습니다.'); | ||
| // 상태 업데이트 필요 | ||
| } catch (error) { | ||
| console.error('Error toggling favorite:', error); | ||
| alert('좋아요 상태를 변경하는 중 오류가 발생했습니다.'); | ||
| } | ||
| }; |
There was a problem hiding this comment.
product가 존재하지 않는 상황을 위해 product?. 로 optional chaining을 한걸로 보입니다. 그런데, handleFavorite 자체가 product가 없는 경우 아예 실행되지 않아야 합니다. 밑에 if(product) 로 처리한것 처럼, 실행 자체를 막아버리면 에러가 나오지 않습니다.
| <div className={styles.productContent}> | ||
| <img src={product.image ? product.image : '/default.png'} alt={product.title || '상품이미지'} className={styles.productImage} /> | ||
| <img | ||
| src={product.image ? product.image : '/default.png'} |
There was a problem hiding this comment.
product.image도 없을 수 있고 이것이 default.png로 초기화되고있습니다. 25번 line에서 처리하는건 어떨까요?
| { | ||
| "compilerOptions": { | ||
| "paths": { | ||
| "@/*": ["./src/*"] |
| const res = await fetch(`https://panda-market-api.vercel.app/comments`, { | ||
| method: "POST", | ||
| headers: { | ||
| Authorization: `Bearer ${localStorage.getItem("token")}`, |
There was a problem hiding this comment.
Bearer만 딱 쓰는경우가 대다수이긴 하나 그렇지 않은 경우도 있습니다.realm등의 값이 들어갈 수도 있고 생각보다 다양합니다. Oauth를 사용한다면 rfc6750 를 읽어보세요- 공통 header는 공통 함수를 만들어서 주입하는편이 간단합니다.
Comment on lines
+88
to
+91
| if (isLoading) return <div>로딩 중...</div>; | ||
| if (error) return <div>오류가 발생했습니다: {error.message}</div>; | ||
|
|
||
| return ( |
|
|
||
| export default function Document() { | ||
| return ( | ||
| <Html lang="en"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
요구사항
기본 요구사항
공통
https://panda-market-api.vercel.app/docs를 확인해 주세요.
로그인/회원가입 페이지
로그인 페이지
회원가입 페이지
로그인, 회원가입 페이지 공통
GNB
상품 상세 페이지
심화 요구사항
로그인 및 회원가입 페이지 공통
유저 기능
멘토에게
셀프 코드 리뷰를 통해 질문 이어가겠습니다.