Skip to content

Commit

Permalink
show count in trades
Browse files Browse the repository at this point in the history
  • Loading branch information
matthias-luger committed Nov 27, 2023
1 parent 8853173 commit 8c8639a
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 43 deletions.
1 change: 1 addition & 0 deletions api/ApiHelper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1963,6 +1963,7 @@ export function initAPI(returnSSRResponse: boolean = false): API {
},
data: '',
resolve: data => {
console.log(data)
resolve(data ? (data as TradeObject[]).slice(Math.max(data.length - 36, 0)).map(parseInventoryData) : [])
},
reject: (error: any) => {
Expand Down
89 changes: 47 additions & 42 deletions components/PlayerInventory/PlayerInventory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,48 +37,53 @@ export default function PlayerInventory(props: Props) {
let isTradeable = !isSouldbound && item.tag !== 'SKYBLOCK_MENU'
return (
<div className={styles.gridCell}>
<Tooltip
type="hover"
className={styles.hoverElement}
hoverPlacement="bottom"
id={styles.tooltipHoverId}
content={
<img
title={removeMinecraftColorCoding(item.itemName)}
className={styles.image}
src={api.getItemImageUrl({ tag: item.tag })}
alt=""
crossOrigin="anonymous"
height={48}
style={isTradeable ? { cursor: 'pointer' } : {}}
onClick={() => {
if (!isTradeable) {
return
}
if (props.onItemClick) {
props.onItemClick(item)
}
}}
/>
}
tooltipContent={
<div style={{ maxWidth: '100%' }}>
{isSouldbound ? <p>{getMinecraftColorCodedElement(`§4§lNot tradeable - Item is Soulbound`)}</p> : null}
<p>
<img
title={convertTagToName(item.tag)}
className={styles.image}
src={api.getItemImageUrl(item)}
alt=""
crossOrigin="anonymous"
height={24}
/>
{getMinecraftColorCodedElement(`${item.itemName}`)}
</p>
{getMinecraftColorCodedElement(item.description, false)}
</div>
}
/>
<div style={{ position: 'relative', height: '100%' }}>
<Tooltip
type="hover"
className={styles.hoverElement}
hoverPlacement="bottom"
id={styles.tooltipHoverId}
content={
<img
title={removeMinecraftColorCoding(item.itemName)}
className={styles.image}
src={api.getItemImageUrl({ tag: item.tag })}
alt=""
crossOrigin="anonymous"
height={48}
style={isTradeable ? { cursor: 'pointer', position: 'absolute', top: 0, left: 0 } : {}}
onClick={() => {
if (!isTradeable) {
return
}
if (props.onItemClick) {
props.onItemClick(item)
}
}}
/>
}
tooltipContent={
<div style={{ maxWidth: '100%' }}>
{isSouldbound ? <p>{getMinecraftColorCodedElement(`§4§lNot tradeable - Item is Soulbound`)}</p> : null}
<p>
<img
title={convertTagToName(item.tag)}
className={styles.image}
src={api.getItemImageUrl(item)}
alt=""
crossOrigin="anonymous"
height={24}
/>
{getMinecraftColorCodedElement(`${item.itemName}`)}
</p>
{getMinecraftColorCodedElement(item.description, false)}
</div>
}
/>
{item.count !== 1 ? (
<span style={{ position: 'absolute', fontWeight: 'bold', bottom: 0, right: 0, fontSize: '24px' }}>{item.count}</span>
) : null}
</div>
</div>
)
}
Expand Down
2 changes: 1 addition & 1 deletion components/TradeCreate/TradeCreate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export default function TradeCreate(props: Props) {
crossOrigin="anonymous"
height={24}
/>
{getMinecraftColorCodedElement(`${offer.itemName}`)}
{offer.count !== 1 ? `${offer.count}x` : null} {getMinecraftColorCodedElement(`${offer.itemName}`)}
</Card.Title>
</Card.Header>
<Card.Body>{getMinecraftColorCodedElement(offer.description, false)}</Card.Body>
Expand Down
1 change: 1 addition & 0 deletions components/TradeList/TradeList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ export default function TradeList(props: Props) {
crossOrigin="anonymous"
height={24}
/>
{trade.item.count !== 1 ? `${trade.item.count}x` : null}{' '}
{getMinecraftColorCodedElement(`${trade.item.itemName}`)}
</Card.Title>
</Card.Header>
Expand Down

0 comments on commit 8c8639a

Please sign in to comment.