-
Notifications
You must be signed in to change notification settings - Fork 40
[오병훈] Sprint8 #257
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
The head ref may contain hidden characters: "React-\uC624\uBCD1\uD6C8-sprint8"
[오병훈] Sprint8 #257
Changes from all commits
9fdb8b2
a603c1c
f509f7a
12acf52
1bc03f7
5c6fe99
112d695
fe42eef
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| declare module '*.png'; | ||
| declare module '*.svg'; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,11 @@ import { useEffect, useState } from 'react'; | |
| import { getProducts } from '../api'; | ||
| import ItemCard from './ItemCard'; | ||
| import '../style/Items.css'; | ||
| import { | ||
| Product, | ||
| ProductListResponse, | ||
| ProductOrderBy, | ||
| } from './types/productTypes'; | ||
|
|
||
| const getPageSize = () => { | ||
| const width = window.innerWidth; | ||
|
|
@@ -18,11 +23,20 @@ const getPageSize = () => { | |
| }; | ||
|
|
||
| function BestItemSection() { | ||
| const [itemList, setItemList] = useState([]); | ||
| const [itemList, setItemList] = useState<Product[]>([]); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 굳굳 ! 여러 곳에서 사용될 타입을 정의함으로서 재사용성을 높였군요 ! 👍👍 |
||
| const [pageSize, setPageSize] = useState(getPageSize()); | ||
|
|
||
| const fetchSortedData = async ({ orderBy, pageSize }) => { | ||
| const products = await getProducts({ orderBy, pageSize }); | ||
| const fetchSortedData = async ({ | ||
| orderBy, | ||
| pageSize, | ||
| }: { | ||
| orderBy: ProductOrderBy; | ||
| pageSize: number; | ||
| }) => { | ||
| const products: ProductListResponse = await getProducts({ | ||
| orderBy, | ||
| pageSize, | ||
| }); | ||
| setItemList(products.list); | ||
| }; | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,15 +1,25 @@ | ||
| import { useEffect, useRef, useState } from 'react'; | ||
| import { ChangeEvent, useEffect, useRef, useState } from 'react'; | ||
| import '../style/ProductCreateForm.css'; | ||
| import { ReactComponent as PlusIcon } from '../images/ic_plus.svg'; | ||
| import { ReactComponent as DeleteIcon } from '../images/ic_X.svg'; | ||
|
|
||
| function FileInput({ name, value, initialPreview, onChange }) { | ||
| interface FileInputProps { | ||
| name: string; | ||
| value: File | null; | ||
| initialPreview: string | null; | ||
| onChange: (name: string, value: File | null) => void; | ||
| } | ||
|
Comment on lines
+6
to
+11
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 훌륭합니다. 😊 깔끔한 타입이예요. |
||
|
|
||
| function FileInput({ name, value, initialPreview, onChange }: FileInputProps) { | ||
| const [preview, setPreview] = useState(initialPreview); | ||
| const inputRef = useRef(); | ||
| const inputRef = useRef<HTMLInputElement | null>(null); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| const [isImageValid, setIsImageValid] = useState(false); | ||
|
|
||
| const handleChange = (e) => { | ||
| const nextValue = e.target.files[0]; | ||
| const handleChange = (e: ChangeEvent<HTMLInputElement>) => { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 함수 이벤트 타입도 명확하구요 ! |
||
| const fileList = e.target.files; | ||
| if (!fileList || fileList.length === 0) return; | ||
|
|
||
| const nextValue = fileList[0]; | ||
| onChange(name, nextValue); | ||
| setIsImageValid(true); | ||
| }; | ||
|
|
@@ -55,7 +65,7 @@ function FileInput({ name, value, initialPreview, onChange }) { | |
| <div className="preview-container"> | ||
| <img | ||
| className="image-preview" | ||
| src={preview} | ||
| src={preview || ''} | ||
| alt="이미지 미리보기" | ||
| /> | ||
| <button className="image-delete-btn" onClick={handleClearClick}> | ||
|
|
||
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.
크으 굳굳 ! 타입을 확인해보니
"recent" | "favorite"군요 !명확한 타입입니다 ! 굳굳 ~! 👍