refactor(market): pass currency config through negotiation panel
Renders negotiation amounts from the full CurrencyConfig, matching the other market components. Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
parent
e3c4eada09
commit
bcd6d97ff4
1 changed files with 8 additions and 10 deletions
|
|
@ -6,7 +6,7 @@ import type { Asset, MarketListing, MarketNegotiation } from "@/payload-types";
|
|||
import { Badge } from "@/components/ui/badge";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { formatAmount } from "@/lib/banking/format";
|
||||
import { formatAmount, type CurrencyConfig } from "@/lib/banking/format";
|
||||
import {
|
||||
acceptMarketOffer,
|
||||
cancelMarketOffer,
|
||||
|
|
@ -70,11 +70,11 @@ function counterpartyLabel(negotiation: MarketNegotiation, role: "buyer" | "sell
|
|||
function NegotiationRow({
|
||||
negotiation,
|
||||
role,
|
||||
currencyLabel,
|
||||
currencyConfig,
|
||||
}: {
|
||||
negotiation: MarketNegotiation;
|
||||
role: "buyer" | "seller";
|
||||
currencyLabel: string | null;
|
||||
currencyConfig: CurrencyConfig;
|
||||
}) {
|
||||
const router = useRouter();
|
||||
const [busy, setBusy] = useState<string | null>(null);
|
||||
|
|
@ -87,7 +87,7 @@ function NegotiationRow({
|
|||
const theirProposal =
|
||||
(role === "buyer" && negotiation.proposedBy === "seller") ||
|
||||
(role === "seller" && negotiation.proposedBy === "buyer");
|
||||
const fmt = (n: number) => formatAmount(n, { name: currencyLabel ?? undefined });
|
||||
const fmt = (n: number) => formatAmount(n, currencyConfig);
|
||||
|
||||
async function run(action: () => Promise<{ success: boolean; error?: string }>, key: string) {
|
||||
setBusy(key);
|
||||
|
|
@ -116,8 +116,6 @@ function NegotiationRow({
|
|||
void run(() => counterMarketOffer(negotiation.id, value), "counter");
|
||||
}
|
||||
|
||||
const showActions = isOpen && theirProposal;
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-2 rounded-md border p-3">
|
||||
<div className="flex items-center justify-between gap-2">
|
||||
|
|
@ -221,13 +219,13 @@ function NegotiationRow({
|
|||
interface NegotiationPanelProps {
|
||||
negotiations: MarketNegotiation[];
|
||||
currentUserId: number;
|
||||
currencyLabel: string | null;
|
||||
currencyConfig: CurrencyConfig;
|
||||
}
|
||||
|
||||
export function NegotiationPanel({
|
||||
negotiations,
|
||||
currentUserId,
|
||||
currencyLabel,
|
||||
currencyConfig,
|
||||
}: NegotiationPanelProps) {
|
||||
const open = negotiations.filter((n) => n.status === "open");
|
||||
const closed = negotiations.filter((n) => n.status !== "open");
|
||||
|
|
@ -250,7 +248,7 @@ export function NegotiationPanel({
|
|||
<NegotiationHistoryDialog
|
||||
negotiations={negotiations}
|
||||
currentUserId={currentUserId}
|
||||
currencyLabel={currencyLabel}
|
||||
currencyConfig={currencyConfig}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -269,7 +267,7 @@ export function NegotiationPanel({
|
|||
key={negotiation.id}
|
||||
negotiation={negotiation}
|
||||
role={role}
|
||||
currencyLabel={currencyLabel}
|
||||
currencyConfig={currencyConfig}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
|
|
|
|||
Loading…
Reference in a new issue