@medialane/ui 0.201.10 → 0.203.0
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/components/activity-card.cjs +6 -5
- package/dist/components/activity-card.cjs.map +1 -1
- package/dist/components/activity-card.d.cts +1 -2
- package/dist/components/activity-card.d.ts +1 -2
- package/dist/components/activity-card.js +6 -5
- package/dist/components/activity-card.js.map +1 -1
- package/dist/components/activity-row.cjs +7 -7
- package/dist/components/activity-row.cjs.map +1 -1
- package/dist/components/activity-row.d.cts +1 -3
- package/dist/components/activity-row.d.ts +1 -3
- package/dist/components/activity-row.js +7 -7
- package/dist/components/activity-row.js.map +1 -1
- package/dist/components/activity-ticker.cjs +3 -2
- package/dist/components/activity-ticker.cjs.map +1 -1
- package/dist/components/activity-ticker.js +3 -2
- package/dist/components/activity-ticker.js.map +1 -1
- package/dist/components/activity-timeline-row.cjs +3 -3
- package/dist/components/activity-timeline-row.cjs.map +1 -1
- package/dist/components/activity-timeline-row.d.cts +1 -2
- package/dist/components/activity-timeline-row.d.ts +1 -2
- package/dist/components/activity-timeline-row.js +3 -3
- package/dist/components/activity-timeline-row.js.map +1 -1
- package/dist/components/asset-access-cards.d.cts +1 -0
- package/dist/components/asset-access-cards.d.ts +1 -0
- package/dist/components/asset-card.cjs +3 -2
- package/dist/components/asset-card.cjs.map +1 -1
- package/dist/components/asset-card.js +3 -2
- package/dist/components/asset-card.js.map +1 -1
- package/dist/components/asset-marketplace-panel.d.cts +1 -0
- package/dist/components/asset-marketplace-panel.d.ts +1 -0
- package/dist/components/asset-owners-panel.cjs +2 -1
- package/dist/components/asset-owners-panel.cjs.map +1 -1
- package/dist/components/asset-owners-panel.js +2 -1
- package/dist/components/asset-owners-panel.js.map +1 -1
- package/dist/components/asset-page.cjs +7 -5
- package/dist/components/asset-page.cjs.map +1 -1
- package/dist/components/asset-page.js +7 -5
- package/dist/components/asset-page.js.map +1 -1
- package/dist/components/badge.d.cts +1 -1
- package/dist/components/badge.d.ts +1 -1
- package/dist/components/button.d.cts +1 -1
- package/dist/components/button.d.ts +1 -1
- package/dist/components/coin-row.cjs +3 -2
- package/dist/components/coin-row.cjs.map +1 -1
- package/dist/components/coin-row.js +3 -2
- package/dist/components/coin-row.js.map +1 -1
- package/dist/components/collection-card.cjs +3 -2
- package/dist/components/collection-card.cjs.map +1 -1
- package/dist/components/collection-card.js +3 -2
- package/dist/components/collection-card.js.map +1 -1
- package/dist/components/collection-header.cjs +3 -2
- package/dist/components/collection-header.cjs.map +1 -1
- package/dist/components/collection-header.js +3 -2
- package/dist/components/collection-header.js.map +1 -1
- package/dist/components/creation-record.cjs +2 -1
- package/dist/components/creation-record.cjs.map +1 -1
- package/dist/components/creation-record.js +2 -1
- package/dist/components/creation-record.js.map +1 -1
- package/dist/components/creator-chip.cjs +2 -1
- package/dist/components/creator-chip.cjs.map +1 -1
- package/dist/components/creator-chip.js +2 -1
- package/dist/components/creator-chip.js.map +1 -1
- package/dist/components/discover-creators-strip.cjs +3 -2
- package/dist/components/discover-creators-strip.cjs.map +1 -1
- package/dist/components/discover-creators-strip.js +3 -2
- package/dist/components/discover-creators-strip.js.map +1 -1
- package/dist/components/discover-feed-section.cjs +1 -2
- package/dist/components/discover-feed-section.cjs.map +1 -1
- package/dist/components/discover-feed-section.d.cts +1 -3
- package/dist/components/discover-feed-section.d.ts +1 -3
- package/dist/components/discover-feed-section.js +1 -2
- package/dist/components/discover-feed-section.js.map +1 -1
- package/dist/components/drop/drop-card.cjs +3 -2
- package/dist/components/drop/drop-card.cjs.map +1 -1
- package/dist/components/drop/drop-card.js +3 -2
- package/dist/components/drop/drop-card.js.map +1 -1
- package/dist/components/drop/page/drop-page.cjs +4 -3
- package/dist/components/drop/page/drop-page.cjs.map +1 -1
- package/dist/components/drop/page/drop-page.js +4 -3
- package/dist/components/drop/page/drop-page.js.map +1 -1
- package/dist/components/fast-mint/fast-mint.cjs +5 -3
- package/dist/components/fast-mint/fast-mint.cjs.map +1 -1
- package/dist/components/fast-mint/fast-mint.js +5 -3
- package/dist/components/fast-mint/fast-mint.js.map +1 -1
- package/dist/components/featured-carousel.cjs +3 -2
- package/dist/components/featured-carousel.cjs.map +1 -1
- package/dist/components/featured-carousel.js +3 -2
- package/dist/components/featured-carousel.js.map +1 -1
- package/dist/components/hero-slider.cjs +3 -2
- package/dist/components/hero-slider.cjs.map +1 -1
- package/dist/components/hero-slider.js +3 -2
- package/dist/components/hero-slider.js.map +1 -1
- package/dist/components/listing-card.cjs +3 -2
- package/dist/components/listing-card.cjs.map +1 -1
- package/dist/components/listing-card.js +3 -2
- package/dist/components/listing-card.js.map +1 -1
- package/dist/components/make-offer-picker.cjs +3 -2
- package/dist/components/make-offer-picker.cjs.map +1 -1
- package/dist/components/make-offer-picker.js +3 -2
- package/dist/components/make-offer-picker.js.map +1 -1
- package/dist/components/medialane-app.cjs +2 -0
- package/dist/components/medialane-app.cjs.map +1 -1
- package/dist/components/medialane-app.d.cts +6 -1
- package/dist/components/medialane-app.d.ts +6 -1
- package/dist/components/medialane-app.js +1 -0
- package/dist/components/medialane-app.js.map +1 -1
- package/dist/components/nav-command-menu.cjs +141 -16
- package/dist/components/nav-command-menu.cjs.map +1 -1
- package/dist/components/nav-command-menu.d.cts +4 -2
- package/dist/components/nav-command-menu.d.ts +4 -2
- package/dist/components/nav-command-menu.js +141 -17
- package/dist/components/nav-command-menu.js.map +1 -1
- package/dist/components/portfolio-activity.cjs +1 -3
- package/dist/components/portfolio-activity.cjs.map +1 -1
- package/dist/components/portfolio-activity.js +1 -3
- package/dist/components/portfolio-activity.js.map +1 -1
- package/dist/components/portfolio-assets.cjs +117 -0
- package/dist/components/portfolio-assets.cjs.map +1 -0
- package/dist/components/portfolio-assets.d.cts +19 -0
- package/dist/components/portfolio-assets.d.ts +19 -0
- package/dist/components/portfolio-assets.js +93 -0
- package/dist/components/portfolio-assets.js.map +1 -0
- package/dist/components/portfolio-orders.cjs +205 -0
- package/dist/components/portfolio-orders.cjs.map +1 -0
- package/dist/components/portfolio-orders.d.cts +23 -0
- package/dist/components/portfolio-orders.d.ts +23 -0
- package/dist/components/portfolio-orders.js +171 -0
- package/dist/components/portfolio-orders.js.map +1 -0
- package/dist/components/portfolio-shell.cjs +106 -0
- package/dist/components/portfolio-shell.cjs.map +1 -0
- package/dist/components/portfolio-shell.d.cts +18 -0
- package/dist/components/portfolio-shell.d.ts +18 -0
- package/dist/components/portfolio-shell.js +81 -0
- package/dist/components/portfolio-shell.js.map +1 -0
- package/dist/components/result-thumbnail.cjs +60 -0
- package/dist/components/result-thumbnail.cjs.map +1 -0
- package/dist/components/result-thumbnail.d.cts +9 -0
- package/dist/components/result-thumbnail.d.ts +9 -0
- package/dist/components/result-thumbnail.js +26 -0
- package/dist/components/result-thumbnail.js.map +1 -0
- package/dist/components/router.cjs +6 -2
- package/dist/components/router.cjs.map +1 -1
- package/dist/components/router.d.cts +1 -1
- package/dist/components/router.d.ts +1 -1
- package/dist/components/router.js +4 -2
- package/dist/components/router.js.map +1 -1
- package/dist/components/search-page.cjs +178 -0
- package/dist/components/search-page.cjs.map +1 -0
- package/dist/components/search-page.d.cts +5 -0
- package/dist/components/search-page.d.ts +5 -0
- package/dist/components/search-page.js +144 -0
- package/dist/components/search-page.js.map +1 -0
- package/dist/components/token-card.cjs +3 -2
- package/dist/components/token-card.cjs.map +1 -1
- package/dist/components/token-card.js +3 -2
- package/dist/components/token-card.js.map +1 -1
- package/dist/data/nav-commands.cjs +85 -0
- package/dist/data/nav-commands.cjs.map +1 -0
- package/dist/data/nav-commands.d.cts +342 -0
- package/dist/data/nav-commands.d.ts +342 -0
- package/dist/data/nav-commands.js +89 -0
- package/dist/data/nav-commands.js.map +1 -0
- package/dist/index.cjs +39 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -2
- package/dist/index.d.ts +11 -2
- package/dist/index.js +26 -2
- package/dist/index.js.map +1 -1
- package/dist/utils/format-activity.cjs +9 -8
- package/dist/utils/format-activity.cjs.map +1 -1
- package/dist/utils/format-activity.d.cts +5 -4
- package/dist/utils/format-activity.d.ts +5 -4
- package/dist/utils/format-activity.js +10 -9
- package/dist/utils/format-activity.js.map +1 -1
- package/dist/utils/ipfs.cjs +6 -1
- package/dist/utils/ipfs.cjs.map +1 -1
- package/dist/utils/ipfs.d.cts +6 -1
- package/dist/utils/ipfs.d.ts +6 -1
- package/dist/utils/ipfs.js +5 -1
- package/dist/utils/ipfs.js.map +1 -1
- package/dist/utils/portfolio-counts.cjs +8 -2
- package/dist/utils/portfolio-counts.cjs.map +1 -1
- package/dist/utils/portfolio-counts.d.cts +9 -3
- package/dist/utils/portfolio-counts.d.ts +9 -3
- package/dist/utils/portfolio-counts.js +8 -2
- package/dist/utils/portfolio-counts.js.map +1 -1
- package/dist/utils/seen-offers.cjs +52 -0
- package/dist/utils/seen-offers.cjs.map +1 -0
- package/dist/utils/seen-offers.d.cts +4 -0
- package/dist/utils/seen-offers.d.ts +4 -0
- package/dist/utils/seen-offers.js +27 -0
- package/dist/utils/seen-offers.js.map +1 -0
- package/dist/utils/token-profile-link.cjs +3 -2
- package/dist/utils/token-profile-link.cjs.map +1 -1
- package/dist/utils/token-profile-link.js +3 -2
- package/dist/utils/token-profile-link.js.map +1 -1
- package/dist/utils/use-image-url.cjs +36 -0
- package/dist/utils/use-image-url.cjs.map +1 -0
- package/dist/utils/use-image-url.d.cts +5 -0
- package/dist/utils/use-image-url.d.ts +5 -0
- package/dist/utils/use-image-url.js +12 -0
- package/dist/utils/use-image-url.js.map +1 -0
- package/dist/utils/use-notifications.cjs +7 -5
- package/dist/utils/use-notifications.cjs.map +1 -1
- package/dist/utils/use-notifications.js +7 -5
- package/dist/utils/use-notifications.js.map +1 -1
- package/dist/utils/use-search.cjs +59 -0
- package/dist/utils/use-search.cjs.map +1 -0
- package/dist/utils/use-search.d.cts +14 -0
- package/dist/utils/use-search.d.ts +14 -0
- package/dist/utils/use-search.js +24 -0
- package/dist/utils/use-search.js.map +1 -0
- package/package.json +3 -3
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all)
|
|
11
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from))
|
|
16
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
+
mod
|
|
28
|
+
));
|
|
29
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
+
var portfolio_orders_exports = {};
|
|
31
|
+
__export(portfolio_orders_exports, {
|
|
32
|
+
PortfolioOrders: () => PortfolioOrders
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(portfolio_orders_exports);
|
|
35
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
36
|
+
var import_sdk = require("@medialane/sdk");
|
|
37
|
+
var import_lucide_react = require("lucide-react");
|
|
38
|
+
var import_image = __toESM(require("./image.js"), 1);
|
|
39
|
+
var import_link = __toESM(require("./link.js"), 1);
|
|
40
|
+
var import_badge = require("./badge.js");
|
|
41
|
+
var import_button = require("./button.js");
|
|
42
|
+
var import_empty_or_error = require("./empty-or-error.js");
|
|
43
|
+
var import_cn = require("../utils/cn.js");
|
|
44
|
+
var import_explorer_url = require("../utils/explorer-url.js");
|
|
45
|
+
var import_format = require("../utils/format.js");
|
|
46
|
+
var import_time = require("../utils/time.js");
|
|
47
|
+
var import_same_address = require("../utils/same-address.js");
|
|
48
|
+
var import_seen_offers = require("../utils/seen-offers.js");
|
|
49
|
+
var import_use_image_url = require("../utils/use-image-url.js");
|
|
50
|
+
var import_use_orders = require("../utils/use-orders.js");
|
|
51
|
+
const VIEWS = {
|
|
52
|
+
listings: {
|
|
53
|
+
emptyTitle: "No active listings",
|
|
54
|
+
emptyDescription: "List an asset to start selling.",
|
|
55
|
+
emptyCta: { label: "Browse assets", href: "/portfolio/assets" },
|
|
56
|
+
emptyIcon: import_lucide_react.Tag,
|
|
57
|
+
priceLabel: "Price",
|
|
58
|
+
count: (n) => `${n} active listing${n === 1 ? "" : "s"}`
|
|
59
|
+
},
|
|
60
|
+
offers: {
|
|
61
|
+
emptyTitle: "No offers sent yet",
|
|
62
|
+
emptyDescription: "Browse the marketplace to make offers on assets.",
|
|
63
|
+
emptyCta: { label: "Browse marketplace", href: "/marketplace" },
|
|
64
|
+
emptyIcon: import_lucide_react.HandCoins,
|
|
65
|
+
priceLabel: "Offer price",
|
|
66
|
+
count: (n) => `${n} active offer${n === 1 ? "" : "s"}`
|
|
67
|
+
},
|
|
68
|
+
received: {
|
|
69
|
+
emptyTitle: "No offers received yet",
|
|
70
|
+
emptyDescription: "When someone makes an offer on your asset, it will appear here.",
|
|
71
|
+
emptyCta: void 0,
|
|
72
|
+
emptyIcon: import_lucide_react.Inbox,
|
|
73
|
+
priceLabel: "Offer price",
|
|
74
|
+
count: null
|
|
75
|
+
},
|
|
76
|
+
"counter-offers": {
|
|
77
|
+
emptyTitle: "No counter-offers yet",
|
|
78
|
+
emptyDescription: "When a seller responds to your bid with a counter-offer, it will appear here.",
|
|
79
|
+
emptyCta: void 0,
|
|
80
|
+
emptyIcon: import_lucide_react.Inbox,
|
|
81
|
+
priceLabel: "Their price / Your bid",
|
|
82
|
+
count: null
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
const isNft = (o) => o.offer.itemType === "ERC721" || o.offer.itemType === "ERC1155";
|
|
86
|
+
function expiryOf(order) {
|
|
87
|
+
const expired = (0, import_time.isExpired)(order.endTime);
|
|
88
|
+
const urgent = !expired && Number(order.endTime) * 1e3 - Date.now() < 864e5;
|
|
89
|
+
return { label: (0, import_time.timeUntil)(order.endTime), expired, urgent };
|
|
90
|
+
}
|
|
91
|
+
function price(o) {
|
|
92
|
+
return `${(0, import_format.formatDisplayPrice)(o.price.formatted)} ${o.price.currency ?? ""}`.trim();
|
|
93
|
+
}
|
|
94
|
+
function OrderRow({ order, subtitle, from, priceCell, actions, isNew }) {
|
|
95
|
+
const resolveImage = (0, import_use_image_url.useImageUrl)();
|
|
96
|
+
const name = order.token?.name || `#${order.nftTokenId}`;
|
|
97
|
+
const image = resolveImage(order.token?.image, { width: 96 });
|
|
98
|
+
const expiry = expiryOf(order);
|
|
99
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { "data-new": isNew ? "true" : void 0, className: (0, import_cn.cn)("flex items-center gap-4 px-4 py-3 transition-colors hover:bg-muted/40", isNew && "border-l-2 border-primary"), children: [
|
|
100
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "relative h-12 w-12 shrink-0 overflow-hidden rounded-lg border border-border bg-muted", children: image && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_image.default, { src: image, alt: name, fill: true, sizes: "48px", unoptimized: true, className: "object-cover" }) }),
|
|
101
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "min-w-0 flex-1", children: [
|
|
102
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_link.default, { href: (0, import_sdk.assetHref)("STARKNET", order.nftContract, order.nftTokenId), className: "block truncate text-sm font-medium transition-colors hover:text-primary", children: name }),
|
|
103
|
+
subtitle
|
|
104
|
+
] }),
|
|
105
|
+
from && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "hidden shrink-0 sm:block", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_link.default, { href: (0, import_sdk.profileHref)({ address: from }), className: "text-xs tabular-nums text-muted-foreground transition-colors hover:text-foreground", children: [
|
|
106
|
+
from.slice(0, 6),
|
|
107
|
+
"\u2026",
|
|
108
|
+
from.slice(-4)
|
|
109
|
+
] }) }),
|
|
110
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "hidden shrink-0 text-right sm:block", children: priceCell }),
|
|
111
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "hidden shrink-0 md:block", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: (0, import_cn.cn)("text-sm", expiry.expired && "text-muted-foreground", expiry.urgent && "font-medium text-destructive"), children: expiry.label }) }),
|
|
112
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex shrink-0 items-center gap-2", children: [
|
|
113
|
+
order.txHash?.created && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("a", { href: `${import_explorer_url.EXPLORER_URL}/tx/${order.txHash.created}`, target: "_blank", rel: "noopener noreferrer", "aria-label": "View on explorer", className: "inline-flex h-7 w-7 items-center justify-center rounded-md transition-colors hover:bg-muted", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.ExternalLink, { className: "h-3.5 w-3.5 text-muted-foreground" }) }),
|
|
114
|
+
actions
|
|
115
|
+
] })
|
|
116
|
+
] });
|
|
117
|
+
}
|
|
118
|
+
function PriceText({ order }) {
|
|
119
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { className: "text-sm font-semibold", children: [
|
|
120
|
+
(0, import_format.formatDisplayPrice)(order.price.formatted),
|
|
121
|
+
" ",
|
|
122
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "text-xs font-normal text-muted-foreground", children: order.price.currency })
|
|
123
|
+
] });
|
|
124
|
+
}
|
|
125
|
+
function CounterOfferRow({ bid, actions }) {
|
|
126
|
+
const { counterOffers } = (0, import_use_orders.useCounterOffers)({ originalOrderHash: bid.orderHash });
|
|
127
|
+
const counter = counterOffers[0];
|
|
128
|
+
if (!counter) return null;
|
|
129
|
+
const closed = counter.status !== "ACTIVE" || (0, import_time.isExpired)(counter.endTime);
|
|
130
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
131
|
+
OrderRow,
|
|
132
|
+
{
|
|
133
|
+
order: counter,
|
|
134
|
+
subtitle: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_badge.Badge, { variant: "secondary", className: "mt-0.5 h-4 px-1.5 text-[10px]", children: [
|
|
135
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.ArrowLeftRight, { className: "mr-1 h-2.5 w-2.5" }),
|
|
136
|
+
"Counter-offer"
|
|
137
|
+
] }),
|
|
138
|
+
priceCell: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex flex-col items-end gap-0.5", children: [
|
|
139
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "text-xs text-muted-foreground line-through", children: price(bid) }),
|
|
140
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "text-sm font-semibold", children: counter.price.formatted ? price(counter) : "\u2014" })
|
|
141
|
+
] }),
|
|
142
|
+
actions: closed ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "text-xs text-muted-foreground", children: counter.status !== "ACTIVE" ? counter.status.toLowerCase() : "Expired" }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_button.Button, { size: "sm", className: "h-8 text-xs", disabled: actions.isProcessing, onClick: () => actions.accept?.(counter, bid), children: "Accept" })
|
|
143
|
+
}
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
function PortfolioOrders({ view, address, useActions }) {
|
|
147
|
+
const mine = (0, import_use_orders.useUserOrders)(view === "received" ? null : address);
|
|
148
|
+
const received = (0, import_use_orders.useReceivedOffers)(view === "received" ? address : null);
|
|
149
|
+
const source = view === "received" ? received : mine;
|
|
150
|
+
const actions = useActions({ view, refresh: () => void source.mutate() });
|
|
151
|
+
const config = VIEWS[view];
|
|
152
|
+
const orders = view === "listings" ? mine.orders.filter((o) => isNft(o) && o.status === "ACTIVE") : view === "offers" ? mine.orders.filter((o) => o.offer.itemType === "ERC20" && o.status === "ACTIVE") : view === "counter-offers" ? mine.orders.filter((o) => o.offer.itemType === "ERC20" && (0, import_same_address.isSameAddress)(o.offerer, address) && o.hasActiveCounterOffer === true) : received.orders;
|
|
153
|
+
const seen = view === "received" ? (0, import_seen_offers.getSeenOffers)() : null;
|
|
154
|
+
const EmptyIcon = config.emptyIcon;
|
|
155
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
156
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
157
|
+
import_empty_or_error.EmptyOrError,
|
|
158
|
+
{
|
|
159
|
+
isLoading: source.isLoading,
|
|
160
|
+
error: source.error,
|
|
161
|
+
isEmpty: orders.length === 0,
|
|
162
|
+
onRetry: () => void source.mutate(),
|
|
163
|
+
emptyTitle: config.emptyTitle,
|
|
164
|
+
emptyDescription: config.emptyDescription,
|
|
165
|
+
emptyCta: config.emptyCta,
|
|
166
|
+
emptyIcon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(EmptyIcon, { className: "h-7 w-7 text-muted-foreground" }),
|
|
167
|
+
skeletonCount: 3,
|
|
168
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "space-y-1", children: [
|
|
169
|
+
config.count && orders.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "pb-2 text-sm text-muted-foreground", children: config.count(orders.length) }),
|
|
170
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "overflow-hidden rounded-lg border border-border", children: [
|
|
171
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex items-center gap-4 border-b border-border bg-muted/30 px-4 py-2 text-xs uppercase tracking-wide text-muted-foreground", children: [
|
|
172
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "w-12 shrink-0" }),
|
|
173
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "flex-1", children: "Asset" }),
|
|
174
|
+
view === "received" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "hidden w-28 sm:block", children: "From" }),
|
|
175
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: (0, import_cn.cn)("hidden text-right sm:block", view === "counter-offers" ? "w-40" : "w-24"), children: config.priceLabel }),
|
|
176
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "hidden w-28 md:block", children: "Expires" }),
|
|
177
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "w-24 text-right", children: "Actions" })
|
|
178
|
+
] }),
|
|
179
|
+
view === "counter-offers" ? orders.map((bid) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CounterOfferRow, { bid, actions }, bid.orderHash)) : orders.map((order) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
180
|
+
OrderRow,
|
|
181
|
+
{
|
|
182
|
+
order,
|
|
183
|
+
isNew: seen ? !seen.has(order.orderHash) : false,
|
|
184
|
+
from: view === "received" ? order.offerer : void 0,
|
|
185
|
+
subtitle: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "text-xs text-muted-foreground", children: view === "received" ? "Received offer" : view === "offers" ? "Offer" : "Active" }),
|
|
186
|
+
priceCell: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PriceText, { order }),
|
|
187
|
+
actions: view === "received" ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
188
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_button.Button, { size: "sm", variant: "outline", className: "h-8 text-xs", disabled: actions.isProcessing, onClick: () => actions.counter?.(order), children: "Counter" }),
|
|
189
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_button.Button, { size: "sm", className: "h-8 text-xs", disabled: actions.isProcessing, onClick: () => actions.accept?.(order), children: "Accept" })
|
|
190
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_button.Button, { size: "sm", variant: "outline", className: "h-8 text-xs text-destructive hover:text-destructive", disabled: actions.isProcessing, onClick: () => actions.cancel?.(order), children: "Cancel" })
|
|
191
|
+
},
|
|
192
|
+
order.orderHash
|
|
193
|
+
))
|
|
194
|
+
] })
|
|
195
|
+
] })
|
|
196
|
+
}
|
|
197
|
+
),
|
|
198
|
+
actions.dialogs
|
|
199
|
+
] });
|
|
200
|
+
}
|
|
201
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
202
|
+
0 && (module.exports = {
|
|
203
|
+
PortfolioOrders
|
|
204
|
+
});
|
|
205
|
+
//# sourceMappingURL=portfolio-orders.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/portfolio-orders.tsx"],"sourcesContent":["\"use client\";\n\nimport type { ReactNode } from \"react\";\nimport { assetHref, profileHref, type ApiOrder } from \"@medialane/sdk\";\nimport { ArrowLeftRight, ExternalLink, HandCoins, Inbox, Tag } from \"lucide-react\";\nimport Image from \"./image.js\";\nimport Link from \"./link.js\";\nimport { Badge } from \"./badge.js\";\nimport { Button } from \"./button.js\";\nimport { EmptyOrError } from \"./empty-or-error.js\";\nimport { cn } from \"../utils/cn.js\";\nimport { EXPLORER_URL } from \"../utils/explorer-url.js\";\nimport { formatDisplayPrice } from \"../utils/format.js\";\nimport { isExpired, timeUntil } from \"../utils/time.js\";\nimport { isSameAddress } from \"../utils/same-address.js\";\nimport { getSeenOffers } from \"../utils/seen-offers.js\";\nimport { useImageUrl } from \"../utils/use-image-url.js\";\nimport { useCounterOffers, useReceivedOffers, useUserOrders } from \"../utils/use-orders.js\";\n\nexport type PortfolioOrdersView = \"listings\" | \"offers\" | \"received\" | \"counter-offers\";\n\nexport interface PortfolioOrderActions {\n isProcessing: boolean;\n cancel?: (order: ApiOrder) => void;\n accept?: (order: ApiOrder, original?: ApiOrder) => void;\n counter?: (order: ApiOrder) => void;\n dialogs?: ReactNode;\n}\n\nexport type UsePortfolioOrderActions = (context: { view: PortfolioOrdersView; refresh: () => void }) => PortfolioOrderActions;\n\nconst VIEWS = {\n listings: {\n emptyTitle: \"No active listings\",\n emptyDescription: \"List an asset to start selling.\",\n emptyCta: { label: \"Browse assets\", href: \"/portfolio/assets\" },\n emptyIcon: Tag,\n priceLabel: \"Price\",\n count: (n: number) => `${n} active listing${n === 1 ? \"\" : \"s\"}`,\n },\n offers: {\n emptyTitle: \"No offers sent yet\",\n emptyDescription: \"Browse the marketplace to make offers on assets.\",\n emptyCta: { label: \"Browse marketplace\", href: \"/marketplace\" },\n emptyIcon: HandCoins,\n priceLabel: \"Offer price\",\n count: (n: number) => `${n} active offer${n === 1 ? \"\" : \"s\"}`,\n },\n received: {\n emptyTitle: \"No offers received yet\",\n emptyDescription: \"When someone makes an offer on your asset, it will appear here.\",\n emptyCta: undefined,\n emptyIcon: Inbox,\n priceLabel: \"Offer price\",\n count: null,\n },\n \"counter-offers\": {\n emptyTitle: \"No counter-offers yet\",\n emptyDescription: \"When a seller responds to your bid with a counter-offer, it will appear here.\",\n emptyCta: undefined,\n emptyIcon: Inbox,\n priceLabel: \"Their price / Your bid\",\n count: null,\n },\n} as const;\n\nconst isNft = (o: ApiOrder) => o.offer.itemType === \"ERC721\" || o.offer.itemType === \"ERC1155\";\n\nfunction expiryOf(order: ApiOrder) {\n const expired = isExpired(order.endTime);\n const urgent = !expired && Number(order.endTime) * 1000 - Date.now() < 86400000;\n return { label: timeUntil(order.endTime), expired, urgent };\n}\n\nfunction price(o: ApiOrder) {\n return `${formatDisplayPrice(o.price.formatted)} ${o.price.currency ?? \"\"}`.trim();\n}\n\nfunction OrderRow({ order, subtitle, from, priceCell, actions, isNew }: {\n order: ApiOrder;\n subtitle: ReactNode;\n from?: string;\n priceCell: ReactNode;\n actions: ReactNode;\n isNew?: boolean;\n}) {\n const resolveImage = useImageUrl();\n const name = order.token?.name || `#${order.nftTokenId}`;\n const image = resolveImage(order.token?.image, { width: 96 });\n const expiry = expiryOf(order);\n return (\n <div data-new={isNew ? \"true\" : undefined} className={cn(\"flex items-center gap-4 px-4 py-3 transition-colors hover:bg-muted/40\", isNew && \"border-l-2 border-primary\")}>\n <div className=\"relative h-12 w-12 shrink-0 overflow-hidden rounded-lg border border-border bg-muted\">\n {image && <Image src={image} alt={name} fill sizes=\"48px\" unoptimized className=\"object-cover\" />}\n </div>\n <div className=\"min-w-0 flex-1\">\n <Link href={assetHref(\"STARKNET\", order.nftContract, order.nftTokenId)} className=\"block truncate text-sm font-medium transition-colors hover:text-primary\">\n {name}\n </Link>\n {subtitle}\n </div>\n {from && (\n <div className=\"hidden shrink-0 sm:block\">\n <Link href={profileHref({ address: from })} className=\"text-xs tabular-nums text-muted-foreground transition-colors hover:text-foreground\">\n {from.slice(0, 6)}…{from.slice(-4)}\n </Link>\n </div>\n )}\n <div className=\"hidden shrink-0 text-right sm:block\">{priceCell}</div>\n <div className=\"hidden shrink-0 md:block\">\n <p className={cn(\"text-sm\", expiry.expired && \"text-muted-foreground\", expiry.urgent && \"font-medium text-destructive\")}>{expiry.label}</p>\n </div>\n <div className=\"flex shrink-0 items-center gap-2\">\n {order.txHash?.created && (\n <a href={`${EXPLORER_URL}/tx/${order.txHash.created}`} target=\"_blank\" rel=\"noopener noreferrer\" aria-label=\"View on explorer\" className=\"inline-flex h-7 w-7 items-center justify-center rounded-md transition-colors hover:bg-muted\">\n <ExternalLink className=\"h-3.5 w-3.5 text-muted-foreground\" />\n </a>\n )}\n {actions}\n </div>\n </div>\n );\n}\n\nfunction PriceText({ order }: { order: ApiOrder }) {\n return (\n <p className=\"text-sm font-semibold\">\n {formatDisplayPrice(order.price.formatted)} <span className=\"text-xs font-normal text-muted-foreground\">{order.price.currency}</span>\n </p>\n );\n}\n\nfunction CounterOfferRow({ bid, actions }: { bid: ApiOrder; actions: PortfolioOrderActions }) {\n const { counterOffers } = useCounterOffers({ originalOrderHash: bid.orderHash });\n const counter = counterOffers[0];\n if (!counter) return null;\n const closed = counter.status !== \"ACTIVE\" || isExpired(counter.endTime);\n return (\n <OrderRow\n order={counter}\n subtitle={\n <Badge variant=\"secondary\" className=\"mt-0.5 h-4 px-1.5 text-[10px]\">\n <ArrowLeftRight className=\"mr-1 h-2.5 w-2.5\" />\n Counter-offer\n </Badge>\n }\n priceCell={\n <div className=\"flex flex-col items-end gap-0.5\">\n <p className=\"text-xs text-muted-foreground line-through\">{price(bid)}</p>\n <p className=\"text-sm font-semibold\">{counter.price.formatted ? price(counter) : \"—\"}</p>\n </div>\n }\n actions={\n closed ? (\n <span className=\"text-xs text-muted-foreground\">{counter.status !== \"ACTIVE\" ? counter.status.toLowerCase() : \"Expired\"}</span>\n ) : (\n <Button size=\"sm\" className=\"h-8 text-xs\" disabled={actions.isProcessing} onClick={() => actions.accept?.(counter, bid)}>\n Accept\n </Button>\n )\n }\n />\n );\n}\n\nexport function PortfolioOrders({ view, address, useActions }: {\n view: PortfolioOrdersView;\n address: string;\n useActions: UsePortfolioOrderActions;\n}) {\n const mine = useUserOrders(view === \"received\" ? null : address);\n const received = useReceivedOffers(view === \"received\" ? address : null);\n const source = view === \"received\" ? received : mine;\n const actions = useActions({ view, refresh: () => void source.mutate() });\n const config = VIEWS[view];\n\n const orders =\n view === \"listings\" ? mine.orders.filter((o) => isNft(o) && o.status === \"ACTIVE\")\n : view === \"offers\" ? mine.orders.filter((o) => o.offer.itemType === \"ERC20\" && o.status === \"ACTIVE\")\n : view === \"counter-offers\" ? mine.orders.filter((o) => o.offer.itemType === \"ERC20\" && isSameAddress(o.offerer, address) && o.hasActiveCounterOffer === true)\n : received.orders;\n\n const seen = view === \"received\" ? getSeenOffers() : null;\n const EmptyIcon = config.emptyIcon;\n\n return (\n <>\n <EmptyOrError\n isLoading={source.isLoading}\n error={source.error}\n isEmpty={orders.length === 0}\n onRetry={() => void source.mutate()}\n emptyTitle={config.emptyTitle}\n emptyDescription={config.emptyDescription}\n emptyCta={config.emptyCta}\n emptyIcon={<EmptyIcon className=\"h-7 w-7 text-muted-foreground\" />}\n skeletonCount={3}\n >\n <div className=\"space-y-1\">\n {config.count && orders.length > 0 && <p className=\"pb-2 text-sm text-muted-foreground\">{config.count(orders.length)}</p>}\n <div className=\"overflow-hidden rounded-lg border border-border\">\n <div className=\"flex items-center gap-4 border-b border-border bg-muted/30 px-4 py-2 text-xs uppercase tracking-wide text-muted-foreground\">\n <div className=\"w-12 shrink-0\" />\n <div className=\"flex-1\">Asset</div>\n {view === \"received\" && <div className=\"hidden w-28 sm:block\">From</div>}\n <div className={cn(\"hidden text-right sm:block\", view === \"counter-offers\" ? \"w-40\" : \"w-24\")}>{config.priceLabel}</div>\n <div className=\"hidden w-28 md:block\">Expires</div>\n <div className=\"w-24 text-right\">Actions</div>\n </div>\n {view === \"counter-offers\"\n ? orders.map((bid) => <CounterOfferRow key={bid.orderHash} bid={bid} actions={actions} />)\n : orders.map((order) => (\n <OrderRow\n key={order.orderHash}\n order={order}\n isNew={seen ? !seen.has(order.orderHash) : false}\n from={view === \"received\" ? order.offerer : undefined}\n subtitle={<span className=\"text-xs text-muted-foreground\">{view === \"received\" ? \"Received offer\" : view === \"offers\" ? \"Offer\" : \"Active\"}</span>}\n priceCell={<PriceText order={order} />}\n actions={\n view === \"received\" ? (\n <>\n <Button size=\"sm\" variant=\"outline\" className=\"h-8 text-xs\" disabled={actions.isProcessing} onClick={() => actions.counter?.(order)}>Counter</Button>\n <Button size=\"sm\" className=\"h-8 text-xs\" disabled={actions.isProcessing} onClick={() => actions.accept?.(order)}>Accept</Button>\n </>\n ) : (\n <Button size=\"sm\" variant=\"outline\" className=\"h-8 text-xs text-destructive hover:text-destructive\" disabled={actions.isProcessing} onClick={() => actions.cancel?.(order)}>Cancel</Button>\n )\n }\n />\n ))}\n </div>\n </div>\n </EmptyOrError>\n {actions.dialogs}\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA6FkB;AA1FlB,iBAAsD;AACtD,0BAAoE;AACpE,mBAAkB;AAClB,kBAAiB;AACjB,mBAAsB;AACtB,oBAAuB;AACvB,4BAA6B;AAC7B,gBAAmB;AACnB,0BAA6B;AAC7B,oBAAmC;AACnC,kBAAqC;AACrC,0BAA8B;AAC9B,yBAA8B;AAC9B,2BAA4B;AAC5B,wBAAmE;AAcnE,MAAM,QAAQ;AAAA,EACZ,UAAU;AAAA,IACR,YAAY;AAAA,IACZ,kBAAkB;AAAA,IAClB,UAAU,EAAE,OAAO,iBAAiB,MAAM,oBAAoB;AAAA,IAC9D,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,OAAO,CAAC,MAAc,GAAG,CAAC,kBAAkB,MAAM,IAAI,KAAK,GAAG;AAAA,EAChE;AAAA,EACA,QAAQ;AAAA,IACN,YAAY;AAAA,IACZ,kBAAkB;AAAA,IAClB,UAAU,EAAE,OAAO,sBAAsB,MAAM,eAAe;AAAA,IAC9D,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,OAAO,CAAC,MAAc,GAAG,CAAC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S,WAAW,UAAU,UAAS;AAAA,gBAC3I,WAAW,4CAAC,aAAU,OAAc;AAAA,gBACpC,SACE,SAAS,aACP,4EACE;AAAA,8DAAC,wBAAO,MAAK,MAAK,SAAQ,WAAU,WAAU,eAAc,UAAU,QAAQ,cAAc,SAAS,MAAM,QAAQ,UAAU,KAAK,GAAG,qBAAO;AAAA,kBAC5I,4CAAC,wBAAO,MAAK,MAAK,WAAU,eAAc,UAAU,QAAQ,cAAc,SAAS,MAAM,QAAQ,SAAS,KAAK,GAAG,oBAAM;AAAA,mBAC1H,IAEA,4CAAC,wBAAO,MAAK,MAAK,SAAQ,WAAU,WAAU,uDAAsD,UAAU,QAAQ,cAAc,SAAS,MAAM,QAAQ,SAAS,KAAK,GAAG,oBAAM;AAAA;AAAA,cAbjL,MAAM;AAAA,YAgBb,CACD;AAAA,aACP;AAAA,WACF;AAAA;AAAA,IACF;AAAA,IACC,QAAQ;AAAA,KACX;AAEJ;","names":["Image","Link"]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import { ApiOrder } from '@medialane/sdk';
|
|
4
|
+
|
|
5
|
+
type PortfolioOrdersView = "listings" | "offers" | "received" | "counter-offers";
|
|
6
|
+
interface PortfolioOrderActions {
|
|
7
|
+
isProcessing: boolean;
|
|
8
|
+
cancel?: (order: ApiOrder) => void;
|
|
9
|
+
accept?: (order: ApiOrder, original?: ApiOrder) => void;
|
|
10
|
+
counter?: (order: ApiOrder) => void;
|
|
11
|
+
dialogs?: ReactNode;
|
|
12
|
+
}
|
|
13
|
+
type UsePortfolioOrderActions = (context: {
|
|
14
|
+
view: PortfolioOrdersView;
|
|
15
|
+
refresh: () => void;
|
|
16
|
+
}) => PortfolioOrderActions;
|
|
17
|
+
declare function PortfolioOrders({ view, address, useActions }: {
|
|
18
|
+
view: PortfolioOrdersView;
|
|
19
|
+
address: string;
|
|
20
|
+
useActions: UsePortfolioOrderActions;
|
|
21
|
+
}): react_jsx_runtime.JSX.Element;
|
|
22
|
+
|
|
23
|
+
export { type PortfolioOrderActions, PortfolioOrders, type PortfolioOrdersView, type UsePortfolioOrderActions };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import { ApiOrder } from '@medialane/sdk';
|
|
4
|
+
|
|
5
|
+
type PortfolioOrdersView = "listings" | "offers" | "received" | "counter-offers";
|
|
6
|
+
interface PortfolioOrderActions {
|
|
7
|
+
isProcessing: boolean;
|
|
8
|
+
cancel?: (order: ApiOrder) => void;
|
|
9
|
+
accept?: (order: ApiOrder, original?: ApiOrder) => void;
|
|
10
|
+
counter?: (order: ApiOrder) => void;
|
|
11
|
+
dialogs?: ReactNode;
|
|
12
|
+
}
|
|
13
|
+
type UsePortfolioOrderActions = (context: {
|
|
14
|
+
view: PortfolioOrdersView;
|
|
15
|
+
refresh: () => void;
|
|
16
|
+
}) => PortfolioOrderActions;
|
|
17
|
+
declare function PortfolioOrders({ view, address, useActions }: {
|
|
18
|
+
view: PortfolioOrdersView;
|
|
19
|
+
address: string;
|
|
20
|
+
useActions: UsePortfolioOrderActions;
|
|
21
|
+
}): react_jsx_runtime.JSX.Element;
|
|
22
|
+
|
|
23
|
+
export { type PortfolioOrderActions, PortfolioOrders, type PortfolioOrdersView, type UsePortfolioOrderActions };
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { assetHref, profileHref } from "@medialane/sdk";
|
|
4
|
+
import { ArrowLeftRight, ExternalLink, HandCoins, Inbox, Tag } from "lucide-react";
|
|
5
|
+
import Image from "./image.js";
|
|
6
|
+
import Link from "./link.js";
|
|
7
|
+
import { Badge } from "./badge.js";
|
|
8
|
+
import { Button } from "./button.js";
|
|
9
|
+
import { EmptyOrError } from "./empty-or-error.js";
|
|
10
|
+
import { cn } from "../utils/cn.js";
|
|
11
|
+
import { EXPLORER_URL } from "../utils/explorer-url.js";
|
|
12
|
+
import { formatDisplayPrice } from "../utils/format.js";
|
|
13
|
+
import { isExpired, timeUntil } from "../utils/time.js";
|
|
14
|
+
import { isSameAddress } from "../utils/same-address.js";
|
|
15
|
+
import { getSeenOffers } from "../utils/seen-offers.js";
|
|
16
|
+
import { useImageUrl } from "../utils/use-image-url.js";
|
|
17
|
+
import { useCounterOffers, useReceivedOffers, useUserOrders } from "../utils/use-orders.js";
|
|
18
|
+
const VIEWS = {
|
|
19
|
+
listings: {
|
|
20
|
+
emptyTitle: "No active listings",
|
|
21
|
+
emptyDescription: "List an asset to start selling.",
|
|
22
|
+
emptyCta: { label: "Browse assets", href: "/portfolio/assets" },
|
|
23
|
+
emptyIcon: Tag,
|
|
24
|
+
priceLabel: "Price",
|
|
25
|
+
count: (n) => `${n} active listing${n === 1 ? "" : "s"}`
|
|
26
|
+
},
|
|
27
|
+
offers: {
|
|
28
|
+
emptyTitle: "No offers sent yet",
|
|
29
|
+
emptyDescription: "Browse the marketplace to make offers on assets.",
|
|
30
|
+
emptyCta: { label: "Browse marketplace", href: "/marketplace" },
|
|
31
|
+
emptyIcon: HandCoins,
|
|
32
|
+
priceLabel: "Offer price",
|
|
33
|
+
count: (n) => `${n} active offer${n === 1 ? "" : "s"}`
|
|
34
|
+
},
|
|
35
|
+
received: {
|
|
36
|
+
emptyTitle: "No offers received yet",
|
|
37
|
+
emptyDescription: "When someone makes an offer on your asset, it will appear here.",
|
|
38
|
+
emptyCta: void 0,
|
|
39
|
+
emptyIcon: Inbox,
|
|
40
|
+
priceLabel: "Offer price",
|
|
41
|
+
count: null
|
|
42
|
+
},
|
|
43
|
+
"counter-offers": {
|
|
44
|
+
emptyTitle: "No counter-offers yet",
|
|
45
|
+
emptyDescription: "When a seller responds to your bid with a counter-offer, it will appear here.",
|
|
46
|
+
emptyCta: void 0,
|
|
47
|
+
emptyIcon: Inbox,
|
|
48
|
+
priceLabel: "Their price / Your bid",
|
|
49
|
+
count: null
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
const isNft = (o) => o.offer.itemType === "ERC721" || o.offer.itemType === "ERC1155";
|
|
53
|
+
function expiryOf(order) {
|
|
54
|
+
const expired = isExpired(order.endTime);
|
|
55
|
+
const urgent = !expired && Number(order.endTime) * 1e3 - Date.now() < 864e5;
|
|
56
|
+
return { label: timeUntil(order.endTime), expired, urgent };
|
|
57
|
+
}
|
|
58
|
+
function price(o) {
|
|
59
|
+
return `${formatDisplayPrice(o.price.formatted)} ${o.price.currency ?? ""}`.trim();
|
|
60
|
+
}
|
|
61
|
+
function OrderRow({ order, subtitle, from, priceCell, actions, isNew }) {
|
|
62
|
+
const resolveImage = useImageUrl();
|
|
63
|
+
const name = order.token?.name || `#${order.nftTokenId}`;
|
|
64
|
+
const image = resolveImage(order.token?.image, { width: 96 });
|
|
65
|
+
const expiry = expiryOf(order);
|
|
66
|
+
return /* @__PURE__ */ jsxs("div", { "data-new": isNew ? "true" : void 0, className: cn("flex items-center gap-4 px-4 py-3 transition-colors hover:bg-muted/40", isNew && "border-l-2 border-primary"), children: [
|
|
67
|
+
/* @__PURE__ */ jsx("div", { className: "relative h-12 w-12 shrink-0 overflow-hidden rounded-lg border border-border bg-muted", children: image && /* @__PURE__ */ jsx(Image, { src: image, alt: name, fill: true, sizes: "48px", unoptimized: true, className: "object-cover" }) }),
|
|
68
|
+
/* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1", children: [
|
|
69
|
+
/* @__PURE__ */ jsx(Link, { href: assetHref("STARKNET", order.nftContract, order.nftTokenId), className: "block truncate text-sm font-medium transition-colors hover:text-primary", children: name }),
|
|
70
|
+
subtitle
|
|
71
|
+
] }),
|
|
72
|
+
from && /* @__PURE__ */ jsx("div", { className: "hidden shrink-0 sm:block", children: /* @__PURE__ */ jsxs(Link, { href: profileHref({ address: from }), className: "text-xs tabular-nums text-muted-foreground transition-colors hover:text-foreground", children: [
|
|
73
|
+
from.slice(0, 6),
|
|
74
|
+
"\u2026",
|
|
75
|
+
from.slice(-4)
|
|
76
|
+
] }) }),
|
|
77
|
+
/* @__PURE__ */ jsx("div", { className: "hidden shrink-0 text-right sm:block", children: priceCell }),
|
|
78
|
+
/* @__PURE__ */ jsx("div", { className: "hidden shrink-0 md:block", children: /* @__PURE__ */ jsx("p", { className: cn("text-sm", expiry.expired && "text-muted-foreground", expiry.urgent && "font-medium text-destructive"), children: expiry.label }) }),
|
|
79
|
+
/* @__PURE__ */ jsxs("div", { className: "flex shrink-0 items-center gap-2", children: [
|
|
80
|
+
order.txHash?.created && /* @__PURE__ */ jsx("a", { href: `${EXPLORER_URL}/tx/${order.txHash.created}`, target: "_blank", rel: "noopener noreferrer", "aria-label": "View on explorer", className: "inline-flex h-7 w-7 items-center justify-center rounded-md transition-colors hover:bg-muted", children: /* @__PURE__ */ jsx(ExternalLink, { className: "h-3.5 w-3.5 text-muted-foreground" }) }),
|
|
81
|
+
actions
|
|
82
|
+
] })
|
|
83
|
+
] });
|
|
84
|
+
}
|
|
85
|
+
function PriceText({ order }) {
|
|
86
|
+
return /* @__PURE__ */ jsxs("p", { className: "text-sm font-semibold", children: [
|
|
87
|
+
formatDisplayPrice(order.price.formatted),
|
|
88
|
+
" ",
|
|
89
|
+
/* @__PURE__ */ jsx("span", { className: "text-xs font-normal text-muted-foreground", children: order.price.currency })
|
|
90
|
+
] });
|
|
91
|
+
}
|
|
92
|
+
function CounterOfferRow({ bid, actions }) {
|
|
93
|
+
const { counterOffers } = useCounterOffers({ originalOrderHash: bid.orderHash });
|
|
94
|
+
const counter = counterOffers[0];
|
|
95
|
+
if (!counter) return null;
|
|
96
|
+
const closed = counter.status !== "ACTIVE" || isExpired(counter.endTime);
|
|
97
|
+
return /* @__PURE__ */ jsx(
|
|
98
|
+
OrderRow,
|
|
99
|
+
{
|
|
100
|
+
order: counter,
|
|
101
|
+
subtitle: /* @__PURE__ */ jsxs(Badge, { variant: "secondary", className: "mt-0.5 h-4 px-1.5 text-[10px]", children: [
|
|
102
|
+
/* @__PURE__ */ jsx(ArrowLeftRight, { className: "mr-1 h-2.5 w-2.5" }),
|
|
103
|
+
"Counter-offer"
|
|
104
|
+
] }),
|
|
105
|
+
priceCell: /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-end gap-0.5", children: [
|
|
106
|
+
/* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground line-through", children: price(bid) }),
|
|
107
|
+
/* @__PURE__ */ jsx("p", { className: "text-sm font-semibold", children: counter.price.formatted ? price(counter) : "\u2014" })
|
|
108
|
+
] }),
|
|
109
|
+
actions: closed ? /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: counter.status !== "ACTIVE" ? counter.status.toLowerCase() : "Expired" }) : /* @__PURE__ */ jsx(Button, { size: "sm", className: "h-8 text-xs", disabled: actions.isProcessing, onClick: () => actions.accept?.(counter, bid), children: "Accept" })
|
|
110
|
+
}
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
function PortfolioOrders({ view, address, useActions }) {
|
|
114
|
+
const mine = useUserOrders(view === "received" ? null : address);
|
|
115
|
+
const received = useReceivedOffers(view === "received" ? address : null);
|
|
116
|
+
const source = view === "received" ? received : mine;
|
|
117
|
+
const actions = useActions({ view, refresh: () => void source.mutate() });
|
|
118
|
+
const config = VIEWS[view];
|
|
119
|
+
const orders = view === "listings" ? mine.orders.filter((o) => isNft(o) && o.status === "ACTIVE") : view === "offers" ? mine.orders.filter((o) => o.offer.itemType === "ERC20" && o.status === "ACTIVE") : view === "counter-offers" ? mine.orders.filter((o) => o.offer.itemType === "ERC20" && isSameAddress(o.offerer, address) && o.hasActiveCounterOffer === true) : received.orders;
|
|
120
|
+
const seen = view === "received" ? getSeenOffers() : null;
|
|
121
|
+
const EmptyIcon = config.emptyIcon;
|
|
122
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
123
|
+
/* @__PURE__ */ jsx(
|
|
124
|
+
EmptyOrError,
|
|
125
|
+
{
|
|
126
|
+
isLoading: source.isLoading,
|
|
127
|
+
error: source.error,
|
|
128
|
+
isEmpty: orders.length === 0,
|
|
129
|
+
onRetry: () => void source.mutate(),
|
|
130
|
+
emptyTitle: config.emptyTitle,
|
|
131
|
+
emptyDescription: config.emptyDescription,
|
|
132
|
+
emptyCta: config.emptyCta,
|
|
133
|
+
emptyIcon: /* @__PURE__ */ jsx(EmptyIcon, { className: "h-7 w-7 text-muted-foreground" }),
|
|
134
|
+
skeletonCount: 3,
|
|
135
|
+
children: /* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
|
|
136
|
+
config.count && orders.length > 0 && /* @__PURE__ */ jsx("p", { className: "pb-2 text-sm text-muted-foreground", children: config.count(orders.length) }),
|
|
137
|
+
/* @__PURE__ */ jsxs("div", { className: "overflow-hidden rounded-lg border border-border", children: [
|
|
138
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-4 border-b border-border bg-muted/30 px-4 py-2 text-xs uppercase tracking-wide text-muted-foreground", children: [
|
|
139
|
+
/* @__PURE__ */ jsx("div", { className: "w-12 shrink-0" }),
|
|
140
|
+
/* @__PURE__ */ jsx("div", { className: "flex-1", children: "Asset" }),
|
|
141
|
+
view === "received" && /* @__PURE__ */ jsx("div", { className: "hidden w-28 sm:block", children: "From" }),
|
|
142
|
+
/* @__PURE__ */ jsx("div", { className: cn("hidden text-right sm:block", view === "counter-offers" ? "w-40" : "w-24"), children: config.priceLabel }),
|
|
143
|
+
/* @__PURE__ */ jsx("div", { className: "hidden w-28 md:block", children: "Expires" }),
|
|
144
|
+
/* @__PURE__ */ jsx("div", { className: "w-24 text-right", children: "Actions" })
|
|
145
|
+
] }),
|
|
146
|
+
view === "counter-offers" ? orders.map((bid) => /* @__PURE__ */ jsx(CounterOfferRow, { bid, actions }, bid.orderHash)) : orders.map((order) => /* @__PURE__ */ jsx(
|
|
147
|
+
OrderRow,
|
|
148
|
+
{
|
|
149
|
+
order,
|
|
150
|
+
isNew: seen ? !seen.has(order.orderHash) : false,
|
|
151
|
+
from: view === "received" ? order.offerer : void 0,
|
|
152
|
+
subtitle: /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: view === "received" ? "Received offer" : view === "offers" ? "Offer" : "Active" }),
|
|
153
|
+
priceCell: /* @__PURE__ */ jsx(PriceText, { order }),
|
|
154
|
+
actions: view === "received" ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
155
|
+
/* @__PURE__ */ jsx(Button, { size: "sm", variant: "outline", className: "h-8 text-xs", disabled: actions.isProcessing, onClick: () => actions.counter?.(order), children: "Counter" }),
|
|
156
|
+
/* @__PURE__ */ jsx(Button, { size: "sm", className: "h-8 text-xs", disabled: actions.isProcessing, onClick: () => actions.accept?.(order), children: "Accept" })
|
|
157
|
+
] }) : /* @__PURE__ */ jsx(Button, { size: "sm", variant: "outline", className: "h-8 text-xs text-destructive hover:text-destructive", disabled: actions.isProcessing, onClick: () => actions.cancel?.(order), children: "Cancel" })
|
|
158
|
+
},
|
|
159
|
+
order.orderHash
|
|
160
|
+
))
|
|
161
|
+
] })
|
|
162
|
+
] })
|
|
163
|
+
}
|
|
164
|
+
),
|
|
165
|
+
actions.dialogs
|
|
166
|
+
] });
|
|
167
|
+
}
|
|
168
|
+
export {
|
|
169
|
+
PortfolioOrders
|
|
170
|
+
};
|
|
171
|
+
//# sourceMappingURL=portfolio-orders.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/portfolio-orders.tsx"],"sourcesContent":["\"use client\";\n\nimport type { ReactNode } from \"react\";\nimport { assetHref, profileHref, type ApiOrder } from \"@medialane/sdk\";\nimport { ArrowLeftRight, ExternalLink, HandCoins, Inbox, Tag } from \"lucide-react\";\nimport Image from \"./image.js\";\nimport Link from \"./link.js\";\nimport { Badge } from \"./badge.js\";\nimport { Button } from \"./button.js\";\nimport { EmptyOrError } from \"./empty-or-error.js\";\nimport { cn } from \"../utils/cn.js\";\nimport { EXPLORER_URL } from \"../utils/explorer-url.js\";\nimport { formatDisplayPrice } from \"../utils/format.js\";\nimport { isExpired, timeUntil } from \"../utils/time.js\";\nimport { isSameAddress } from \"../utils/same-address.js\";\nimport { getSeenOffers } from \"../utils/seen-offers.js\";\nimport { useImageUrl } from \"../utils/use-image-url.js\";\nimport { useCounterOffers, useReceivedOffers, useUserOrders } from \"../utils/use-orders.js\";\n\nexport type PortfolioOrdersView = \"listings\" | \"offers\" | \"received\" | \"counter-offers\";\n\nexport interface PortfolioOrderActions {\n isProcessing: boolean;\n cancel?: (order: ApiOrder) => void;\n accept?: (order: ApiOrder, original?: ApiOrder) => void;\n counter?: (order: ApiOrder) => void;\n dialogs?: ReactNode;\n}\n\nexport type UsePortfolioOrderActions = (context: { view: PortfolioOrdersView; refresh: () => void }) => PortfolioOrderActions;\n\nconst VIEWS = {\n listings: {\n emptyTitle: \"No active listings\",\n emptyDescription: \"List an asset to start selling.\",\n emptyCta: { label: \"Browse assets\", href: \"/portfolio/assets\" },\n emptyIcon: Tag,\n priceLabel: \"Price\",\n count: (n: number) => `${n} active listing${n === 1 ? \"\" : \"s\"}`,\n },\n offers: {\n emptyTitle: \"No offers sent yet\",\n emptyDescription: \"Browse the marketplace to make offers on assets.\",\n emptyCta: { label: \"Browse marketplace\", href: \"/marketplace\" },\n emptyIcon: HandCoins,\n priceLabel: \"Offer price\",\n count: (n: number) => `${n} active offer${n === 1 ? \"\" : \"s\"}`,\n },\n received: {\n emptyTitle: \"No offers received yet\",\n emptyDescription: \"When someone makes an offer on your asset, it will appear here.\",\n emptyCta: undefined,\n emptyIcon: Inbox,\n priceLabel: \"Offer price\",\n count: null,\n },\n \"counter-offers\": {\n emptyTitle: \"No counter-offers yet\",\n emptyDescription: \"When a seller responds to your bid with a counter-offer, it will appear here.\",\n emptyCta: undefined,\n emptyIcon: Inbox,\n priceLabel: \"Their price / Your bid\",\n count: null,\n },\n} as const;\n\nconst isNft = (o: ApiOrder) => o.offer.itemType === \"ERC721\" || o.offer.itemType === \"ERC1155\";\n\nfunction expiryOf(order: ApiOrder) {\n const expired = isExpired(order.endTime);\n const urgent = !expired && Number(order.endTime) * 1000 - Date.now() < 86400000;\n return { label: timeUntil(order.endTime), expired, urgent };\n}\n\nfunction price(o: ApiOrder) {\n return `${formatDisplayPrice(o.price.formatted)} ${o.price.currency ?? \"\"}`.trim();\n}\n\nfunction OrderRow({ order, subtitle, from, priceCell, actions, isNew }: {\n order: ApiOrder;\n subtitle: ReactNode;\n from?: string;\n priceCell: ReactNode;\n actions: ReactNode;\n isNew?: boolean;\n}) {\n const resolveImage = useImageUrl();\n const name = order.token?.name || `#${order.nftTokenId}`;\n const image = resolveImage(order.token?.image, { width: 96 });\n const expiry = expiryOf(order);\n return (\n <div data-new={isNew ? \"true\" : undefined} className={cn(\"flex items-center gap-4 px-4 py-3 transition-colors hover:bg-muted/40\", isNew && \"border-l-2 border-primary\")}>\n <div className=\"relative h-12 w-12 shrink-0 overflow-hidden rounded-lg border border-border bg-muted\">\n {image && <Image src={image} alt={name} fill sizes=\"48px\" unoptimized className=\"object-cover\" />}\n </div>\n <div className=\"min-w-0 flex-1\">\n <Link href={assetHref(\"STARKNET\", order.nftContract, order.nftTokenId)} className=\"block truncate text-sm font-medium transition-colors hover:text-primary\">\n {name}\n </Link>\n {subtitle}\n </div>\n {from && (\n <div className=\"hidden shrink-0 sm:block\">\n <Link href={profileHref({ address: from })} className=\"text-xs tabular-nums text-muted-foreground transition-colors hover:text-foreground\">\n {from.slice(0, 6)}…{from.slice(-4)}\n </Link>\n </div>\n )}\n <div className=\"hidden shrink-0 text-right sm:block\">{priceCell}</div>\n <div className=\"hidden shrink-0 md:block\">\n <p className={cn(\"text-sm\", expiry.expired && \"text-muted-foreground\", expiry.urgent && \"font-medium text-destructive\")}>{expiry.label}</p>\n </div>\n <div className=\"flex shrink-0 items-center gap-2\">\n {order.txHash?.created && (\n <a href={`${EXPLORER_URL}/tx/${order.txHash.created}`} target=\"_blank\" rel=\"noopener noreferrer\" aria-label=\"View on explorer\" className=\"inline-flex h-7 w-7 items-center justify-center rounded-md transition-colors hover:bg-muted\">\n <ExternalLink className=\"h-3.5 w-3.5 text-muted-foreground\" />\n </a>\n )}\n {actions}\n </div>\n </div>\n );\n}\n\nfunction PriceText({ order }: { order: ApiOrder }) {\n return (\n <p className=\"text-sm font-semibold\">\n {formatDisplayPrice(order.price.formatted)} <span className=\"text-xs font-normal text-muted-foreground\">{order.price.currency}</span>\n </p>\n );\n}\n\nfunction CounterOfferRow({ bid, actions }: { bid: ApiOrder; actions: PortfolioOrderActions }) {\n const { counterOffers } = useCounterOffers({ originalOrderHash: bid.orderHash });\n const counter = counterOffers[0];\n if (!counter) return null;\n const closed = counter.status !== \"ACTIVE\" || isExpired(counter.endTime);\n return (\n <OrderRow\n order={counter}\n subtitle={\n <Badge variant=\"secondary\" className=\"mt-0.5 h-4 px-1.5 text-[10px]\">\n <ArrowLeftRight className=\"mr-1 h-2.5 w-2.5\" />\n Counter-offer\n </Badge>\n }\n priceCell={\n <div className=\"flex flex-col items-end gap-0.5\">\n <p className=\"text-xs text-muted-foreground line-through\">{price(bid)}</p>\n <p className=\"text-sm font-semibold\">{counter.price.formatted ? price(counter) : \"—\"}</p>\n </div>\n }\n actions={\n closed ? (\n <span className=\"text-xs text-muted-foreground\">{counter.status !== \"ACTIVE\" ? counter.status.toLowerCase() : \"Expired\"}</span>\n ) : (\n <Button size=\"sm\" className=\"h-8 text-xs\" disabled={actions.isProcessing} onClick={() => actions.accept?.(counter, bid)}>\n Accept\n </Button>\n )\n }\n />\n );\n}\n\nexport function PortfolioOrders({ view, address, useActions }: {\n view: PortfolioOrdersView;\n address: string;\n useActions: UsePortfolioOrderActions;\n}) {\n const mine = useUserOrders(view === \"received\" ? null : address);\n const received = useReceivedOffers(view === \"received\" ? address : null);\n const source = view === \"received\" ? received : mine;\n const actions = useActions({ view, refresh: () => void source.mutate() });\n const config = VIEWS[view];\n\n const orders =\n view === \"listings\" ? mine.orders.filter((o) => isNft(o) && o.status === \"ACTIVE\")\n : view === \"offers\" ? mine.orders.filter((o) => o.offer.itemType === \"ERC20\" && o.status === \"ACTIVE\")\n : view === \"counter-offers\" ? mine.orders.filter((o) => o.offer.itemType === \"ERC20\" && isSameAddress(o.offerer, address) && o.hasActiveCounterOffer === true)\n : received.orders;\n\n const seen = view === \"received\" ? getSeenOffers() : null;\n const EmptyIcon = config.emptyIcon;\n\n return (\n <>\n <EmptyOrError\n isLoading={source.isLoading}\n error={source.error}\n isEmpty={orders.length === 0}\n onRetry={() => void source.mutate()}\n emptyTitle={config.emptyTitle}\n emptyDescription={config.emptyDescription}\n emptyCta={config.emptyCta}\n emptyIcon={<EmptyIcon className=\"h-7 w-7 text-muted-foreground\" />}\n skeletonCount={3}\n >\n <div className=\"space-y-1\">\n {config.count && orders.length > 0 && <p className=\"pb-2 text-sm text-muted-foreground\">{config.count(orders.length)}</p>}\n <div className=\"overflow-hidden rounded-lg border border-border\">\n <div className=\"flex items-center gap-4 border-b border-border bg-muted/30 px-4 py-2 text-xs uppercase tracking-wide text-muted-foreground\">\n <div className=\"w-12 shrink-0\" />\n <div className=\"flex-1\">Asset</div>\n {view === \"received\" && <div className=\"hidden w-28 sm:block\">From</div>}\n <div className={cn(\"hidden text-right sm:block\", view === \"counter-offers\" ? \"w-40\" : \"w-24\")}>{config.priceLabel}</div>\n <div className=\"hidden w-28 md:block\">Expires</div>\n <div className=\"w-24 text-right\">Actions</div>\n </div>\n {view === \"counter-offers\"\n ? orders.map((bid) => <CounterOfferRow key={bid.orderHash} bid={bid} actions={actions} />)\n : orders.map((order) => (\n <OrderRow\n key={order.orderHash}\n order={order}\n isNew={seen ? !seen.has(order.orderHash) : false}\n from={view === \"received\" ? order.offerer : undefined}\n subtitle={<span className=\"text-xs text-muted-foreground\">{view === \"received\" ? \"Received offer\" : view === \"offers\" ? \"Offer\" : \"Active\"}</span>}\n priceCell={<PriceText order={order} />}\n actions={\n view === \"received\" ? (\n <>\n <Button size=\"sm\" variant=\"outline\" className=\"h-8 text-xs\" disabled={actions.isProcessing} onClick={() => actions.counter?.(order)}>Counter</Button>\n <Button size=\"sm\" className=\"h-8 text-xs\" disabled={actions.isProcessing} onClick={() => actions.accept?.(order)}>Accept</Button>\n </>\n ) : (\n <Button size=\"sm\" variant=\"outline\" className=\"h-8 text-xs text-destructive hover:text-destructive\" disabled={actions.isProcessing} onClick={() => actions.cancel?.(order)}>Cancel</Button>\n )\n }\n />\n ))}\n </div>\n </div>\n </EmptyOrError>\n {actions.dialogs}\n </>\n );\n}\n"],"mappings":";AA6FkB,SAgIM,UAhIN,KAEZ,YAFY;AA1FlB,SAAS,WAAW,mBAAkC;AACtD,SAAS,gBAAgB,cAAc,WAAW,OAAO,WAAW;AACpE,OAAO,WAAW;AAClB,OAAO,UAAU;AACjB,SAAS,aAAa;AACtB,SAAS,cAAc;AACvB,SAAS,oBAAoB;AAC7B,SAAS,UAAU;AACnB,SAAS,oBAAoB;AAC7B,SAAS,0BAA0B;AACnC,SAAS,WAAW,iBAAiB;AACrC,SAAS,qBAAqB;AAC9B,SAAS,qBAAqB;AAC9B,SAAS,mBAAmB;AAC5B,SAAS,kBAAkB,mBAAmB,qBAAqB;AAcnE,MAAM,QAAQ;AAAA,EACZ,UAAU;AAAA,IACR,YAAY;AAAA,IACZ,kBAAkB;AAAA,IAClB,UAAU,EAAE,OAAO,iBAAiB,MAAM,oBAAoB;AAAA,IAC9D,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,OAAO,CAAC,MAAc,GAAG,CAAC,kBAAkB,MAAM,IAAI,KAAK,GAAG;AAAA,EAChE;AAAA,EACA,QAAQ;AAAA,IACN,YAAY;AAAA,IACZ,kBAAkB;AAAA,IAClB,UAAU,EAAE,OAAO,sBAAsB,MAAM,eAAe;AAAA,IAC9D,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,OAAO,CAAC,MAAc,GAAG,CAAC,gBAAgB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gBACpC,SACE,SAAS,aACP,iCACE;AAAA,sCAAC,UAAO,MAAK,MAAK,SAAQ,WAAU,WAAU,eAAc,UAAU,QAAQ,cAAc,SAAS,MAAM,QAAQ,UAAU,KAAK,GAAG,qBAAO;AAAA,kBAC5I,oBAAC,UAAO,MAAK,MAAK,WAAU,eAAc,UAAU,QAAQ,cAAc,SAAS,MAAM,QAAQ,SAAS,KAAK,GAAG,oBAAM;AAAA,mBAC1H,IAEA,oBAAC,UAAO,MAAK,MAAK,SAAQ,WAAU,WAAU,uDAAsD,UAAU,QAAQ,cAAc,SAAS,MAAM,QAAQ,SAAS,KAAK,GAAG,oBAAM;AAAA;AAAA,cAbjL,MAAM;AAAA,YAgBb,CACD;AAAA,aACP;AAAA,WACF;AAAA;AAAA,IACF;AAAA,IACC,QAAQ;AAAA,KACX;AAEJ;","names":[]}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
var portfolio_shell_exports = {};
|
|
21
|
+
__export(portfolio_shell_exports, {
|
|
22
|
+
PORTFOLIO_TABS: () => PORTFOLIO_TABS,
|
|
23
|
+
PortfolioShell: () => PortfolioShell
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(portfolio_shell_exports);
|
|
26
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
27
|
+
var import_react = require("react");
|
|
28
|
+
var import_lucide_react = require("lucide-react");
|
|
29
|
+
var import_router = require("./router.js");
|
|
30
|
+
var import_button = require("./button.js");
|
|
31
|
+
var import_skeleton = require("./skeleton.js");
|
|
32
|
+
var import_portfolio_header = require("./portfolio-header.js");
|
|
33
|
+
var import_portfolio_chip_filter = require("./portfolio-chip-filter.js");
|
|
34
|
+
var import_medialane_app = require("./medialane-app.js");
|
|
35
|
+
var import_portfolio_counts = require("../utils/portfolio-counts.js");
|
|
36
|
+
var import_seen_offers = require("../utils/seen-offers.js");
|
|
37
|
+
var import_use_orders = require("../utils/use-orders.js");
|
|
38
|
+
var import_use_rewards = require("../utils/use-rewards.js");
|
|
39
|
+
var import_use_sponsorship = require("../utils/use-sponsorship.js");
|
|
40
|
+
const PORTFOLIO_TABS = [
|
|
41
|
+
{ key: "assets", label: "Assets", href: "/portfolio/assets" },
|
|
42
|
+
{ key: "collections", label: "Collections", href: "/portfolio/collections" },
|
|
43
|
+
{ key: "listings", label: "Listings", href: "/portfolio/listings" },
|
|
44
|
+
{ key: "received", label: "Offers received", href: "/portfolio/received" },
|
|
45
|
+
{ key: "offers", label: "Offers sent", href: "/portfolio/offers" },
|
|
46
|
+
{ key: "counter", label: "Counter-offers", href: "/portfolio/counter-offers" },
|
|
47
|
+
{ key: "licensing", label: "Licensing", href: "/portfolio/licensing" },
|
|
48
|
+
{ key: "sponsorship", label: "Sponsorships", href: "/portfolio/sponsorships" },
|
|
49
|
+
{ key: "activity", label: "Activity", href: "/portfolio/activity" }
|
|
50
|
+
];
|
|
51
|
+
function SignedOut() {
|
|
52
|
+
const { onRequireWallet, connectLabel } = (0, import_medialane_app.useMedialaneApp)();
|
|
53
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "mx-auto max-w-lg space-y-4 px-4 pt-24 pb-8 text-center", children: [
|
|
54
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.Wallet, { className: "mx-auto h-10 w-10 text-muted-foreground" }),
|
|
55
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h1", { className: "text-2xl font-bold", children: "Your portfolio" }),
|
|
56
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "text-muted-foreground", children: "Sign in to see your assets, listings and offers." }),
|
|
57
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_button.Button, { size: "lg", className: "rounded-full px-7", onClick: onRequireWallet, children: connectLabel ?? "Sign in" })
|
|
58
|
+
] });
|
|
59
|
+
}
|
|
60
|
+
function Loading() {
|
|
61
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "mx-auto max-w-lg space-y-4 px-4 pt-24 pb-8", children: [
|
|
62
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_skeleton.Skeleton, { className: "mx-auto h-10 w-10 rounded-full" }),
|
|
63
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_skeleton.Skeleton, { className: "mx-auto h-7 w-56" }),
|
|
64
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_skeleton.Skeleton, { className: "mx-auto h-4 w-72" })
|
|
65
|
+
] });
|
|
66
|
+
}
|
|
67
|
+
function PortfolioShell({ tabs = PORTFOLIO_TABS, remixOffers, children }) {
|
|
68
|
+
const { walletAddress: address, walletLoading } = (0, import_medialane_app.useMedialaneApp)();
|
|
69
|
+
const pathname = (0, import_router.usePathname)();
|
|
70
|
+
const { orders } = (0, import_use_orders.useUserOrders)(address);
|
|
71
|
+
const { orders: receivedOffers } = (0, import_use_orders.useReceivedOffers)(address);
|
|
72
|
+
const { data: rewards } = (0, import_use_rewards.useRewards)(address);
|
|
73
|
+
const { pendingCount } = (0, import_use_sponsorship.useMySponsorshipDealCounts)(address);
|
|
74
|
+
(0, import_react.useEffect)(() => {
|
|
75
|
+
if (receivedOffers.length > 0) (0, import_seen_offers.markOffersAsSeen)(receivedOffers.map((o) => o.orderHash));
|
|
76
|
+
}, [receivedOffers]);
|
|
77
|
+
if (!address) return walletLoading ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Loading, {}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SignedOut, {});
|
|
78
|
+
const counts = (0, import_portfolio_counts.derivePortfolioCounts)({ orders, receivedOffers, remixOffers, address, sponsorshipPendingCount: pendingCount });
|
|
79
|
+
const countFor = { received: counts.received, counter: counts.counter, licensing: counts.remix, sponsorship: counts.sponsorships };
|
|
80
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "space-y-6 px-4 pt-20 pb-8 sm:px-6 lg:px-8", children: [
|
|
81
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
82
|
+
import_portfolio_header.PortfolioHeader,
|
|
83
|
+
{
|
|
84
|
+
address,
|
|
85
|
+
score: rewards ? { levelName: rewards.currentLevelName, totalXp: rewards.totalXp, href: "/rewards" } : null
|
|
86
|
+
}
|
|
87
|
+
),
|
|
88
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
89
|
+
import_portfolio_chip_filter.PortfolioChipFilter,
|
|
90
|
+
{
|
|
91
|
+
options: tabs.map((t) => ({ key: t.key, href: t.href, label: countFor[t.key] ? `${t.label} (${countFor[t.key]})` : t.label })),
|
|
92
|
+
value: pathname ?? "",
|
|
93
|
+
onChange: () => {
|
|
94
|
+
},
|
|
95
|
+
showAll: false
|
|
96
|
+
}
|
|
97
|
+
),
|
|
98
|
+
children
|
|
99
|
+
] });
|
|
100
|
+
}
|
|
101
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
102
|
+
0 && (module.exports = {
|
|
103
|
+
PORTFOLIO_TABS,
|
|
104
|
+
PortfolioShell
|
|
105
|
+
});
|
|
106
|
+
//# sourceMappingURL=portfolio-shell.cjs.map
|