@rpg-engine/long-bow 0.8.165 → 0.8.167
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/long-bow.cjs.development.js +5 -7
- package/dist/long-bow.cjs.development.js.map +1 -1
- package/dist/long-bow.cjs.production.min.js +1 -1
- package/dist/long-bow.cjs.production.min.js.map +1 -1
- package/dist/long-bow.esm.js +5 -7
- package/dist/long-bow.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Marketplace/BuyPanel.tsx +4 -8
- package/src/stories/Features/trading/Marketplace.stories.tsx +34 -26
package/package.json
CHANGED
|
@@ -90,6 +90,7 @@ export const BuyPanel: React.FC<IBuyPanelProps> = ({
|
|
|
90
90
|
dcBalance = 0,
|
|
91
91
|
dcToGoldSwapRate = 0,
|
|
92
92
|
openBuyOrders = [],
|
|
93
|
+
openBuyOrdersTotal = 0,
|
|
93
94
|
openBuyOrdersPage = 1,
|
|
94
95
|
onOpenBuyOrdersPageChange,
|
|
95
96
|
isLoading = false,
|
|
@@ -190,11 +191,6 @@ export const BuyPanel: React.FC<IBuyPanelProps> = ({
|
|
|
190
191
|
});
|
|
191
192
|
}, [visibleBuyOrders]);
|
|
192
193
|
|
|
193
|
-
const paginatedGroupedBuyOrders = useMemo(() => {
|
|
194
|
-
const start = (openBuyOrdersPage - 1) * BUY_REQUESTS_PER_PAGE;
|
|
195
|
-
return groupedBuyOrders.slice(start, start + BUY_REQUESTS_PER_PAGE);
|
|
196
|
-
}, [groupedBuyOrders, openBuyOrdersPage]);
|
|
197
|
-
|
|
198
194
|
const showSellSection = browseMode === 'sell';
|
|
199
195
|
const showBuySection = browseMode === 'buy';
|
|
200
196
|
const hasVisibleContent =
|
|
@@ -451,7 +447,7 @@ export const BuyPanel: React.FC<IBuyPanelProps> = ({
|
|
|
451
447
|
{groupedBuyOrders.length === 0 ? (
|
|
452
448
|
<SectionEmpty>No public buy requests found.</SectionEmpty>
|
|
453
449
|
) : (
|
|
454
|
-
|
|
450
|
+
groupedBuyOrders.map(({ bestOrder, otherOrders }) => (
|
|
455
451
|
<GroupedBuyOrderRow
|
|
456
452
|
key={bestOrder._id}
|
|
457
453
|
bestOrder={bestOrder}
|
|
@@ -477,9 +473,9 @@ export const BuyPanel: React.FC<IBuyPanelProps> = ({
|
|
|
477
473
|
onPageChange={onPageChange}
|
|
478
474
|
/>
|
|
479
475
|
)}
|
|
480
|
-
{showBuySection &&
|
|
476
|
+
{showBuySection && openBuyOrdersTotal > BUY_REQUESTS_PER_PAGE && (
|
|
481
477
|
<Pager
|
|
482
|
-
totalItems={
|
|
478
|
+
totalItems={openBuyOrdersTotal}
|
|
483
479
|
currentPage={openBuyOrdersPage}
|
|
484
480
|
itemsPerPage={BUY_REQUESTS_PER_PAGE}
|
|
485
481
|
onPageChange={onOpenBuyOrdersPageChange ?? (() => {})}
|
|
@@ -42,29 +42,31 @@ const mockYourBuyOrders: IMarketplaceBuyOrderItem[] = [
|
|
|
42
42
|
{ _id: 'bo-3', owner: 'player-1', itemBlueprintKey: 'items/leather-armor', maxPrice: 300, escrowedGold: 0, fee: 15, status: MarketplaceBuyOrderStatus.Expired, createdAt: daysAgo(35), updatedAt: daysAgo(7) },
|
|
43
43
|
];
|
|
44
44
|
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
// Broad Sword — 3 requests (grouped)
|
|
54
|
-
{ _id: 'obo-4a', owner: 'player-5', itemBlueprintKey: 'items/broad-sword', maxPrice: 350, escrowedGold: 350, fee: 17, status: MarketplaceBuyOrderStatus.Active, createdAt: daysAgo(3), updatedAt: daysAgo(3) },
|
|
55
|
-
{ _id: 'obo-4b', owner: 'player-11', itemBlueprintKey: 'items/broad-sword', itemRarity: 'Rare', maxPrice: 480, escrowedGold: 480, fee: 24, status: MarketplaceBuyOrderStatus.Active, createdAt: daysAgo(1), updatedAt: daysAgo(1) },
|
|
56
|
-
{ _id: 'obo-4c', owner: 'player-12', itemBlueprintKey: 'items/broad-sword', maxPrice: 270, escrowedGold: 270, fee: 13, status: MarketplaceBuyOrderStatus.Active, createdAt: daysAgo(6), updatedAt: daysAgo(6) },
|
|
57
|
-
// Barbarian Helmet — single request
|
|
58
|
-
{ _id: 'obo-5', owner: 'player-6', itemBlueprintKey: 'items/barbarian-helmet', itemRarity: 'Uncommon', maxPrice: 600, escrowedGold: 600, fee: 30, status: MarketplaceBuyOrderStatus.Active, createdAt: daysAgo(1), updatedAt: daysAgo(1) },
|
|
59
|
-
// Leather Armor — 2 requests (grouped)
|
|
60
|
-
{ _id: 'obo-6a', owner: 'player-7', itemBlueprintKey: 'items/leather-armor', maxPrice: 420, escrowedGold: 420, fee: 21, status: MarketplaceBuyOrderStatus.Active, createdAt: daysAgo(4), updatedAt: daysAgo(4) },
|
|
61
|
-
{ _id: 'obo-6b', owner: 'player-13', itemBlueprintKey: 'items/leather-armor', itemRarity: 'Uncommon', maxPrice: 380, escrowedGold: 380, fee: 19, status: MarketplaceBuyOrderStatus.Active, createdAt: daysAgo(2), updatedAt: daysAgo(2) },
|
|
62
|
-
// Angelic Sword — 2 requests (grouped)
|
|
63
|
-
{ _id: 'obo-7a', owner: 'player-8', itemBlueprintKey: 'items/angelic-sword', itemRarity: 'Legendary', maxPrice: 5000, escrowedGold: 5000, fee: 250, status: MarketplaceBuyOrderStatus.Active, createdAt: daysAgo(6), updatedAt: daysAgo(6) },
|
|
64
|
-
{ _id: 'obo-7b', owner: 'player-14', itemBlueprintKey: 'items/angelic-sword', itemRarity: 'Epic', maxPrice: 3500, escrowedGold: 3500, fee: 175, status: MarketplaceBuyOrderStatus.Active, createdAt: daysAgo(3), updatedAt: daysAgo(3) },
|
|
65
|
-
// Greater Life Potion — single request
|
|
66
|
-
{ _id: 'obo-8', owner: 'player-9', itemBlueprintKey: 'items/greater-life-potion', maxPrice: 90, stackQty: 10, escrowedGold: 900, fee: 45, status: MarketplaceBuyOrderStatus.Active, createdAt: daysAgo(2), updatedAt: daysAgo(2) },
|
|
45
|
+
const ITEM_KEYS = [
|
|
46
|
+
'items/broad-sword', 'items/angelic-sword', 'items/leather-armor',
|
|
47
|
+
'items/abyssal-tide-staff', 'items/wooden-shield', 'items/fire-wand',
|
|
48
|
+
'items/barbarian-helmet', 'items/greater-life-potion', 'items/iron-axe',
|
|
49
|
+
'items/shadow-cloak', 'items/mystic-staff', 'items/steel-boots',
|
|
50
|
+
'items/dragon-scale', 'items/emerald-ring', 'items/frost-bow',
|
|
51
|
+
'items/phoenix-feather', 'items/void-dagger', 'items/crystal-wand',
|
|
52
|
+
'items/titan-gauntlets', 'items/silver-arrow',
|
|
67
53
|
];
|
|
54
|
+
const RARITIES = ['Common', 'Uncommon', 'Rare', 'Epic', 'Legendary'] as const;
|
|
55
|
+
|
|
56
|
+
const allMockOpenBuyOrders: IMarketplaceBuyOrderItem[] = Array.from({ length: 100 }, (_, i) => ({
|
|
57
|
+
_id: `obo-${i + 1}`,
|
|
58
|
+
owner: `player-${(i % 20) + 2}`,
|
|
59
|
+
itemBlueprintKey: ITEM_KEYS[i % ITEM_KEYS.length],
|
|
60
|
+
itemRarity: RARITIES[i % RARITIES.length] as any,
|
|
61
|
+
maxPrice: Math.round((100 + i * 47) / 10) * 10,
|
|
62
|
+
escrowedGold: Math.round((100 + i * 47) / 10) * 10,
|
|
63
|
+
fee: Math.round((100 + i * 47) / 10) * 10 * 0.05,
|
|
64
|
+
status: MarketplaceBuyOrderStatus.Active,
|
|
65
|
+
createdAt: daysAgo(i % 30),
|
|
66
|
+
updatedAt: daysAgo(i % 30),
|
|
67
|
+
}));
|
|
68
|
+
|
|
69
|
+
const OPEN_BUY_ORDERS_PER_PAGE = 5;
|
|
68
70
|
|
|
69
71
|
const mockTransactions: IMarketplaceTransaction[] = [
|
|
70
72
|
{ owner: 'player-1', type: MarketplaceTransactionType.Purchase, goldAmount: 450, itemKey: 'items/broad-sword', itemName: 'Broad Sword', counterpartName: 'MerchantKing', metadata: { currency: 'gold' }, createdAt: daysAgo(1), updatedAt: daysAgo(1) },
|
|
@@ -80,6 +82,7 @@ const mockTransactions: IMarketplaceTransaction[] = [
|
|
|
80
82
|
|
|
81
83
|
const Template: Story = () => {
|
|
82
84
|
const [page, setPage] = React.useState(1);
|
|
85
|
+
const [openBuyOrdersPage, setOpenBuyOrdersPage] = React.useState(1);
|
|
83
86
|
const [selectedBlueprint, setSelectedBlueprint] = React.useState<IMarketplaceBlueprintSummary | undefined>();
|
|
84
87
|
const [quantity, setQuantity] = React.useState(1);
|
|
85
88
|
const [maxPrice, setMaxPrice] = React.useState(0);
|
|
@@ -89,6 +92,11 @@ const Template: Story = () => {
|
|
|
89
92
|
const [historyType, setHistoryType] = React.useState('All');
|
|
90
93
|
const [yourBuyOrders, setYourBuyOrders] = React.useState<IMarketplaceBuyOrderItem[]>(mockYourBuyOrders);
|
|
91
94
|
|
|
95
|
+
const pagedOpenBuyOrders = allMockOpenBuyOrders.slice(
|
|
96
|
+
(openBuyOrdersPage - 1) * OPEN_BUY_ORDERS_PER_PAGE,
|
|
97
|
+
openBuyOrdersPage * OPEN_BUY_ORDERS_PER_PAGE,
|
|
98
|
+
);
|
|
99
|
+
|
|
92
100
|
const handleBlueprintSearch = (request: any) => {
|
|
93
101
|
console.log('blueprint search:', request);
|
|
94
102
|
setBlueprintLoading(true);
|
|
@@ -181,10 +189,10 @@ const Template: Story = () => {
|
|
|
181
189
|
yourBuyOrdersPage={1}
|
|
182
190
|
onYourBuyOrdersPageChange={p => console.log('your orders page:', p)}
|
|
183
191
|
onCancelBuyOrder={id => setYourBuyOrders(prev => prev.filter(o => o._id !== id))}
|
|
184
|
-
openBuyOrders={
|
|
185
|
-
openBuyOrdersTotal={
|
|
186
|
-
openBuyOrdersPage={
|
|
187
|
-
onOpenBuyOrdersPageChange={
|
|
192
|
+
openBuyOrders={pagedOpenBuyOrders}
|
|
193
|
+
openBuyOrdersTotal={allMockOpenBuyOrders.length}
|
|
194
|
+
openBuyOrdersPage={openBuyOrdersPage}
|
|
195
|
+
onOpenBuyOrdersPageChange={setOpenBuyOrdersPage}
|
|
188
196
|
// Blueprint Search props
|
|
189
197
|
onBlueprintSearch={handleBlueprintSearch}
|
|
190
198
|
onBlueprintSelect={setSelectedBlueprint}
|