-
Notifications
You must be signed in to change notification settings - Fork 1
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
Feat: ProductItem 시간, style, Type 변경, 프로필 이미지 추가 #123
Changes from all commits
cb2cd46
7fe87a0
05935db
18e7a9b
7975ca6
3bc8ac0
b63f5af
2e1a9b6
758c7ab
8340f12
e8994f5
eeefb2a
05e9922
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,11 @@ | ||
import jordanBlackImage from '@/assets/images/jordan_black.jpeg'; | ||
import TimeLabel from '../atomic/TimeLabel'; | ||
import { ReactNode } from 'react'; | ||
|
||
export interface ProductProps { | ||
auctionId?: number; | ||
productName: string; | ||
minPrice: number; | ||
cdnPath?: string | null; | ||
imageUrl?: string; | ||
timeRemaining?: number; | ||
participantCount?: number; | ||
isParticipating?: boolean; | ||
|
@@ -22,7 +21,7 @@ const ProductItem = ({ product, children }: { product: ProductProps; children: R | |
<div className='flex flex-col'> | ||
<div className='w-full h-auto mb-4'> | ||
<div className='relative'> | ||
<img className='object-cover w-full h-[15rem] rounded-t' src={`${product.cdnPath ? product.cdnPath : jordanBlackImage}`} alt='Jordan Black Shoes' /> | ||
<img className='object-cover w-full h-[15rem] rounded-t' src={product.imageUrl} alt='제품 사진' /> | ||
{product.timeRemaining && <TimeLabel time={product.timeRemaining} />} | ||
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. 여기도 위와 마찬가지로 Default image필요없을 것 같습니다. |
||
</div> | ||
</div> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,14 +2,18 @@ import type { IUserAuctionLostItem } from 'AuctionItem'; | |
import { IoPricetagsOutline } from 'react-icons/io5'; | ||
import { LuUsers } from 'react-icons/lu'; | ||
import ProductItem from '../common/item/ProductItem'; | ||
import { formatCurrencyWithWon } from '@/utils/formatCurrencyWithWon'; | ||
|
||
const OrderLostProduct = ({ product }: { product: IUserAuctionLostItem }) => { | ||
const date = new Date(product.endDateTime); | ||
const year = date.getFullYear(); | ||
const month = String(date.getMonth() + 1).padStart(2, '0'); | ||
const day = String(date.getDate()).padStart(2, '0'); | ||
|
||
const formattedDate = `${year}.${month}.${day}`; | ||
const formattedDate = `${year}년 ${month}월 ${day}일`; | ||
const formattedMinPrice = formatCurrencyWithWon(product.minPrice); | ||
const formattedHighPrice = formatCurrencyWithWon(product.highestAmount); | ||
|
||
|
||
return ( | ||
<ProductItem product={product}> | ||
|
@@ -18,7 +22,7 @@ const OrderLostProduct = ({ product }: { product: IUserAuctionLostItem }) => { | |
<IoPricetagsOutline className='text-gray-500' /> | ||
<p className='text-sm text-gray-500'>시작가</p> | ||
</div> | ||
<p className='ml-4 font-semibold'>{`${product.minPrice.toLocaleString()}원`}</p> | ||
<p className='ml-4 font-semibold'>{formattedMinPrice}</p> | ||
</div> | ||
<div className='flex'> | ||
<div className='flex gap-2'> | ||
|
@@ -32,7 +36,7 @@ const OrderLostProduct = ({ product }: { product: IUserAuctionLostItem }) => { | |
<LuUsers className='text-gray-500' /> | ||
<p className='text-sm text-gray-500'>가장 높은 금액</p> | ||
</div> | ||
<p className='ml-4 font-semibold'>{`${(product.highestBid).toLocaleString()}원`}</p> | ||
<p className='ml-4 font-semibold'>{formattedHighPrice}</p> | ||
</div> | ||
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. 숫자를 원으로 바꾸는 함수를 util 함수에 작성해놨으니 그거 사용하시면 됩니다. 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. 넵! |
||
</ProductItem> | ||
); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { Dispatch, SetStateAction } from 'react'; | ||
import { Input } from '../ui/input'; | ||
import { useProfileImageUploader } from '@/hooks/useProfileImageUploader'; | ||
import { Button } from '../ui/button'; | ||
import ProfileEdit from '@/assets/icons/profile_edit.svg' | ||
|
||
interface ImageUploaderProps { | ||
image: string | null; | ||
setImage: Dispatch<SetStateAction<string | null>>; | ||
file: File | null; | ||
setFile: Dispatch<SetStateAction<File | null>>; | ||
} | ||
|
||
const ProfileImageUploader = ({ file, setFile, image, setImage }: ImageUploaderProps) => { | ||
const { fileInputRef, deleteImage, handleImage, handleBoxClick } = useProfileImageUploader(image, setImage, file, setFile); | ||
|
||
return ( | ||
<div className="flex flex-col items-center gap-4"> | ||
{image ? ( | ||
<div className="relative w-40 h-40"> | ||
<img src={image} alt="프로필 사진" className="object-cover w-full h-full rounded-full" /> | ||
<Button | ||
type='button' | ||
className="absolute top-[-5%] right-[-5%] bg-red-500 text-white rounded-full p-1 cursor-pointer" | ||
onClick={deleteImage} | ||
aria-label="프로필 사진 삭제" | ||
> | ||
삭제 | ||
</Button> | ||
</div> | ||
) : ( | ||
<div className="relative w-40 h-40" onClick={handleBoxClick}> | ||
<img src={ProfileEdit} alt="프로필 사진" className="object-cover w-full h-full rounded-full" /> | ||
</div> | ||
)} | ||
<Input | ||
ref={fileInputRef} | ||
type="file" | ||
id="사진" | ||
className="hidden" | ||
accept="image/*" | ||
onChange={handleImage} // 다수의 파일을 받지 않음 | ||
aria-label="프로필 사진 업로드 인풋" | ||
role="button" | ||
/> | ||
</div> | ||
); | ||
}; | ||
|
||
export default ProfileImageUploader; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,17 @@ | ||
import { UserProfile } from '@/@types/user'; | ||
import { httpClient } from '@/api/axios'; | ||
import { API_END_POINT } from '@/constants/api'; | ||
|
||
export const getProfile = async () => { | ||
const response = await httpClient.get(`${API_END_POINT.PROFILE}`); | ||
const response = await httpClient.get(`${API_END_POINT.SIGNUP}`); | ||
return response.data; | ||
}; | ||
|
||
export const postEditProfile = async (data: UserProfile) => { | ||
const response = await httpClient.post(`${API_END_POINT.PROFILE}/profile`,data); | ||
export const postEditProfile = async (formData: FormData) => { | ||
const response = await httpClient.post(`${API_END_POINT.PROFILE}`, formData, { | ||
headers: { | ||
'Content-Type': 'multipart/form-data', | ||
}, | ||
}); | ||
|
||
return response.data; | ||
}; |
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.
alt 값도 수정이 필요해보입니다.