diff --git a/src/app/(frontend)/logistics/market/page.tsx b/src/app/(frontend)/logistics/market/page.tsx index 6c8a161..9b0c430 100644 --- a/src/app/(frontend)/logistics/market/page.tsx +++ b/src/app/(frontend)/logistics/market/page.tsx @@ -6,7 +6,7 @@ import { StoreIcon } from "lucide-react"; import { MarketView } from "@/components/frontend/market/MarketView"; import { hasPermission } from "@/utils/access-control/hasPermission"; import { ensureLockerStorage } from "@/lib/locker"; -import { getMainCurrencyName } from "@/lib/banking"; +import { getCurrencyConfig } from "@/lib/banking"; export const metadata = { title: "Market — Polaris Task Force", @@ -76,8 +76,8 @@ export default async function MarketPage() { return false; }); - const isManager = user ? (await hasPermission(payload, user, "logistics:manage")) : false; - const currencyLabel = await getMainCurrencyName(payload); + const isManager = user ? await hasPermission(payload, user, "logistics:manage") : false; + const currencyConfig = await getCurrencyConfig(payload); return (
@@ -97,7 +97,7 @@ export default async function MarketPage() { negotiations={negotiations} locker={lockerFull} currentUserId={userId} - currencyLabel={currencyLabel} + currencyConfig={currencyConfig} isManager={isManager} />
diff --git a/src/components/frontend/market/CreateListingDialog.tsx b/src/components/frontend/market/CreateListingDialog.tsx index 3d8b095..03d8528 100644 --- a/src/components/frontend/market/CreateListingDialog.tsx +++ b/src/components/frontend/market/CreateListingDialog.tsx @@ -30,7 +30,7 @@ import { createMarketListing } from "@/app/(frontend)/logistics/market/actions"; interface CreateListingDialogProps { locker: LockerStorage | null; - currencyLabel: string | null; + currencyLabel: string; open?: boolean; onOpenChange?: (open: boolean) => void; } @@ -225,7 +225,7 @@ export function CreateListingDialog({ />
- + {negotiable && (
- +
- {formatAmount(listing.price ?? 0, { name: currencyLabel ?? undefined })} / unit + {formatAmount(listing.price ?? 0, currencyConfig)} / unit {stock > 1 && ( @@ -149,7 +149,7 @@ export function ListingCard({ {selectedQty}/{stock} ·{" "} )} - total {formatAmount(selectedTotal, { name: currencyLabel ?? undefined })} + total {formatAmount(selectedTotal, currencyConfig)}
{error &&

{error}

} @@ -188,7 +188,7 @@ export function ListingCard({ )}
diff --git a/src/components/frontend/market/MakeOfferDialog.tsx b/src/components/frontend/market/MakeOfferDialog.tsx index f7f804c..797ed10 100644 --- a/src/components/frontend/market/MakeOfferDialog.tsx +++ b/src/components/frontend/market/MakeOfferDialog.tsx @@ -16,7 +16,7 @@ import { DialogTitle, DialogTrigger, } from "@/components/ui/dialog"; -import { formatAmount } from "@/lib/banking/format"; +import { currencyLabel, formatAmount, type CurrencyConfig } from "@/lib/banking/format"; import { acceptMarketOffer, cancelMarketOffer, @@ -55,10 +55,10 @@ function outcomeOf(negotiation: MarketNegotiation | null): OfferOutcome | null { interface MakeOfferDialogProps { listing: MarketListing; currentUserId: number; - currencyLabel: string | null; + currencyConfig: CurrencyConfig; } -export function MakeOfferDialog({ listing, currentUserId, currencyLabel }: MakeOfferDialogProps) { +export function MakeOfferDialog({ listing, currentUserId, currencyConfig }: MakeOfferDialogProps) { const router = useRouter(); const [open, setOpen] = useState(false); const [amount, setAmount] = useState(""); @@ -76,7 +76,8 @@ export function MakeOfferDialog({ listing, currentUserId, currencyLabel }: MakeO const isVendor = listing.isAutoGenerated; const stock = listing.quantity ?? 1; const outcome = outcomeOf(negotiation); - const fmt = (n: number) => formatAmount(n, { name: currencyLabel ?? undefined }); + const displayCurrency = currencyLabel(currencyConfig); + const fmt = (n: number) => formatAmount(n, currencyConfig); const clampedQty = Math.max(1, Math.min(stock, qty)); const sinceAccept = acceptedAt != null ? nowTick - acceptedAt : 0; @@ -244,7 +245,7 @@ export function MakeOfferDialog({ listing, currentUserId, currencyLabel }: MakeO
{isVendor && ( - + )} {loadingThread && !outcome && ( @@ -254,7 +255,7 @@ export function MakeOfferDialog({ listing, currentUserId, currencyLabel }: MakeO {!outcome && !loadingThread && ( <>
- +
- + @@ -179,7 +181,7 @@ export function MarketView({ key={listing.id} listing={listing} currentUserId={currentUserId} - currencyLabel={currencyLabel} + currencyConfig={currencyConfig} canManage={isManager} /> ))} @@ -190,7 +192,7 @@ export function MarketView({ {myListings.length > 0 && ( @@ -207,7 +209,7 @@ export function MarketView({ key={listing.id} listing={listing} currentUserId={currentUserId} - currencyLabel={currencyLabel} + currencyConfig={currencyConfig} canManage={isManager} /> ))} diff --git a/src/components/frontend/market/NegotiationHistoryDialog.tsx b/src/components/frontend/market/NegotiationHistoryDialog.tsx index fc783ca..9abd337 100644 --- a/src/components/frontend/market/NegotiationHistoryDialog.tsx +++ b/src/components/frontend/market/NegotiationHistoryDialog.tsx @@ -14,7 +14,7 @@ import { DialogTrigger, } from "@/components/ui/dialog"; import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "@/components/ui/collapsible"; -import { formatAmount } from "@/lib/banking/format"; +import { currencyLabel, formatAmount, type CurrencyConfig } from "@/lib/banking/format"; import { buildChatBubbles } from "@/lib/market/chatBubbles"; import { ChatBubbleList } from "@/components/frontend/market/ChatBubbleList"; import { ChevronDownIcon, HistoryIcon } from "lucide-react"; @@ -71,15 +71,15 @@ function counterpartyLabel(negotiation: MarketNegotiation, role: "buyer" | "sell function HistoryRow({ negotiation, role, - currencyLabel, + currencyConfig, }: { negotiation: MarketNegotiation; role: "buyer" | "seller"; - currencyLabel: string | null; + currencyConfig: CurrencyConfig; }) { const [expanded, setExpanded] = useState(false); const listing = listingOf(negotiation); - const fmt = (n: number) => formatAmount(n, { name: currencyLabel ?? undefined }); + const fmt = (n: number) => formatAmount(n, currencyConfig); const buyerLabel = role === "buyer" ? "You" : counterpartyLabel(negotiation, "buyer"); const sellerLabel = role === "seller" ? "You" : counterpartyLabel(negotiation, "seller"); @@ -112,7 +112,7 @@ function HistoryRow({ {listing && ( ); }) diff --git a/src/lib/market/npcDialogue.ts b/src/lib/market/npcDialogue.ts index 38f5fee..32fca40 100644 --- a/src/lib/market/npcDialogue.ts +++ b/src/lib/market/npcDialogue.ts @@ -1,13 +1,5 @@ export type NpcDialogueKind = - | "firm" - | "lowball" - | "backward" - | "stall" - | "concede" - | "good" - | "overpay" - | "closed" - | "accept"; + "firm" | "lowball" | "backward" | "stall" | "concede" | "good" | "overpay" | "closed" | "accept"; type DialogueLine = (amount: string, asking: string) => string; @@ -18,8 +10,8 @@ const LINES: Record = { (amount) => `I'm holding at ${amount}. My prices are already fair.`, ], lowball: [ - (amount) => `That's an insult! I'll come down to ${amount} — not a unit less.`, - (amount) => `You're joking, right? ${amount} and not a unit less.`, + (amount) => `That's an insult! I'll come down to ${amount} — not a fraction less.`, + (amount) => `You're joking, right? ${amount} and not a fraction less.`, (amount) => `I paid more than that for lunch! ${amount} — final offer.`, ], backward: [ @@ -28,8 +20,8 @@ const LINES: Record = { ], stall: [ () => "Really? That's hardly different. Negotiate like you mean it.", - () => "A whole dollar more? That's not negotiating, that's teasing. Come back with a real number.", - () => "You're just wearing me down with pennies now. Bring something meaningful.", + () => "That tiny increase isn't negotiating. Come back with a real number.", + () => "You're just inching up now. Bring something meaningful.", ], concede: [ (amount) => `Hmm, not sure about that... how about ${amount}?`,