Skip to content

Conversation

@TopiaYu
Copy link
Collaborator

@TopiaYu TopiaYu commented May 10, 2025

https://scintillating-ganache-14d305.netlify.app/additems

요구사항

기본

상품 등록

  • 상품 등록 페이지 주소는 “/additem” 입니다.
  • 페이지 주소가 “/additem” 일때 상단네비게이션바의 '중고마켓' 버튼의 색상은 “3692FF”입니다.
  • 상품 이미지는 최대 한개 업로드가 가능합니다.
  • 각 input의 placeholder 값을 정확히 입력해주세요.
  • 이미지를 제외하고 input 에 모든 값을 입력하면 ‘등록' 버튼이 활성화 됩니다.
  • API를 통한 상품 등록은 추후 미션에서 적용합니다.

심화

  • 이미지 안의 X 버튼을 누르면 이미지가 삭제됩니다.
  • 추가된 태그 안의 X 버튼을 누르면 해당 태그는 삭제됩니다.

주요 변경사항

  • additems 페이지 구현
  • 파일 업로드 구현
  • 태그 추가 삭제 구현

스크린샷

데스크탑 Screenshot 2025-05-11 at 3 48 48 am
모바일 Screenshot 2025-05-11 at 3 50 00 am

멘토에게

  • 셀프 코드 리뷰를 통해 질문 이어가겠습니다.

@TopiaYu TopiaYu requested a review from GANGYIKIM May 10, 2025 18:53
@TopiaYu TopiaYu self-assigned this May 10, 2025
@TopiaYu TopiaYu added the 매운맛🔥 뒤는 없습니다. 그냥 필터 없이 말해주세요. 책임은 제가 집니다. label May 10, 2025
Copy link
Collaborator

@GANGYIKIM GANGYIKIM left a comment

Choose a reason for hiding this comment

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

동환님 6번째 미션 제출 고생하셨습니다~
미션 5에서 드렸던 코멘트와 중복되는 코멘트는 지양하고 있습니다! 참고해주세요~
다음 미션도 화이팅입니다!

Comment on lines +74 to +76
const addItemImageWrapper = css`
`
Copy link
Collaborator

Choose a reason for hiding this comment

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

❗️ 수정요청
빈 css block은 지우시는 것을 추천드려요!

Suggested change
const addItemImageWrapper = css`
`

}
`

const ItemTag = css`
Copy link
Collaborator

Choose a reason for hiding this comment

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

❗️수정요청
스타일을 정의할 때 ItemTag처럼 대문자로 시작하면 컴포넌트처럼 보일 수 있어 혼동을 줄 수 있습니다.
스타일 객체는 일반 변수로 간주되므로 첫문자를 소문자로 작성하는 것이 좋을 것 같아요!

<input
id='fileUpload'
type='file'
accept='image/*'
Copy link
Collaborator

Choose a reason for hiding this comment

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

💊 제안
input의 accept 속성은 유저가 어떤 파일을 올려야하는지에 대한 힌트를 제공하는 속성입니다.
유저는 파일 업로드시 accept의 명시된 확장자 이외의 파일도 올릴 수 있으므로
실제 upload 함수에서 한번더 확장자를 검사해주시는 것이 좋습니다.

(사용자가 업로드창에서 옵션을 열어 확장자를 바꾸면 아래처럼 보입니다)
스크린샷 2025-05-08 오후 5 53 17

https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/accept

return <div>AddItem</div>;

const [imgPreviewUrl, setImgPreviewUrl] = useState(null); // 추가했을때 이미지프리뷰
const [showWarning, setShowWarning] = useState(false);
Copy link
Collaborator

Choose a reason for hiding this comment

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

💊 제안
boolean 타입을 추론할 수 있게 isWarning, isImageUploaded 같은 이름을 추천드립니다~
추가로 imgPreviewUrl state를 통해 업로드된 이미지가 존재하는지 파악할 수 있어 해당 state는 없어도 될 것 같아요~

Comment on lines +53 to +55
const handleSubmitButton = () => {

}
Copy link
Collaborator

Choose a reason for hiding this comment

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

❗️ 수정요청

Suggested change
const handleSubmitButton = () => {
}

</div>
</label>
{imgPreviewUrl && (
<div css={previewBox}>
Copy link
Collaborator

Choose a reason for hiding this comment

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

❗️ 수정요청
해당 영역이 header위로 올라가네요. 확인해보시고 수정해보세요~
스크린샷 2025-05-14 오후 4 51 24

Comment on lines +126 to +127
<label>판매가격</label>
<input id="price" placeholder="판매가격을 입력해주세요" type='number' value={itemPrice} onChange={(e) => setItemPrice(e.target.value)}></input>
Copy link
Collaborator

Choose a reason for hiding this comment

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

💊 제안
라벨과 인풋을 사용하셨으니 연결해서 라벨 클릭시 자동으로 인풋으로 포커스가 가게 해주세요.

Suggested change
<label>판매가격</label>
<input id="price" placeholder="판매가격을 입력해주세요" type='number' value={itemPrice} onChange={(e) => setItemPrice(e.target.value)}></input>
<label htmlFor="price">판매가격</label>
<input id="price" placeholder="판매가격을 입력해주세요" type='number' value={itemPrice} onChange={(e) => setItemPrice(e.target.value)}></input>

id="tag"
placeholder="태그를 입력해주세요"
value={itemTag} onChange={(e) => setItemTag(e.target.value)}
onKeyDown={(e) => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

💊 제안
onKeyDown 내부 로직이 길어지면 컴포넌트가 복잡해지므로, 별도의 핸들러 함수로 분리하면시면 좋겠습니다.

Copy link
Collaborator

Choose a reason for hiding this comment

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

❗️ 수정요청
한글로된 태그를 생성할 때 두번 입력이 발생하는 것 같은 현상이 있습니다. 이는 자모음으로 이루어진 한글을 입력중에 발생하는 현상입니다~
배포사이트에서 한글로 태그를 생성해보시고, 위의 동작을 고쳐보세요~

https://toby2009.tistory.com/53

Comment on lines +141 to +143
if (!itemHashTag.includes(newTag)) {
setItemHashTag((prev) => [...prev, newTag])
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

💊 제안
중복되는 태그가 생성되지 않도록 해주신 점 좋습니다!
다만 이렇게 되면 사용자가 해당 동작에 대한 피드백을 받지 못하므로, alert, toast, input error 와 같은 방식으로 피드백을 주시면 더 좋을 것 같아요.

Copy link
Collaborator

Choose a reason for hiding this comment

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

💊 제안
하나의 파일이 너무 큰 것 같아요~
내부적으로 아이템 생성을 위한 로직들과 state가 custom hook으로 분리되고 UI 들도 컴포넌트로 분리되면,
가독성 측면에서 더 좋을 것 같아요.
컴포넌트로 분리하는 것은 생각의 단위를 나누는 것과 같이 때문에 너무 크게 가지고 가시면 로직을 파악하기도 어렵고 유지보수시에도불리합니다!

@GANGYIKIM GANGYIKIM merged commit 2d1a5b4 into codeit-bootcamp-frontend:React-유동환 May 14, 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