Skip to content
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

[client] show all my trades in history #2046

Merged
merged 1 commit into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion client/src/ui/components/trading/MarketTradingHistory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ export const MarketTradingHistory = () => {
const takerOwner = getComponentValue(components.Owner, getEntityIdFromKeys([BigInt(event.taker_id)]));
if (!takerOwner) return;

const makerOwner = getComponentValue(components.Owner, getEntityIdFromKeys([BigInt(event.maker_id)]));
if (!makerOwner) return;

const { makerGets, takerGets } = getTradeResources(trade.trade_id);

setTradeEvents((prevTradeEvents) => {
Expand All @@ -58,7 +61,7 @@ export const MarketTradingHistory = () => {
event: {
takerId: event.taker_id,
makerId: event.maker_id,
isYours: takerOwner.address === BigInt(address),
isYours: takerOwner.address === BigInt(address) || makerOwner.address === BigInt(address),
resourceGiven: makerGets[0],
resourceTaken: takerGets[0],
eventTime: new Date(event.timestamp * 1000),
Expand Down
6 changes: 1 addition & 5 deletions client/src/ui/components/trading/TradeHistoryEvent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { useEntitiesUtils } from "@/hooks/helpers/useEntities";
import { ResourceIcon } from "@/ui/elements/ResourceIcon";
import { currencyIntlFormat, divideByPrecision } from "@/ui/utils/utils";
import { Resource, ResourcesIds } from "@bibliothecadao/eternum";
import { Crown } from "lucide-react";
import { TradeEvent } from "./MarketTradingHistory";

export enum EventType {
Expand Down Expand Up @@ -35,10 +34,7 @@ export const TradeHistoryEvent = ({ trade }: { trade: TradeEvent }) => {
className={`text-xs my-auto`}
>{`${trade.event.eventTime.toLocaleDateString()} ${trade.event.eventTime.toLocaleTimeString()}`}</div>
<div className={`text-sm my-auto`}>{trade.type}</div>
<div className={`text-sm my-auto flex flex-row items-center justify-start`}>
{taker}
{trade.event.isYours && <Crown className="h-4" />}
</div>
<div className={`text-sm my-auto flex flex-row items-center justify-start`}>{taker}</div>
<div className="text-sm my-auto flex flex-row">
<div>{"bought"}</div>
<ResourceIcon resource={ResourcesIds[Number(trade.event.resourceTaken.resourceId)]} size={"sm"} />
Expand Down
Loading