-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: bid list API, change auction detail UI (#95)
* feat: impl bid list API * feat: change API schema and query reset * fix: change ui to accordion and tooltip * feat: change UI to friendly * refactor: component decomposition * refactor: decomposition accordion component
- Loading branch information
Showing
9 changed files
with
206 additions
and
71 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { AccordionButton, AccordionIcon, Text } from '@chakra-ui/react'; | ||
import { PropsWithChildren } from 'react'; | ||
|
||
interface AuctionAccordionHeaderProps extends PropsWithChildren { | ||
title: string; | ||
} | ||
|
||
const AuctionAccordionHeader = ({ title }: AuctionAccordionHeaderProps) => { | ||
return ( | ||
<AccordionButton> | ||
<Text fontSize="x-large" fontWeight="600" flex="1" textAlign="left"> | ||
{title} | ||
</Text> | ||
<AccordionIcon /> | ||
</AccordionButton> | ||
); | ||
}; | ||
|
||
export default AuctionAccordionHeader; |
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,39 @@ | ||
import { Box, Table, Tbody, Td, Th, Thead, Tr } from '@chakra-ui/react'; | ||
import { useQuery } from '@tanstack/react-query'; | ||
import { getAuctionBidList } from 'src/apis/auctions'; | ||
|
||
interface AuctionBidListProps { | ||
auctionId: number; | ||
} | ||
const AuctionBidList = ({ auctionId }: AuctionBidListProps) => { | ||
const { data, status } = useQuery({ | ||
queryKey: ['auctionBidList', auctionId], | ||
queryFn: () => getAuctionBidList({ auctionId }), | ||
}); | ||
|
||
if (status === 'error') return <>에러 상태</>; | ||
if (status === 'pending') return <>로딩 중 ...</>; | ||
|
||
return ( | ||
<Box> | ||
<Table size="sm"> | ||
<Thead> | ||
<Tr> | ||
<Th>입찰자 닉네임</Th> | ||
<Th>입찰 가격</Th> | ||
</Tr> | ||
</Thead> | ||
<Tbody> | ||
{data.bids.map((bid, index) => ( | ||
<Tr key={index}> | ||
<Td>{bid.nickname}</Td> | ||
<Td>{bid.price.toLocaleString('ko-KR')}</Td> | ||
</Tr> | ||
))} | ||
</Tbody> | ||
</Table> | ||
</Box> | ||
); | ||
}; | ||
|
||
export default AuctionBidList; |
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
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
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,29 @@ | ||
import { | ||
Stat, | ||
StatArrow, | ||
StatHelpText, | ||
StatLabel, | ||
StatNumber, | ||
Tooltip, | ||
} from '@chakra-ui/react'; | ||
|
||
interface CurrentPriceStatProps { | ||
nowPrice: number; | ||
startPrice: number; | ||
} | ||
const CurrentPriceStat = ({ nowPrice, startPrice }: CurrentPriceStatProps) => { | ||
return ( | ||
<Stat> | ||
<StatLabel>현재 가격</StatLabel> | ||
<StatNumber>{nowPrice.toLocaleString('ko-KR')}원</StatNumber> | ||
<Tooltip padding={2} label="시작가 대비 얼마나 올랐는지 알려드려요."> | ||
<StatHelpText> | ||
<StatArrow type="increase" /> | ||
{(((nowPrice - startPrice) / startPrice) * 100).toFixed(2)}% | ||
</StatHelpText> | ||
</Tooltip> | ||
</Stat> | ||
); | ||
}; | ||
|
||
export default CurrentPriceStat; |
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