-
Notifications
You must be signed in to change notification settings - Fork 43
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
[김찬기] Sprint6 #222
Merged
withyj-codeit
merged 76 commits into
codeit-bootcamp-frontend:React-김찬기
from
cksrlcks:React-김찬기-sprint6
Dec 3, 2024
The head ref may contain hidden characters: "React-\uAE40\uCC2C\uAE30-sprint6"
Merged
[김찬기] Sprint6 #222
Changes from all commits
Commits
Show all changes
76 commits
Select commit
Hold shift + click to select a range
e7bf589
feat: ProtectedRoute 컴포넌트 추가 및 상품등록 페이지에 적용
cksrlcks 6f1ef49
feat: useForm hook 수정
cksrlcks 36ba19c
feat: Chip 컴포넌트 작업 (공용)
cksrlcks 8cbb035
feat: Tags List 컴포넌트 작업
cksrlcks 18366b1
feat: Input 컴포넌트 개선 (textarea 추가)
cksrlcks 028c1af
feat: Tag input 컴포넌트 작업
cksrlcks 093a254
feat: useForm hook 수정
cksrlcks a92f5f8
feat: FileInput 컴포넌트 작업
cksrlcks 04dac8d
feat: 상품추가 페이지 1차 작업 (통신없이 콘솔로만 데이터 찍히도록)
cksrlcks 4aa9d2a
feat: 이미지 업로드 및 상품추가 api 호출 작업
cksrlcks 6c08c56
feat: 상품추가 페이지 폼제출 작업
cksrlcks dc4855a
refactor: service error 객체 수정 (status도 받을수 있도록)
cksrlcks b006c7c
feat: auth context 개선
cksrlcks c0506ac
feat: 상품추가 페이지 개선
cksrlcks 6d438e0
chore: 사용안하는 코드 제거
cksrlcks 9508f24
feat: Alert 컴포넌트 작업
cksrlcks af0326a
feat: 상품추가 페이지 작업
cksrlcks 5b03f7b
fix: Proctected Route에서 accesstoken을 검사하도록 변경
cksrlcks 788fd6f
refactor: Field 컴포넌트 작업
cksrlcks cddd907
feat: useLocalArray 훅 작업 (최근검색어등에 사용)
cksrlcks 99ec63f
feat: 최근검색어 컴포넌트 작업
cksrlcks 44914fb
refactor: useAuth 컨텍스트 개선
cksrlcks 9e04b3b
feat: 최근검색, 검색 인풋 개선
cksrlcks 7517df8
refactor(mentor): 폴더명과 컴포넌트명 일치화 (Prodcut)
cksrlcks 7466805
refactor(mentor): 변수명이 배열을 의미하도록 변경(activePathList로 변경)
cksrlcks 4d728dc
refactor(mentor): Nav css내 오타수정
cksrlcks cf20418
refactor(mentor): Search 컴포넌트 개선
cksrlcks 478d31d
refactor(mentor): 공용 Container 컴포넌트 이름 변경 (PageContainer로 변경)
cksrlcks f3f987d
refactor(mentor): useAsync hook 개선
cksrlcks 8b0e53d
chore: 불필요한 파일 정리
cksrlcks ed0a767
refactor(mentor): Form Field Container 컴포넌트 이름 변경
cksrlcks ddb2d45
feat: useForm에서 배열요소를 다룰수 있도록 개선
cksrlcks 58aa7ca
feat: TagsInput이 배열 값을 다루도록 변경
cksrlcks 4c4acf0
feat: Tags 랜더링시 '#'기호 붙여서 랜더링하도록 수정
cksrlcks 10c47d0
bug: TagsInput에서 한글 작성후 enter시 글자가 짤리는 현상 수정
cksrlcks 0f6a269
chore: Textarea 컴포넌트내 불필요한 코드 정리
cksrlcks 98b2291
feat: NumberInput 컴포넌트 작업
cksrlcks 06f8666
fix: AddItem페이지 문구수정 (상품 소개)
cksrlcks 1ac333f
feat: useForm에서 custom validation을 할 수 있도록 개선
cksrlcks e668c12
feat: NumberInput이 format형태를 prop으로 받아서 사용할 수 있도록 개선 (재사용성 높이기)
cksrlcks 85602c6
chore: 안쓰는 임포트, 변수 코드 지우기
cksrlcks 472eb29
refactor(mentor): items 페이지에 멘토링시간에 배운 분리 적용 (presentational & conta…
cksrlcks d49857a
refactor: useSingleFile hook추가, 이미지 업로드 컴포넌트 개선
cksrlcks 19b69a7
chore: alias 수정
cksrlcks 56121d6
chore: alias 수정 (임포트된곳 바르게 고치기)
cksrlcks 4a271b8
refactor: form schema, message 분리
cksrlcks 1560dd6
refactor: Field 컴포넌트 리팩토링
cksrlcks 9ced152
refactor: usePagination, Pagination 컴포넌트 개선
cksrlcks eb6120d
refactor: 공용 Form 컴포넌트 추가
cksrlcks 9e3f609
chore: auth context 파일명 변경
cksrlcks f64e5df
refactor: Search 인풋, 최근검색어, useLocalStorage개선
cksrlcks b34e60f
refactor: 프로젝트 폴더, 파일구조 변경 (멘토링 참고)
cksrlcks 6644153
feat: 페이지네이션 기능 추가 (이전그룹, 다음그룹 넘기기)
cksrlcks 6427f21
refactor: 최근검색관련 items 페이지안에서 쓰는 hook으로 분리
cksrlcks 3f11986
refactor: useList 훅 개선, 전체상품페이지 개선
cksrlcks 89e62c1
fix: ProductFilter scss 파일명 오타 수정
cksrlcks 78806de
fix: usePagination 수정
cksrlcks f89e43a
refactor: 코드 정리
cksrlcks 9c25a84
refactor: react router 수정
cksrlcks 9d7f1d1
feat: Error 페이지에 router error 표시하기
cksrlcks d9185cf
refactor: 베스트상품도 전체상품과 동일한 api호출 함수로 변경
cksrlcks bf2d40b
feat: 태그 인풋 ux개선 및 keydown시 합성문자 해결
cksrlcks 2d24cc0
chore: AllItemsPage, BestItemsPage 코드 정리
cksrlcks ec28bb5
style: 최근검색 모달 그림자 추가
cksrlcks 8bd2e97
chore: README.md 수정
cksrlcks d8e2c08
feat: 로그인후 로그인, 회원가입페이지 접근시 items페이지로 이동 구현
cksrlcks 7ccee03
chore: README.md 수정
cksrlcks 6560fa0
fix: react router 경고 제거 (v7 future 관련 경고)
cksrlcks 3bd6277
refactor: useSyncParams 작업
cksrlcks 07917e8
bug: TagsInput에서 Enter시 폼제출 되는 현상 수정
cksrlcks 497894a
refactor: searchparams를 바로 이용하도록 개선
cksrlcks ce75b23
refactor: usePageSize return 형태 수정
cksrlcks 5e32e25
refactor: 이미지 썸네일 공용 컴포넌트 제작
cksrlcks 0040bbb
style: 공용 썸네일추가건으로 인한 스타일 보정
cksrlcks 6dbc364
fix: number input에 undefined가 못들어가도록 수정
cksrlcks f5f4499
fix: number input에 NaN이 나오는 현상 수정
cksrlcks File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,13 @@ | ||
import { Outlet } from "react-router-dom"; | ||
import { AuthProvider } from "./context/AuthContext"; | ||
import { RouterProvider } from "react-router-dom"; | ||
import { router } from "./router"; | ||
|
||
export default function App() { | ||
return ( | ||
<> | ||
<Outlet /> | ||
<AuthProvider> | ||
<RouterProvider router={router} /> | ||
</AuthProvider> | ||
</> | ||
); | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
@forward "input"; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
.field { | ||
position: relative; | ||
|
||
.field-box { | ||
display: block; | ||
width: 100%; | ||
height: 5.6rem; | ||
padding: 0 2.4rem; | ||
border: 1px solid transparent; | ||
border-radius: 12px; | ||
background: var(--color-secondary-100); | ||
|
||
&:focus, | ||
&.valid { | ||
border: 1px solid var(--color-primary-100); | ||
outline: none; | ||
} | ||
|
||
&.error { | ||
border: 1px solid var(--color-error); | ||
outline: none; | ||
} | ||
|
||
&::placeholder { | ||
color: var(--color-secondary-400); | ||
} | ||
|
||
&:has(~ button) { | ||
padding-right: 5rem; | ||
} | ||
} | ||
|
||
textarea.field-box { | ||
height: 28.2rem; | ||
padding: 2.4rem; | ||
resize: none; | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
@use "base"; | ||
@use "common"; |
This file was deleted.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import styles from "./Error.module.scss"; | ||
|
||
export function Error({ error }) { | ||
if (!error) { | ||
return null; | ||
} | ||
return ( | ||
<div className={styles["item-error"]}> | ||
{error || "오류가 발생했습니다."} | ||
</div> | ||
); | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
.item-error { | ||
margin-top: 0.8rem; | ||
padding-left: 1.6rem; | ||
font-size: 1.4rem; | ||
font-weight: 600; | ||
color: var(--color-error); | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import styles from "./FieldItem.module.scss"; | ||
|
||
export function FieldItem({ children }) { | ||
return <div className={styles["form-item"]}>{children}</div>; | ||
} | ||
|
||
function Label({ htmlFor, children }) { | ||
return ( | ||
<label className={styles["item-label"]} htmlFor={htmlFor}> | ||
{children} | ||
</label> | ||
); | ||
} | ||
|
||
FieldItem.Label = Label; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
@use "@assets/scss/base/mixins"; | ||
|
||
.form-item { | ||
margin-bottom: 2.4rem; | ||
position: relative; | ||
|
||
@include mixins.mobile { | ||
margin-bottom: 1.6rem; | ||
} | ||
|
||
.item-label { | ||
display: inline-block; | ||
margin-bottom: 1.6rem; | ||
font-size: 1.8rem; | ||
font-weight: 700; | ||
|
||
@include mixins.mobile { | ||
margin-bottom: 0.8rem; | ||
font-size: 1.4rem; | ||
} | ||
} | ||
|
||
.item-field { | ||
position: relative; | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { Alert, LoadingSpinner } from "@components/ui"; | ||
|
||
export function Form({ isLoading, error, onSubmit, children }) { | ||
return ( | ||
<> | ||
{isLoading && <LoadingSpinner />} | ||
{error && ( | ||
<Alert mode="error">{error.message || "오류가 발생했습니다."}</Alert> | ||
)} | ||
<form onSubmit={onSubmit}>{children}</form> | ||
</> | ||
); | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import useSingleFile from "@hooks/useSingleFile"; | ||
import { Thumbnail } from "@components/ui"; | ||
import { Error } from "@components/Field"; | ||
import iconPlus from "@assets/img/icon/icon_plus.svg"; | ||
import styles from "./ImageUpload.module.scss"; | ||
|
||
const LIMIT_SIZE_MB = 2; | ||
|
||
export function ImageUpload({ | ||
error, | ||
value, | ||
id, | ||
name, | ||
onChange, | ||
placeholder = "이미지 등록", | ||
}) { | ||
const { fileProps, fileError, handleRemove, preview } = useSingleFile({ | ||
name, | ||
value, | ||
accept: "image/*", | ||
limiSize: LIMIT_SIZE_MB, | ||
onChange: (file) => onChange(name, file), | ||
errorMessage: { | ||
max: "이미지 등록은 최대 1개까지 가능합니다.", | ||
accept: "이미지 파일만 업로드 가능합니다.", | ||
}, | ||
}); | ||
|
||
// 두가지 에러 동시에 보내려고 문자열로 합침 | ||
const fileInputError = [fileError, error].filter((err) => err).join(" / "); | ||
|
||
return ( | ||
<> | ||
<div className={styles["thumbnail-list"]}> | ||
<label className={styles["upload-button"]}> | ||
<span className={styles["upload-label"]}> | ||
<img src={iconPlus} alt="이미지 업로드" /> | ||
{placeholder} | ||
</span> | ||
<input id={id} name={name} className="a11y" {...fileProps} /> | ||
</label> | ||
<div className={styles.preview}> | ||
{preview && ( | ||
<Thumbnail | ||
src={preview} | ||
alt="상품 이미지 등록" | ||
onRemove={handleRemove} | ||
/> | ||
)} | ||
</div> | ||
</div> | ||
<Error error={fileInputError} /> | ||
</> | ||
); | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
.thumbnail-list { | ||
display: flex; | ||
gap: 2.4rem; | ||
} | ||
|
||
.upload-button { | ||
overflow: hidden; | ||
position: relative; | ||
display: block; | ||
width: 100%; | ||
max-width: 28.2rem; | ||
border-radius: 1.6rem; | ||
background: var(--color-secondary-100); | ||
cursor: pointer; | ||
|
||
&:before { | ||
content: ""; | ||
display: block; | ||
width: 100%; | ||
height: 0; | ||
padding-bottom: 100%; | ||
} | ||
|
||
.upload-label { | ||
position: absolute; | ||
left: 0; | ||
top: 0; | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
justify-content: center; | ||
gap: 1.3rem; | ||
width: 100%; | ||
height: 100%; | ||
color: var(--color-secondary-400); | ||
} | ||
} | ||
|
||
.preview { | ||
max-width: 28.2rem; | ||
} |
Oops, something went wrong.
Oops, something went wrong.
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.
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.
고민했던 것들 정리해서 기록하는 것 매우 좋아요~👍
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.
개인적으로 data fetching 하는 hook 하나 (다른 api콜 할 때도 사용하는 공용 hook),
data fetching 하는 hook을 사용해서 실제 서비스에 필요한 api 콜하고 데이터를 받고 필요한 데이터 정제 및 일부 필요한 기능이 들어있는 hook 하나 이렇게 분리해서 사용하는게 깔끔했었어요.
참고 링크는 이후에 다루게 되는 react-query의 예시인데 useQuery같이 api 콜에 필요한 기능을 가진 hook이 있고, 그리고 이걸 래핑해서 구현해서 사용하는 custom hook으로 분리하는 방식으로 사용하는 방식이 좋았어요.
물론 간단한 요청의 경우 data fetching 하는 hook을 바로 사용 하는 것도 괜찮은 옵션이라 생각해요.
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.
리액트쿼리 적용할때 참고해서 적용해보겠습니다!