From 89fc4a782c5d916c3196104cdfd02942fe1eba6f Mon Sep 17 00:00:00 2001 From: Matthieu Date: Wed, 26 Nov 2025 19:12:07 +0100 Subject: [PATCH] update trade system --- .claude/settings.local.json | 16 ++++--- dev-dist/sw.js | 2 +- src/components/Community.tsx | 18 +++---- src/components/TradeCreator.tsx | 16 +++---- src/components/TradeDetail.tsx | 61 ++++++++++++------------ src/lib/Entities.ts | 33 +++++++++---- src/services/tradesService.ts | 84 ++++++++++++++++++--------------- 7 files changed, 128 insertions(+), 102 deletions(-) diff --git a/.claude/settings.local.json b/.claude/settings.local.json index dff52c0..053c3dc 100644 --- a/.claude/settings.local.json +++ b/.claude/settings.local.json @@ -1,11 +1,15 @@ { + "permissions": { + "allow": [ + "mcp__supabase__apply_migration", + "mcp__supabase__list_tables", + "mcp__supabase__execute_sql", + "Bash(npm run build:*)", + "mcp__supabase__get_advisors" + ] + }, "enableAllProjectMcpServers": true, "enabledMcpjsonServers": [ "supabase" - ], - "permissions": { - "allow": [ - "mcp__supabase__apply_migration" - ] - } + ] } diff --git a/dev-dist/sw.js b/dev-dist/sw.js index bb5975d..da47ea6 100644 --- a/dev-dist/sw.js +++ b/dev-dist/sw.js @@ -82,7 +82,7 @@ define(['./workbox-ca84f546'], (function (workbox) { 'use strict'; "revision": "3ca0b8505b4bec776b69afdba2768812" }, { "url": "index.html", - "revision": "0.ufhads5pjvs" + "revision": "0.tucc18p1f38" }], {}); workbox.cleanupOutdatedCaches(); workbox.registerRoute(new workbox.NavigationRoute(workbox.createHandlerBoundToURL("index.html"), { diff --git a/src/components/Community.tsx b/src/components/Community.tsx index 9155986..4a954a0 100644 --- a/src/components/Community.tsx +++ b/src/components/Community.tsx @@ -794,8 +794,10 @@ export default function Community() { ) : (
{(tradesSubTab === 'pending' ? pendingTrades : tradeHistory).map((trade) => { - const isSender = trade.sender_id === user?.id; - const otherUser = isSender ? trade.receiver : trade.sender; + const isUser1 = trade.user1_id === user?.id; + const myUserId = user?.id || ''; + const otherUserId = isUser1 ? trade.user2_id : trade.user1_id; + const otherUser = isUser1 ? trade.user2 : trade.user1; const statusColors: Record = { accepted: 'text-green-400', declined: 'text-red-400', @@ -819,7 +821,7 @@ export default function Community() {
- {isSender ? 'To' : 'From'}: {otherUser?.username} + With: {otherUser?.username}
@@ -829,18 +831,18 @@ export default function Community() { {/* Items */}
- {renderTradeItems(trade.items, trade.sender_id, isSender ? 'Give' : 'Receive')} - {renderTradeItems(trade.items, trade.receiver_id, isSender ? 'Get' : 'Send')} + {renderTradeItems(trade.items, myUserId, 'You Give')} + {renderTradeItems(trade.items, otherUserId, 'You Get')}
{canViewDetails && (

- {isSender ? 'Tap to view/edit' : 'Tap to view details'} + Tap to view details

)} - {/* Actions - Only show quick actions for sender (cancel) */} - {tradesSubTab === 'pending' && isSender && ( + {/* Actions - Allow any user to cancel pending trade */} + {tradesSubTab === 'pending' && (
e.stopPropagation()}>
@@ -246,7 +245,7 @@ export default function TradeDetail({

- {isSender ? 'You Give' : 'You Receive'} + You Give

@@ -285,7 +284,7 @@ export default function TradeDetail({

- {isSender ? 'You Receive' : 'They Give'} + You Receive

@@ -330,13 +329,13 @@ export default function TradeDetail({ )} {/* Price Difference */} - {!loading && (senderPrice > 0 || receiverPrice > 0) && ( + {!loading && (yourPrice > 0 || theirPrice > 0) && (
Value Difference: - 5 ? 'text-yellow-400' : 'text-gray-300'}> - ${Math.abs(senderPrice - receiverPrice).toFixed(2)} - {senderPrice > receiverPrice ? ' in sender favor' : senderPrice < receiverPrice ? ' in receiver favor' : ' (balanced)'} + 5 ? 'text-yellow-400' : 'text-gray-300'}> + ${Math.abs(yourPrice - theirPrice).toFixed(2)} + {yourPrice > theirPrice ? ' in your favor' : yourPrice < theirPrice ? ' in their favor' : ' (balanced)'}
@@ -422,9 +421,10 @@ export default function TradeDetail({ Waiting for {otherUser?.username} to respond...

) : ( - /* No editor yet (version 1) - original flow */ + /* No editor yet (initial trade) */ <> - {isSender ? ( + {isUser1 ? ( + /* User1 (initiator) can edit their initial offer */