1
0
Fork 0

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:
Jason Fraley 2026-09-06 01:24:21 -04:00
parent e3c4eada09
commit bcd6d97ff4

View file

@ -6,7 +6,7 @@ import type { Asset, MarketListing, MarketNegotiation } from "@/payload-types";
import { Badge } from "@/components/ui/badge"; import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button"; import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input"; import { Input } from "@/components/ui/input";
import { formatAmount } from "@/lib/banking/format"; import { formatAmount, type CurrencyConfig } from "@/lib/banking/format";
import { import {
acceptMarketOffer, acceptMarketOffer,
cancelMarketOffer, cancelMarketOffer,
@ -70,11 +70,11 @@ function counterpartyLabel(negotiation: MarketNegotiation, role: "buyer" | "sell
function NegotiationRow({ function NegotiationRow({
negotiation, negotiation,
role, role,
currencyLabel, currencyConfig,
}: { }: {
negotiation: MarketNegotiation; negotiation: MarketNegotiation;
role: "buyer" | "seller"; role: "buyer" | "seller";
currencyLabel: string | null; currencyConfig: CurrencyConfig;
}) { }) {
const router = useRouter(); const router = useRouter();
const [busy, setBusy] = useState<string | null>(null); const [busy, setBusy] = useState<string | null>(null);
@ -87,7 +87,7 @@ function NegotiationRow({
const theirProposal = const theirProposal =
(role === "buyer" && negotiation.proposedBy === "seller") || (role === "buyer" && negotiation.proposedBy === "seller") ||
(role === "seller" && negotiation.proposedBy === "buyer"); (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) { async function run(action: () => Promise<{ success: boolean; error?: string }>, key: string) {
setBusy(key); setBusy(key);
@ -116,8 +116,6 @@ function NegotiationRow({
void run(() => counterMarketOffer(negotiation.id, value), "counter"); void run(() => counterMarketOffer(negotiation.id, value), "counter");
} }
const showActions = isOpen && theirProposal;
return ( return (
<div className="flex flex-col gap-2 rounded-md border p-3"> <div className="flex flex-col gap-2 rounded-md border p-3">
<div className="flex items-center justify-between gap-2"> <div className="flex items-center justify-between gap-2">
@ -221,13 +219,13 @@ function NegotiationRow({
interface NegotiationPanelProps { interface NegotiationPanelProps {
negotiations: MarketNegotiation[]; negotiations: MarketNegotiation[];
currentUserId: number; currentUserId: number;
currencyLabel: string | null; currencyConfig: CurrencyConfig;
} }
export function NegotiationPanel({ export function NegotiationPanel({
negotiations, negotiations,
currentUserId, currentUserId,
currencyLabel, currencyConfig,
}: NegotiationPanelProps) { }: NegotiationPanelProps) {
const open = negotiations.filter((n) => n.status === "open"); const open = negotiations.filter((n) => n.status === "open");
const closed = negotiations.filter((n) => n.status !== "open"); const closed = negotiations.filter((n) => n.status !== "open");
@ -250,7 +248,7 @@ export function NegotiationPanel({
<NegotiationHistoryDialog <NegotiationHistoryDialog
negotiations={negotiations} negotiations={negotiations}
currentUserId={currentUserId} currentUserId={currentUserId}
currencyLabel={currencyLabel} currencyConfig={currencyConfig}
/> />
</div> </div>
</div> </div>
@ -269,7 +267,7 @@ export function NegotiationPanel({
key={negotiation.id} key={negotiation.id}
negotiation={negotiation} negotiation={negotiation}
role={role} role={role}
currencyLabel={currencyLabel} currencyConfig={currencyConfig}
/> />
); );
})} })}