@medialane/ui 0.245.0 → 0.246.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/pop-burn-button.cjs +65 -0
- package/dist/components/pop-burn-button.cjs.map +1 -0
- package/dist/components/pop-burn-button.d.cts +10 -0
- package/dist/components/pop-burn-button.d.ts +10 -0
- package/dist/components/pop-burn-button.js +41 -0
- package/dist/components/pop-burn-button.js.map +1 -0
- package/dist/components/pop-claim-button.cjs +92 -0
- package/dist/components/pop-claim-button.cjs.map +1 -0
- package/dist/components/pop-claim-button.d.cts +7 -0
- package/dist/components/pop-claim-button.d.ts +7 -0
- package/dist/components/pop-claim-button.js +68 -0
- package/dist/components/pop-claim-button.js.map +1 -0
- package/dist/components/portfolio-sponsorships.cjs +209 -0
- package/dist/components/portfolio-sponsorships.cjs.map +1 -0
- package/dist/components/portfolio-sponsorships.d.cts +5 -0
- package/dist/components/portfolio-sponsorships.d.ts +5 -0
- package/dist/components/portfolio-sponsorships.js +175 -0
- package/dist/components/portfolio-sponsorships.js.map +1 -0
- package/dist/components/sponsorship-offer-page.cjs +181 -0
- package/dist/components/sponsorship-offer-page.cjs.map +1 -0
- package/dist/components/sponsorship-offer-page.d.cts +7 -0
- package/dist/components/sponsorship-offer-page.d.ts +7 -0
- package/dist/components/sponsorship-offer-page.js +147 -0
- package/dist/components/sponsorship-offer-page.js.map +1 -0
- package/dist/components/sponsorship-offers-page.cjs +118 -0
- package/dist/components/sponsorship-offers-page.cjs.map +1 -0
- package/dist/components/sponsorship-offers-page.d.cts +5 -0
- package/dist/components/sponsorship-offers-page.d.ts +5 -0
- package/dist/components/sponsorship-offers-page.js +84 -0
- package/dist/components/sponsorship-offers-page.js.map +1 -0
- package/dist/components/transaction-done.cjs +46 -0
- package/dist/components/transaction-done.cjs.map +1 -0
- package/dist/components/transaction-done.d.cts +18 -0
- package/dist/components/transaction-done.d.ts +18 -0
- package/dist/components/transaction-done.js +22 -0
- package/dist/components/transaction-done.js.map +1 -0
- package/dist/index.cjs +18 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
import { CheckCircle2, Handshake, Loader2, X } from "lucide-react";
|
|
5
|
+
import { assetHref } from "@medialane/sdk";
|
|
6
|
+
import { AddressDisplay } from "./address-display.js";
|
|
7
|
+
import { Button } from "./button.js";
|
|
8
|
+
import Link from "./link.js";
|
|
9
|
+
import { useMedialaneApp } from "./medialane-app.js";
|
|
10
|
+
import { Skeleton } from "./skeleton.js";
|
|
11
|
+
import { TransactionDialog } from "./transaction-dialog.js";
|
|
12
|
+
import { TransactionDone } from "./transaction-done.js";
|
|
13
|
+
import { runIntentCalls } from "../utils/run-intent-calls.js";
|
|
14
|
+
import { useSponsorshipBids, useSponsorshipLicenses, useSponsorshipOffers, useSponsorshipProposals } from "../utils/use-sponsorship.js";
|
|
15
|
+
import { useTransaction } from "../utils/use-transaction.js";
|
|
16
|
+
function useRowAction(copy) {
|
|
17
|
+
const app = useMedialaneApp();
|
|
18
|
+
const tx = useTransaction();
|
|
19
|
+
const [activeId, setActiveId] = useState(null);
|
|
20
|
+
const busy = tx.phase === "preparing" || tx.phase === "submitting" || tx.phase === "confirming";
|
|
21
|
+
const run = (id, create, then) => {
|
|
22
|
+
setActiveId(id);
|
|
23
|
+
void tx.run(async (signer) => {
|
|
24
|
+
await runIntentCalls(signer, () => create(app.getClient().api));
|
|
25
|
+
}).then(() => then()).finally(() => setActiveId(null));
|
|
26
|
+
};
|
|
27
|
+
const dialog = /* @__PURE__ */ jsx(TransactionDialog, { tx, title: copy.title, workingLabel: copy.working, firstStepLabel: "Prepare", children: /* @__PURE__ */ jsx(TransactionDone, { tx, name: copy.title, title: copy.done, description: copy.description }) });
|
|
28
|
+
return { run, dialog, busy, activeId };
|
|
29
|
+
}
|
|
30
|
+
function Spinner({ active, idle, className }) {
|
|
31
|
+
return active ? /* @__PURE__ */ jsx(Loader2, { className: `h-3 w-3 animate-spin ${className ?? ""}` }) : /* @__PURE__ */ jsx(Fragment, { children: idle });
|
|
32
|
+
}
|
|
33
|
+
function OfferBidsRow({ offer }) {
|
|
34
|
+
const { walletAddress } = useMedialaneApp();
|
|
35
|
+
const { bids, isLoading, mutate } = useSponsorshipBids(offer.offerId);
|
|
36
|
+
const action = useRowAction({ title: "Accept bid", working: "Accepting the bid\u2026", done: "Bid accepted!", description: "The license is minted to the sponsor." });
|
|
37
|
+
if (isLoading || bids.length === 0) return null;
|
|
38
|
+
return /* @__PURE__ */ jsxs("div", { className: "space-y-1.5 rounded-lg bg-muted/30 p-3", children: [
|
|
39
|
+
action.dialog,
|
|
40
|
+
/* @__PURE__ */ jsxs("p", { className: "text-xs font-semibold text-muted-foreground", children: [
|
|
41
|
+
"Bids on ",
|
|
42
|
+
/* @__PURE__ */ jsx(Link, { href: assetHref("STARKNET", offer.nftContract, offer.tokenId), className: "underline underline-offset-2", children: "View asset" })
|
|
43
|
+
] }),
|
|
44
|
+
bids.map((bid) => /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-2 text-xs", children: [
|
|
45
|
+
/* @__PURE__ */ jsx(AddressDisplay, { address: bid.sponsor, chars: 4, showCopy: false, className: "text-muted-foreground" }),
|
|
46
|
+
/* @__PURE__ */ jsx(
|
|
47
|
+
Button,
|
|
48
|
+
{
|
|
49
|
+
size: "sm",
|
|
50
|
+
className: "bg-brand-rose hover:brightness-110 text-white h-7 px-2.5",
|
|
51
|
+
"aria-label": "Accept bid",
|
|
52
|
+
disabled: action.busy || !walletAddress,
|
|
53
|
+
onClick: () => action.run(
|
|
54
|
+
bid.id,
|
|
55
|
+
(api) => api.intents.create("sponsorship-bid-accept", { author: walletAddress, offerId: offer.offerId, sponsor: bid.sponsor }),
|
|
56
|
+
() => mutate()
|
|
57
|
+
),
|
|
58
|
+
children: /* @__PURE__ */ jsx(Spinner, { active: action.busy && action.activeId === bid.id, idle: /* @__PURE__ */ jsx(CheckCircle2, { className: "h-3 w-3" }) })
|
|
59
|
+
}
|
|
60
|
+
)
|
|
61
|
+
] }, bid.id))
|
|
62
|
+
] });
|
|
63
|
+
}
|
|
64
|
+
function ReceivedProposals({ walletAddress }) {
|
|
65
|
+
const { proposals, isLoading, mutate } = useSponsorshipProposals({ owner: walletAddress, open: true });
|
|
66
|
+
const action = useRowAction({ title: "Respond to proposal", working: "Sending your response\u2026", done: "Response sent!", description: "Your response is now on-chain." });
|
|
67
|
+
if (isLoading) return /* @__PURE__ */ jsx(Skeleton, { className: "h-20 w-full rounded-xl" });
|
|
68
|
+
if (proposals.length === 0) return /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: "No proposals awaiting your decision." });
|
|
69
|
+
const respond = (proposalId, decision) => action.run(
|
|
70
|
+
proposalId,
|
|
71
|
+
(api) => decision === "accept" ? api.intents.create("sponsorship-proposal-accept", { owner: walletAddress, proposalId }) : api.intents.create("sponsorship-proposal-reject", { owner: walletAddress, proposalId }),
|
|
72
|
+
() => mutate()
|
|
73
|
+
);
|
|
74
|
+
return /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
|
|
75
|
+
action.dialog,
|
|
76
|
+
proposals.map((p) => /* @__PURE__ */ jsxs("div", { className: "bento-cell p-4 flex items-center justify-between gap-3", children: [
|
|
77
|
+
/* @__PURE__ */ jsxs("div", { className: "min-w-0", children: [
|
|
78
|
+
/* @__PURE__ */ jsx("p", { className: "text-sm font-semibold", children: /* @__PURE__ */ jsx(Link, { href: assetHref("STARKNET", p.nftContract, p.tokenId), className: "hover:underline", children: "View asset" }) }),
|
|
79
|
+
/* @__PURE__ */ jsxs("p", { className: "text-xs text-muted-foreground", children: [
|
|
80
|
+
/* @__PURE__ */ jsx(AddressDisplay, { address: p.proposer, chars: 4, showCopy: false }),
|
|
81
|
+
" proposed ",
|
|
82
|
+
p.amount
|
|
83
|
+
] })
|
|
84
|
+
] }),
|
|
85
|
+
/* @__PURE__ */ jsxs("div", { className: "flex gap-1.5 shrink-0", children: [
|
|
86
|
+
/* @__PURE__ */ jsx(Button, { size: "sm", variant: "outline", "aria-label": "Decline proposal", disabled: action.busy, onClick: () => respond(p.proposalId, "reject"), children: /* @__PURE__ */ jsx(Spinner, { active: action.busy && action.activeId === p.proposalId, idle: /* @__PURE__ */ jsx(X, { className: "h-3 w-3" }) }) }),
|
|
87
|
+
/* @__PURE__ */ jsx(Button, { size: "sm", className: "bg-brand-rose hover:brightness-110 text-white", "aria-label": "Accept proposal", disabled: action.busy, onClick: () => respond(p.proposalId, "accept"), children: /* @__PURE__ */ jsx(Spinner, { active: action.busy && action.activeId === p.proposalId, idle: /* @__PURE__ */ jsx(CheckCircle2, { className: "h-3 w-3" }) }) })
|
|
88
|
+
] })
|
|
89
|
+
] }, p.id))
|
|
90
|
+
] });
|
|
91
|
+
}
|
|
92
|
+
function SentProposals({ walletAddress }) {
|
|
93
|
+
const { proposals, isLoading, mutate } = useSponsorshipProposals({ proposer: walletAddress, open: true });
|
|
94
|
+
const action = useRowAction({ title: "Withdraw proposal", working: "Withdrawing your proposal\u2026", done: "Proposal withdrawn!", description: "Your proposal is no longer open." });
|
|
95
|
+
if (isLoading) return /* @__PURE__ */ jsx(Skeleton, { className: "h-20 w-full rounded-xl" });
|
|
96
|
+
if (proposals.length === 0) return /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: "No pending proposals sent." });
|
|
97
|
+
return /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
|
|
98
|
+
action.dialog,
|
|
99
|
+
proposals.map((p) => /* @__PURE__ */ jsxs("div", { className: "bento-cell p-4 flex items-center justify-between gap-3", children: [
|
|
100
|
+
/* @__PURE__ */ jsxs("div", { className: "min-w-0", children: [
|
|
101
|
+
/* @__PURE__ */ jsx("p", { className: "text-sm font-semibold", children: /* @__PURE__ */ jsx(Link, { href: assetHref("STARKNET", p.nftContract, p.tokenId), className: "hover:underline", children: "View asset" }) }),
|
|
102
|
+
/* @__PURE__ */ jsxs("p", { className: "text-xs text-muted-foreground", children: [
|
|
103
|
+
"You proposed ",
|
|
104
|
+
p.amount
|
|
105
|
+
] })
|
|
106
|
+
] }),
|
|
107
|
+
/* @__PURE__ */ jsxs(
|
|
108
|
+
Button,
|
|
109
|
+
{
|
|
110
|
+
size: "sm",
|
|
111
|
+
variant: "outline",
|
|
112
|
+
disabled: action.busy,
|
|
113
|
+
onClick: () => action.run(p.proposalId, (api) => api.intents.create("sponsorship-proposal-withdraw", { proposer: walletAddress, proposalId: p.proposalId }), () => mutate()),
|
|
114
|
+
children: [
|
|
115
|
+
/* @__PURE__ */ jsx(Spinner, { active: action.busy && action.activeId === p.proposalId, idle: null, className: "mr-1.5" }),
|
|
116
|
+
"Withdraw"
|
|
117
|
+
]
|
|
118
|
+
}
|
|
119
|
+
)
|
|
120
|
+
] }, p.id))
|
|
121
|
+
] });
|
|
122
|
+
}
|
|
123
|
+
function LicenseList({ loading, empty, children }) {
|
|
124
|
+
if (loading) return /* @__PURE__ */ jsx(Skeleton, { className: "h-16 w-full rounded-xl" });
|
|
125
|
+
if (children.length === 0) return /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: empty });
|
|
126
|
+
return /* @__PURE__ */ jsx("div", { className: "space-y-2", children });
|
|
127
|
+
}
|
|
128
|
+
function PortfolioSponsorships() {
|
|
129
|
+
const { walletAddress } = useMedialaneApp();
|
|
130
|
+
const { offers } = useSponsorshipOffers(walletAddress ? { author: walletAddress, open: true } : void 0);
|
|
131
|
+
const { licenses: held, isLoading: heldLoading } = useSponsorshipLicenses(walletAddress ? { holder: walletAddress } : void 0);
|
|
132
|
+
const { licenses: issued, isLoading: issuedLoading } = useSponsorshipLicenses(walletAddress ? { author: walletAddress } : void 0);
|
|
133
|
+
if (!walletAddress) return null;
|
|
134
|
+
return /* @__PURE__ */ jsxs("div", { className: "space-y-8", children: [
|
|
135
|
+
/* @__PURE__ */ jsxs("section", { className: "space-y-3", children: [
|
|
136
|
+
/* @__PURE__ */ jsxs("h2", { className: "text-sm font-bold flex items-center gap-2", children: [
|
|
137
|
+
/* @__PURE__ */ jsx(Handshake, { className: "h-4 w-4 text-brand-rose" }),
|
|
138
|
+
"Proposals awaiting your decision"
|
|
139
|
+
] }),
|
|
140
|
+
/* @__PURE__ */ jsx(ReceivedProposals, { walletAddress })
|
|
141
|
+
] }),
|
|
142
|
+
offers.length > 0 && /* @__PURE__ */ jsxs("section", { className: "space-y-3", children: [
|
|
143
|
+
/* @__PURE__ */ jsx("h2", { className: "text-sm font-bold", children: "Bids on your offers" }),
|
|
144
|
+
/* @__PURE__ */ jsx("div", { className: "space-y-2", children: offers.map((o) => /* @__PURE__ */ jsx(OfferBidsRow, { offer: o }, o.id)) })
|
|
145
|
+
] }),
|
|
146
|
+
/* @__PURE__ */ jsxs("section", { className: "space-y-3", children: [
|
|
147
|
+
/* @__PURE__ */ jsx("h2", { className: "text-sm font-bold", children: "Proposals you've sent" }),
|
|
148
|
+
/* @__PURE__ */ jsx(SentProposals, { walletAddress })
|
|
149
|
+
] }),
|
|
150
|
+
/* @__PURE__ */ jsxs("section", { className: "space-y-3", children: [
|
|
151
|
+
/* @__PURE__ */ jsx("h2", { className: "text-sm font-bold", children: "Licenses you hold" }),
|
|
152
|
+
/* @__PURE__ */ jsx(LicenseList, { loading: heldLoading, empty: "No sponsorship licenses yet.", children: held.map((l) => /* @__PURE__ */ jsxs("div", { className: "bento-cell p-4", children: [
|
|
153
|
+
/* @__PURE__ */ jsx("p", { className: "text-sm font-semibold", children: /* @__PURE__ */ jsx(Link, { href: assetHref("STARKNET", l.assetContract, l.assetTokenId), className: "hover:underline", children: "License on this asset" }) }),
|
|
154
|
+
/* @__PURE__ */ jsxs("p", { className: "text-xs text-muted-foreground", children: [
|
|
155
|
+
"from ",
|
|
156
|
+
/* @__PURE__ */ jsx(AddressDisplay, { address: l.author, chars: 4, showCopy: false })
|
|
157
|
+
] })
|
|
158
|
+
] }, l.id)) })
|
|
159
|
+
] }),
|
|
160
|
+
/* @__PURE__ */ jsxs("section", { className: "space-y-3", children: [
|
|
161
|
+
/* @__PURE__ */ jsx("h2", { className: "text-sm font-bold", children: "Licenses issued on your work" }),
|
|
162
|
+
/* @__PURE__ */ jsx(LicenseList, { loading: issuedLoading, empty: "No licenses issued yet.", children: issued.map((l) => /* @__PURE__ */ jsxs("div", { className: "bento-cell p-4", children: [
|
|
163
|
+
/* @__PURE__ */ jsx("p", { className: "text-sm font-semibold", children: /* @__PURE__ */ jsx(Link, { href: assetHref("STARKNET", l.assetContract, l.assetTokenId), className: "hover:underline", children: "License on this asset" }) }),
|
|
164
|
+
/* @__PURE__ */ jsxs("p", { className: "text-xs text-muted-foreground", children: [
|
|
165
|
+
"held by ",
|
|
166
|
+
/* @__PURE__ */ jsx(AddressDisplay, { address: l.currentHolder ?? l.recipient, chars: 4, showCopy: false })
|
|
167
|
+
] })
|
|
168
|
+
] }, l.id)) })
|
|
169
|
+
] })
|
|
170
|
+
] });
|
|
171
|
+
}
|
|
172
|
+
export {
|
|
173
|
+
PortfolioSponsorships
|
|
174
|
+
};
|
|
175
|
+
//# sourceMappingURL=portfolio-sponsorships.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/portfolio-sponsorships.tsx"],"sourcesContent":["\"use client\";\n\nimport { useState } from \"react\";\nimport { CheckCircle2, Handshake, Loader2, X } from \"lucide-react\";\nimport { assetHref, type ApiSponsorshipOffer } from \"@medialane/sdk\";\nimport { AddressDisplay } from \"./address-display.js\";\nimport { Button } from \"./button.js\";\nimport Link from \"./link.js\";\nimport { useMedialaneApp } from \"./medialane-app.js\";\nimport { Skeleton } from \"./skeleton.js\";\nimport { TransactionDialog } from \"./transaction-dialog.js\";\nimport { TransactionDone } from \"./transaction-done.js\";\nimport { runIntentCalls } from \"../utils/run-intent-calls.js\";\nimport { useSponsorshipBids, useSponsorshipLicenses, useSponsorshipOffers, useSponsorshipProposals } from \"../utils/use-sponsorship.js\";\nimport { useTransaction } from \"../utils/use-transaction.js\";\n\ntype Api = ReturnType<ReturnType<typeof useMedialaneApp>[\"getClient\"]>[\"api\"];\n\nfunction useRowAction(copy: { title: string; working: string; done: string; description: string }) {\n const app = useMedialaneApp();\n const tx = useTransaction();\n const [activeId, setActiveId] = useState<string | null>(null);\n const busy = tx.phase === \"preparing\" || tx.phase === \"submitting\" || tx.phase === \"confirming\";\n\n const run = (id: string, create: (api: Api) => ReturnType<Parameters<typeof runIntentCalls>[1]>, then: () => Promise<unknown>) => {\n setActiveId(id);\n void tx\n .run(async (signer) => {\n await runIntentCalls(signer, () => create(app.getClient().api));\n })\n .then(() => then())\n .finally(() => setActiveId(null));\n };\n\n const dialog = (\n <TransactionDialog tx={tx} title={copy.title} workingLabel={copy.working} firstStepLabel=\"Prepare\">\n <TransactionDone tx={tx} name={copy.title} title={copy.done} description={copy.description} />\n </TransactionDialog>\n );\n\n return { run, dialog, busy, activeId };\n}\n\nfunction Spinner({ active, idle, className }: { active: boolean; idle: React.ReactNode; className?: string }) {\n return active ? <Loader2 className={`h-3 w-3 animate-spin ${className ?? \"\"}`} /> : <>{idle}</>;\n}\n\nfunction OfferBidsRow({ offer }: { offer: ApiSponsorshipOffer }) {\n const { walletAddress } = useMedialaneApp();\n const { bids, isLoading, mutate } = useSponsorshipBids(offer.offerId);\n const action = useRowAction({ title: \"Accept bid\", working: \"Accepting the bid…\", done: \"Bid accepted!\", description: \"The license is minted to the sponsor.\" });\n\n if (isLoading || bids.length === 0) return null;\n\n return (\n <div className=\"space-y-1.5 rounded-lg bg-muted/30 p-3\">\n {action.dialog}\n <p className=\"text-xs font-semibold text-muted-foreground\">\n Bids on <Link href={assetHref(\"STARKNET\", offer.nftContract, offer.tokenId)} className=\"underline underline-offset-2\">View asset</Link>\n </p>\n {bids.map((bid) => (\n <div key={bid.id} className=\"flex items-center justify-between gap-2 text-xs\">\n <AddressDisplay address={bid.sponsor} chars={4} showCopy={false} className=\"text-muted-foreground\" />\n <Button\n size=\"sm\"\n className=\"bg-brand-rose hover:brightness-110 text-white h-7 px-2.5\"\n aria-label=\"Accept bid\"\n disabled={action.busy || !walletAddress}\n onClick={() =>\n action.run(\n bid.id,\n (api) => api.intents.create(\"sponsorship-bid-accept\", { author: walletAddress!, offerId: offer.offerId, sponsor: bid.sponsor }),\n () => mutate(),\n )\n }\n >\n <Spinner active={action.busy && action.activeId === bid.id} idle={<CheckCircle2 className=\"h-3 w-3\" />} />\n </Button>\n </div>\n ))}\n </div>\n );\n}\n\nfunction ReceivedProposals({ walletAddress }: { walletAddress: string }) {\n const { proposals, isLoading, mutate } = useSponsorshipProposals({ owner: walletAddress, open: true });\n const action = useRowAction({ title: \"Respond to proposal\", working: \"Sending your response…\", done: \"Response sent!\", description: \"Your response is now on-chain.\" });\n\n if (isLoading) return <Skeleton className=\"h-20 w-full rounded-xl\" />;\n if (proposals.length === 0) return <p className=\"text-sm text-muted-foreground\">No proposals awaiting your decision.</p>;\n\n const respond = (proposalId: string, decision: \"accept\" | \"reject\") =>\n action.run(\n proposalId,\n (api) =>\n decision === \"accept\"\n ? api.intents.create(\"sponsorship-proposal-accept\", { owner: walletAddress, proposalId })\n : api.intents.create(\"sponsorship-proposal-reject\", { owner: walletAddress, proposalId }),\n () => mutate(),\n );\n\n return (\n <div className=\"space-y-2\">\n {action.dialog}\n {proposals.map((p) => (\n <div key={p.id} className=\"bento-cell p-4 flex items-center justify-between gap-3\">\n <div className=\"min-w-0\">\n <p className=\"text-sm font-semibold\">\n <Link href={assetHref(\"STARKNET\", p.nftContract, p.tokenId)} className=\"hover:underline\">View asset</Link>\n </p>\n <p className=\"text-xs text-muted-foreground\">\n <AddressDisplay address={p.proposer} chars={4} showCopy={false} /> proposed {p.amount}\n </p>\n </div>\n <div className=\"flex gap-1.5 shrink-0\">\n <Button size=\"sm\" variant=\"outline\" aria-label=\"Decline proposal\" disabled={action.busy} onClick={() => respond(p.proposalId, \"reject\")}>\n <Spinner active={action.busy && action.activeId === p.proposalId} idle={<X className=\"h-3 w-3\" />} />\n </Button>\n <Button size=\"sm\" className=\"bg-brand-rose hover:brightness-110 text-white\" aria-label=\"Accept proposal\" disabled={action.busy} onClick={() => respond(p.proposalId, \"accept\")}>\n <Spinner active={action.busy && action.activeId === p.proposalId} idle={<CheckCircle2 className=\"h-3 w-3\" />} />\n </Button>\n </div>\n </div>\n ))}\n </div>\n );\n}\n\nfunction SentProposals({ walletAddress }: { walletAddress: string }) {\n const { proposals, isLoading, mutate } = useSponsorshipProposals({ proposer: walletAddress, open: true });\n const action = useRowAction({ title: \"Withdraw proposal\", working: \"Withdrawing your proposal…\", done: \"Proposal withdrawn!\", description: \"Your proposal is no longer open.\" });\n\n if (isLoading) return <Skeleton className=\"h-20 w-full rounded-xl\" />;\n if (proposals.length === 0) return <p className=\"text-sm text-muted-foreground\">No pending proposals sent.</p>;\n\n return (\n <div className=\"space-y-2\">\n {action.dialog}\n {proposals.map((p) => (\n <div key={p.id} className=\"bento-cell p-4 flex items-center justify-between gap-3\">\n <div className=\"min-w-0\">\n <p className=\"text-sm font-semibold\">\n <Link href={assetHref(\"STARKNET\", p.nftContract, p.tokenId)} className=\"hover:underline\">View asset</Link>\n </p>\n <p className=\"text-xs text-muted-foreground\">You proposed {p.amount}</p>\n </div>\n <Button\n size=\"sm\"\n variant=\"outline\"\n disabled={action.busy}\n onClick={() =>\n action.run(p.proposalId, (api) => api.intents.create(\"sponsorship-proposal-withdraw\", { proposer: walletAddress, proposalId: p.proposalId }), () => mutate())\n }\n >\n <Spinner active={action.busy && action.activeId === p.proposalId} idle={null} className=\"mr-1.5\" />\n Withdraw\n </Button>\n </div>\n ))}\n </div>\n );\n}\n\nfunction LicenseList({ loading, empty, children }: { loading: boolean; empty: string; children: React.ReactNode[] }) {\n if (loading) return <Skeleton className=\"h-16 w-full rounded-xl\" />;\n if (children.length === 0) return <p className=\"text-sm text-muted-foreground\">{empty}</p>;\n return <div className=\"space-y-2\">{children}</div>;\n}\n\nexport function PortfolioSponsorships() {\n const { walletAddress } = useMedialaneApp();\n const { offers } = useSponsorshipOffers(walletAddress ? { author: walletAddress, open: true } : undefined);\n const { licenses: held, isLoading: heldLoading } = useSponsorshipLicenses(walletAddress ? { holder: walletAddress } : undefined);\n const { licenses: issued, isLoading: issuedLoading } = useSponsorshipLicenses(walletAddress ? { author: walletAddress } : undefined);\n\n if (!walletAddress) return null;\n\n return (\n <div className=\"space-y-8\">\n <section className=\"space-y-3\">\n <h2 className=\"text-sm font-bold flex items-center gap-2\"><Handshake className=\"h-4 w-4 text-brand-rose\" />Proposals awaiting your decision</h2>\n <ReceivedProposals walletAddress={walletAddress} />\n </section>\n\n {offers.length > 0 && (\n <section className=\"space-y-3\">\n <h2 className=\"text-sm font-bold\">Bids on your offers</h2>\n <div className=\"space-y-2\">\n {offers.map((o) => <OfferBidsRow key={o.id} offer={o} />)}\n </div>\n </section>\n )}\n\n <section className=\"space-y-3\">\n <h2 className=\"text-sm font-bold\">Proposals you've sent</h2>\n <SentProposals walletAddress={walletAddress} />\n </section>\n\n <section className=\"space-y-3\">\n <h2 className=\"text-sm font-bold\">Licenses you hold</h2>\n <LicenseList loading={heldLoading} empty=\"No sponsorship licenses yet.\">\n {held.map((l) => (\n <div key={l.id} className=\"bento-cell p-4\">\n <p className=\"text-sm font-semibold\">\n <Link href={assetHref(\"STARKNET\", l.assetContract, l.assetTokenId)} className=\"hover:underline\">License on this asset</Link>\n </p>\n <p className=\"text-xs text-muted-foreground\">from <AddressDisplay address={l.author} chars={4} showCopy={false} /></p>\n </div>\n ))}\n </LicenseList>\n </section>\n\n <section className=\"space-y-3\">\n <h2 className=\"text-sm font-bold\">Licenses issued on your work</h2>\n <LicenseList loading={issuedLoading} empty=\"No licenses issued yet.\">\n {issued.map((l) => (\n <div key={l.id} className=\"bento-cell p-4\">\n <p className=\"text-sm font-semibold\">\n <Link href={assetHref(\"STARKNET\", l.assetContract, l.assetTokenId)} className=\"hover:underline\">License on this asset</Link>\n </p>\n <p className=\"text-xs text-muted-foreground\">held by <AddressDisplay address={l.currentHolder ?? l.recipient} chars={4} showCopy={false} /></p>\n </div>\n ))}\n </LicenseList>\n </section>\n </div>\n );\n}\n"],"mappings":";AAoCM,SAQgF,UARhF,KAqBA,YArBA;AAlCN,SAAS,gBAAgB;AACzB,SAAS,cAAc,WAAW,SAAS,SAAS;AACpD,SAAS,iBAA2C;AACpD,SAAS,sBAAsB;AAC/B,SAAS,cAAc;AACvB,OAAO,UAAU;AACjB,SAAS,uBAAuB;AAChC,SAAS,gBAAgB;AACzB,SAAS,yBAAyB;AAClC,SAAS,uBAAuB;AAChC,SAAS,sBAAsB;AAC/B,SAAS,oBAAoB,wBAAwB,sBAAsB,+BAA+B;AAC1G,SAAS,sBAAsB;AAI/B,SAAS,aAAa,MAA6E;AACjG,QAAM,MAAM,gBAAgB;AAC5B,QAAM,KAAK,eAAe;AAC1B,QAAM,CAAC,UAAU,WAAW,IAAI,SAAwB,IAAI;AAC5D,QAAM,OAAO,GAAG,UAAU,eAAe,GAAG,UAAU,gBAAgB,GAAG,UAAU;AAEnF,QAAM,MAAM,CAAC,IAAY,QAAwE,SAAiC;AAChI,gBAAY,EAAE;AACd,SAAK,GACF,IAAI,OAAO,WAAW;AACrB,YAAM,eAAe,QAAQ,MAAM,OAAO,IAAI,UAAU,EAAE,GAAG,CAAC;AAAA,IAChE,CAAC,EACA,KAAK,MAAM,KAAK,CAAC,EACjB,QAAQ,MAAM,YAAY,IAAI,CAAC;AAAA,EACpC;AAEA,QAAM,SACJ,oBAAC,qBAAkB,IAAQ,OAAO,KAAK,OAAO,cAAc,KAAK,SAAS,gBAAe,WACvF,8BAAC,mBAAgB,IAAQ,MAAM,KAAK,OAAO,OAAO,KAAK,MAAM,aAAa,KAAK,aAAa,GAC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,181 @@
|
|
|
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 sponsorship_offer_page_exports = {};
|
|
31
|
+
__export(sponsorship_offer_page_exports, {
|
|
32
|
+
SponsorshipOfferPage: () => SponsorshipOfferPage
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(sponsorship_offer_page_exports);
|
|
35
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
36
|
+
var import_react = require("react");
|
|
37
|
+
var import_lucide_react = require("lucide-react");
|
|
38
|
+
var import_sdk = require("@medialane/sdk");
|
|
39
|
+
var import_back_button = require("./back-button.js");
|
|
40
|
+
var import_button = require("./button.js");
|
|
41
|
+
var import_image = __toESM(require("./image.js"), 1);
|
|
42
|
+
var import_input = require("./input.js");
|
|
43
|
+
var import_medialane_app = require("./medialane-app.js");
|
|
44
|
+
var import_motion_primitives = require("./motion-primitives.js");
|
|
45
|
+
var import_reward_earned = require("./rewards/reward-earned.js");
|
|
46
|
+
var import_service_header = require("./service-header.js");
|
|
47
|
+
var import_transaction_dialog = require("./transaction-dialog.js");
|
|
48
|
+
var import_transaction_done = require("./transaction-done.js");
|
|
49
|
+
var import_address = require("../utils/address.js");
|
|
50
|
+
var import_run_intent_calls = require("../utils/run-intent-calls.js");
|
|
51
|
+
var import_use_image_url = require("../utils/use-image-url.js");
|
|
52
|
+
var import_use_sponsorship = require("../utils/use-sponsorship.js");
|
|
53
|
+
var import_use_tokens = require("../utils/use-tokens.js");
|
|
54
|
+
var import_use_transaction = require("../utils/use-transaction.js");
|
|
55
|
+
const COPY = {
|
|
56
|
+
bid: { title: "Place bid", working: "Placing your bid\u2026", done: "Bid placed!", description: "Your bid is now on-chain." },
|
|
57
|
+
accept: { title: "Accept bid", working: "Accepting the bid\u2026", done: "Bid accepted!", description: "The license is minted to the sponsor." }
|
|
58
|
+
};
|
|
59
|
+
function SponsorshipOfferPage({ offerId }) {
|
|
60
|
+
const app = (0, import_medialane_app.useMedialaneApp)();
|
|
61
|
+
const walletAddress = app.walletAddress;
|
|
62
|
+
const resolveImage = (0, import_use_image_url.useImageUrl)();
|
|
63
|
+
const { offer, isLoading, mutate: mutateOffer } = (0, import_use_sponsorship.useSponsorshipOffer)(offerId);
|
|
64
|
+
const { bids, isLoading: bidsLoading, mutate: mutateBids } = (0, import_use_sponsorship.useSponsorshipBids)(offerId);
|
|
65
|
+
const { token } = (0, import_use_tokens.useToken)(offer?.nftContract ?? "", offer?.tokenId ?? "");
|
|
66
|
+
const tx = (0, import_use_transaction.useTransaction)();
|
|
67
|
+
const [action, setAction] = (0, import_react.useState)("bid");
|
|
68
|
+
const [amount, setAmount] = (0, import_react.useState)("");
|
|
69
|
+
const [activeSponsor, setActiveSponsor] = (0, import_react.useState)(null);
|
|
70
|
+
(0, import_react.useEffect)(() => {
|
|
71
|
+
if (tx.phase !== "success") return;
|
|
72
|
+
setAmount("");
|
|
73
|
+
void Promise.all([mutateOffer(), mutateBids()]);
|
|
74
|
+
}, [tx.phase, mutateOffer, mutateBids]);
|
|
75
|
+
if (isLoading) {
|
|
76
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "max-w-3xl mx-auto px-4 pt-24 pb-8 text-center text-sm text-muted-foreground", children: "Loading offer\u2026" });
|
|
77
|
+
}
|
|
78
|
+
if (!offer) {
|
|
79
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "max-w-3xl mx-auto px-4 pt-24 pb-8 text-center text-sm text-muted-foreground", children: "Offer not found." });
|
|
80
|
+
}
|
|
81
|
+
const isOwner = !!walletAddress && (0, import_sdk.normalizeAddress)("STARKNET", walletAddress) === (0, import_sdk.normalizeAddress)("STARKNET", offer.author);
|
|
82
|
+
const paymentToken = (0, import_sdk.getTokenByAddress)(offer.paymentToken);
|
|
83
|
+
const busy = tx.phase === "preparing" || tx.phase === "submitting" || tx.phase === "confirming";
|
|
84
|
+
const name = token?.metadata?.name ?? `Token #${offer.tokenId}`;
|
|
85
|
+
const imageUrl = resolveImage(token?.metadata?.image);
|
|
86
|
+
const minDisplay = paymentToken ? `${(0, import_sdk.formatAmount)(offer.minAmount, paymentToken.decimals)} ${paymentToken.symbol}` : offer.minAmount;
|
|
87
|
+
const format = (value) => paymentToken ? `${(0, import_sdk.formatAmount)(value, paymentToken.decimals)} ${paymentToken.symbol}` : value;
|
|
88
|
+
const placeBid = () => {
|
|
89
|
+
if (!walletAddress || !paymentToken) return;
|
|
90
|
+
setAction("bid");
|
|
91
|
+
void tx.run(async (signer) => {
|
|
92
|
+
const value = BigInt(Math.round(Number(amount) * 10 ** paymentToken.decimals));
|
|
93
|
+
await (0, import_run_intent_calls.runIntentCalls)(
|
|
94
|
+
signer,
|
|
95
|
+
() => app.getClient().api.intents.create("sponsorship-bid", { sponsor: walletAddress, offerId: offer.offerId, amount: value.toString(), paymentToken: offer.paymentToken })
|
|
96
|
+
);
|
|
97
|
+
});
|
|
98
|
+
};
|
|
99
|
+
const acceptBid = (sponsor) => {
|
|
100
|
+
if (!walletAddress) return;
|
|
101
|
+
setAction("accept");
|
|
102
|
+
setActiveSponsor(sponsor);
|
|
103
|
+
void tx.run(async (signer) => {
|
|
104
|
+
await (0, import_run_intent_calls.runIntentCalls)(
|
|
105
|
+
signer,
|
|
106
|
+
() => app.getClient().api.intents.create("sponsorship-bid-accept", { author: walletAddress, offerId: offer.offerId, sponsor })
|
|
107
|
+
);
|
|
108
|
+
}).finally(() => setActiveSponsor(null));
|
|
109
|
+
};
|
|
110
|
+
const copy = COPY[action];
|
|
111
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "pb-16", children: [
|
|
112
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_transaction_dialog.TransactionDialog, { tx, title: copy.title, workingLabel: copy.working, firstStepLabel: "Prepare", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
113
|
+
import_transaction_done.TransactionDone,
|
|
114
|
+
{
|
|
115
|
+
tx,
|
|
116
|
+
name,
|
|
117
|
+
title: copy.done,
|
|
118
|
+
description: copy.description,
|
|
119
|
+
footer: action === "bid" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_reward_earned.RewardEarned, { actionType: "place_sponsorship_bid" }) : void 0
|
|
120
|
+
}
|
|
121
|
+
) }),
|
|
122
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", { className: "px-4 pt-10 max-w-3xl mx-auto space-y-6", children: [
|
|
123
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_back_button.BackButton, { fallbackHref: "/launchpad/sponsorship" }),
|
|
124
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_motion_primitives.FadeIn, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_service_header.ServiceHeader, { plain: true, icon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.Handshake, { className: "h-4 w-4 text-white" }), title: name, subtitle: offer.open ? "Open for bids" : "Closed" }) }),
|
|
125
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_motion_primitives.FadeIn, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "rounded-2xl border border-border/40 overflow-hidden", children: [
|
|
126
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "relative aspect-square bg-muted/40", children: imageUrl ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_image.default, { src: imageUrl, alt: name, fill: true, sizes: "(min-width: 768px) 768px, 100vw", className: "object-cover", unoptimized: true }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "h-full w-full flex items-center justify-center", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.ImageIcon, { className: "h-8 w-8 text-muted-foreground/40" }) }) }),
|
|
127
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "p-5 grid grid-cols-2 sm:grid-cols-4 gap-4 text-sm", children: [
|
|
128
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
|
|
129
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "text-xs text-muted-foreground", children: "Minimum bid" }),
|
|
130
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "font-semibold", children: minDisplay })
|
|
131
|
+
] }),
|
|
132
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
|
|
133
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "text-xs text-muted-foreground", children: "License length" }),
|
|
134
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { className: "font-semibold", children: [
|
|
135
|
+
Math.round(Number(offer.duration) / 86400),
|
|
136
|
+
" days"
|
|
137
|
+
] })
|
|
138
|
+
] }),
|
|
139
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
|
|
140
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "text-xs text-muted-foreground", children: "Resale royalty" }),
|
|
141
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { className: "font-semibold", children: [
|
|
142
|
+
(offer.royaltyBps / 100).toFixed(1),
|
|
143
|
+
"%"
|
|
144
|
+
] })
|
|
145
|
+
] }),
|
|
146
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
|
|
147
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "text-xs text-muted-foreground", children: "Owner" }),
|
|
148
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "font-semibold", children: (0, import_address.shortenAddress)(offer.author) })
|
|
149
|
+
] })
|
|
150
|
+
] })
|
|
151
|
+
] }) }),
|
|
152
|
+
!offer.open ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_motion_primitives.FadeIn, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "text-sm text-muted-foreground text-center py-6", children: "This offer is no longer open." }) }) : isOwner ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_motion_primitives.FadeIn, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "space-y-3", children: [
|
|
153
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "text-sm font-semibold", children: "Bids" }),
|
|
154
|
+
bidsLoading ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "text-xs text-muted-foreground", children: "Loading bids\u2026" }) : bids.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "text-xs text-muted-foreground", children: "No bids yet." }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "space-y-2", children: bids.map((bid) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex items-center justify-between gap-3 rounded-xl border border-border/30 p-3", children: [
|
|
155
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
|
|
156
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "text-sm font-medium", children: (0, import_address.shortenAddress)(bid.sponsor) }),
|
|
157
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "text-xs text-muted-foreground", children: format(bid.amount) })
|
|
158
|
+
] }),
|
|
159
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_button.Button, { size: "sm", className: "bg-brand-rose hover:brightness-110 text-white", disabled: busy, onClick: () => acceptBid(bid.sponsor), children: busy && activeSponsor === bid.sponsor ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.Loader2, { className: "h-3.5 w-3.5 animate-spin" }) : "Accept" })
|
|
160
|
+
] }, bid.id)) })
|
|
161
|
+
] }) }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_motion_primitives.FadeIn, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "space-y-2", children: [
|
|
162
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "text-sm font-semibold", children: "Place a bid" }),
|
|
163
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex gap-2", children: [
|
|
164
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_input.Input, { type: "number", min: 0, step: "0.01", placeholder: "Your bid", value: amount, onChange: (e) => setAmount(e.target.value), disabled: busy }),
|
|
165
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_button.Button, { className: "bg-brand-rose hover:brightness-110 text-white shrink-0", disabled: busy || !walletAddress || !paymentToken || !amount || Number(amount) <= 0, onClick: placeBid, children: busy ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.Loader2, { className: "h-4 w-4 animate-spin" }) : "Place bid" })
|
|
166
|
+
] }),
|
|
167
|
+
!walletAddress && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", { type: "button", className: "text-xs text-muted-foreground underline", onClick: app.onRequireWallet, children: [
|
|
168
|
+
app.connectLabel ?? "Connect",
|
|
169
|
+
" to place a bid"
|
|
170
|
+
] }),
|
|
171
|
+
!paymentToken && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "text-xs text-destructive", children: "This offer uses a currency the app does not support yet." }),
|
|
172
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "text-xs text-muted-foreground", children: "Placing a bid approves the offer's payment token \u2014 no funds move until the owner accepts." })
|
|
173
|
+
] }) })
|
|
174
|
+
] })
|
|
175
|
+
] });
|
|
176
|
+
}
|
|
177
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
178
|
+
0 && (module.exports = {
|
|
179
|
+
SponsorshipOfferPage
|
|
180
|
+
});
|
|
181
|
+
//# sourceMappingURL=sponsorship-offer-page.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/sponsorship-offer-page.tsx"],"sourcesContent":["\"use client\";\n\nimport { useEffect, useState } from \"react\";\nimport { Handshake, ImageIcon, Loader2 } from \"lucide-react\";\nimport { formatAmount, getTokenByAddress, normalizeAddress } from \"@medialane/sdk\";\nimport { BackButton } from \"./back-button.js\";\nimport { Button } from \"./button.js\";\nimport Image from \"./image.js\";\nimport { Input } from \"./input.js\";\nimport { useMedialaneApp } from \"./medialane-app.js\";\nimport { FadeIn } from \"./motion-primitives.js\";\nimport { RewardEarned } from \"./rewards/reward-earned.js\";\nimport { ServiceHeader } from \"./service-header.js\";\nimport { TransactionDialog } from \"./transaction-dialog.js\";\nimport { TransactionDone } from \"./transaction-done.js\";\nimport { shortenAddress } from \"../utils/address.js\";\nimport { runIntentCalls } from \"../utils/run-intent-calls.js\";\nimport { useImageUrl } from \"../utils/use-image-url.js\";\nimport { useSponsorshipBids, useSponsorshipOffer } from \"../utils/use-sponsorship.js\";\nimport { useToken } from \"../utils/use-tokens.js\";\nimport { useTransaction } from \"../utils/use-transaction.js\";\n\ntype Action = \"bid\" | \"accept\";\n\nconst COPY = {\n bid: { title: \"Place bid\", working: \"Placing your bid…\", done: \"Bid placed!\", description: \"Your bid is now on-chain.\" },\n accept: { title: \"Accept bid\", working: \"Accepting the bid…\", done: \"Bid accepted!\", description: \"The license is minted to the sponsor.\" },\n} as const;\n\nexport function SponsorshipOfferPage({ offerId }: { offerId: string }) {\n const app = useMedialaneApp();\n const walletAddress = app.walletAddress;\n const resolveImage = useImageUrl();\n const { offer, isLoading, mutate: mutateOffer } = useSponsorshipOffer(offerId);\n const { bids, isLoading: bidsLoading, mutate: mutateBids } = useSponsorshipBids(offerId);\n const { token } = useToken(offer?.nftContract ?? \"\", offer?.tokenId ?? \"\");\n const tx = useTransaction();\n const [action, setAction] = useState<Action>(\"bid\");\n const [amount, setAmount] = useState(\"\");\n const [activeSponsor, setActiveSponsor] = useState<string | null>(null);\n\n useEffect(() => {\n if (tx.phase !== \"success\") return;\n setAmount(\"\");\n void Promise.all([mutateOffer(), mutateBids()]);\n }, [tx.phase, mutateOffer, mutateBids]);\n\n if (isLoading) {\n return <div className=\"max-w-3xl mx-auto px-4 pt-24 pb-8 text-center text-sm text-muted-foreground\">Loading offer…</div>;\n }\n if (!offer) {\n return <div className=\"max-w-3xl mx-auto px-4 pt-24 pb-8 text-center text-sm text-muted-foreground\">Offer not found.</div>;\n }\n\n const isOwner = !!walletAddress && normalizeAddress(\"STARKNET\", walletAddress) === normalizeAddress(\"STARKNET\", offer.author);\n const paymentToken = getTokenByAddress(offer.paymentToken);\n const busy = tx.phase === \"preparing\" || tx.phase === \"submitting\" || tx.phase === \"confirming\";\n const name = token?.metadata?.name ?? `Token #${offer.tokenId}`;\n const imageUrl = resolveImage(token?.metadata?.image);\n const minDisplay = paymentToken ? `${formatAmount(offer.minAmount, paymentToken.decimals)} ${paymentToken.symbol}` : offer.minAmount;\n const format = (value: string) => (paymentToken ? `${formatAmount(value, paymentToken.decimals)} ${paymentToken.symbol}` : value);\n\n const placeBid = () => {\n if (!walletAddress || !paymentToken) return;\n setAction(\"bid\");\n void tx.run(async (signer) => {\n const value = BigInt(Math.round(Number(amount) * 10 ** paymentToken.decimals));\n await runIntentCalls(signer, () =>\n app.getClient().api.intents.create(\"sponsorship-bid\", { sponsor: walletAddress, offerId: offer.offerId, amount: value.toString(), paymentToken: offer.paymentToken }),\n );\n });\n };\n\n const acceptBid = (sponsor: string) => {\n if (!walletAddress) return;\n setAction(\"accept\");\n setActiveSponsor(sponsor);\n void tx\n .run(async (signer) => {\n await runIntentCalls(signer, () =>\n app.getClient().api.intents.create(\"sponsorship-bid-accept\", { author: walletAddress, offerId: offer.offerId, sponsor }),\n );\n })\n .finally(() => setActiveSponsor(null));\n };\n\n const copy = COPY[action];\n\n return (\n <div className=\"pb-16\">\n <TransactionDialog tx={tx} title={copy.title} workingLabel={copy.working} firstStepLabel=\"Prepare\">\n <TransactionDone\n tx={tx}\n name={name}\n title={copy.done}\n description={copy.description}\n footer={action === \"bid\" ? <RewardEarned actionType=\"place_sponsorship_bid\" /> : undefined}\n />\n </TransactionDialog>\n\n <section className=\"px-4 pt-10 max-w-3xl mx-auto space-y-6\">\n <BackButton fallbackHref=\"/launchpad/sponsorship\" />\n <FadeIn>\n <ServiceHeader plain icon={<Handshake className=\"h-4 w-4 text-white\" />} title={name} subtitle={offer.open ? \"Open for bids\" : \"Closed\"} />\n </FadeIn>\n\n <FadeIn>\n <div className=\"rounded-2xl border border-border/40 overflow-hidden\">\n <div className=\"relative aspect-square bg-muted/40\">\n {imageUrl ? (\n <Image src={imageUrl} alt={name} fill sizes=\"(min-width: 768px) 768px, 100vw\" className=\"object-cover\" unoptimized />\n ) : (\n <div className=\"h-full w-full flex items-center justify-center\">\n <ImageIcon className=\"h-8 w-8 text-muted-foreground/40\" />\n </div>\n )}\n </div>\n <div className=\"p-5 grid grid-cols-2 sm:grid-cols-4 gap-4 text-sm\">\n <div>\n <p className=\"text-xs text-muted-foreground\">Minimum bid</p>\n <p className=\"font-semibold\">{minDisplay}</p>\n </div>\n <div>\n <p className=\"text-xs text-muted-foreground\">License length</p>\n <p className=\"font-semibold\">{Math.round(Number(offer.duration) / 86400)} days</p>\n </div>\n <div>\n <p className=\"text-xs text-muted-foreground\">Resale royalty</p>\n <p className=\"font-semibold\">{(offer.royaltyBps / 100).toFixed(1)}%</p>\n </div>\n <div>\n <p className=\"text-xs text-muted-foreground\">Owner</p>\n <p className=\"font-semibold\">{shortenAddress(offer.author)}</p>\n </div>\n </div>\n </div>\n </FadeIn>\n\n {!offer.open ? (\n <FadeIn>\n <p className=\"text-sm text-muted-foreground text-center py-6\">This offer is no longer open.</p>\n </FadeIn>\n ) : isOwner ? (\n <FadeIn>\n <div className=\"space-y-3\">\n <p className=\"text-sm font-semibold\">Bids</p>\n {bidsLoading ? (\n <p className=\"text-xs text-muted-foreground\">Loading bids…</p>\n ) : bids.length === 0 ? (\n <p className=\"text-xs text-muted-foreground\">No bids yet.</p>\n ) : (\n <div className=\"space-y-2\">\n {bids.map((bid) => (\n <div key={bid.id} className=\"flex items-center justify-between gap-3 rounded-xl border border-border/30 p-3\">\n <div>\n <p className=\"text-sm font-medium\">{shortenAddress(bid.sponsor)}</p>\n <p className=\"text-xs text-muted-foreground\">{format(bid.amount)}</p>\n </div>\n <Button size=\"sm\" className=\"bg-brand-rose hover:brightness-110 text-white\" disabled={busy} onClick={() => acceptBid(bid.sponsor)}>\n {busy && activeSponsor === bid.sponsor ? <Loader2 className=\"h-3.5 w-3.5 animate-spin\" /> : \"Accept\"}\n </Button>\n </div>\n ))}\n </div>\n )}\n </div>\n </FadeIn>\n ) : (\n <FadeIn>\n <div className=\"space-y-2\">\n <p className=\"text-sm font-semibold\">Place a bid</p>\n <div className=\"flex gap-2\">\n <Input type=\"number\" min={0} step=\"0.01\" placeholder=\"Your bid\" value={amount} onChange={(e) => setAmount(e.target.value)} disabled={busy} />\n <Button className=\"bg-brand-rose hover:brightness-110 text-white shrink-0\" disabled={busy || !walletAddress || !paymentToken || !amount || Number(amount) <= 0} onClick={placeBid}>\n {busy ? <Loader2 className=\"h-4 w-4 animate-spin\" /> : \"Place bid\"}\n </Button>\n </div>\n {!walletAddress && (\n <button type=\"button\" className=\"text-xs text-muted-foreground underline\" onClick={app.onRequireWallet}>\n {app.connectLabel ?? \"Connect\"} to place a bid\n </button>\n )}\n {!paymentToken && <p className=\"text-xs text-destructive\">This offer uses a currency the app does not support yet.</p>}\n <p className=\"text-xs text-muted-foreground\">\n Placing a bid approves the offer's payment token — no funds move until the owner accepts.\n </p>\n </div>\n </FadeIn>\n )}\n </section>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAgDW;AA9CX,mBAAoC;AACpC,0BAA8C;AAC9C,iBAAkE;AAClE,yBAA2B;AAC3B,oBAAuB;AACvB,mBAAkB;AAClB,mBAAsB;AACtB,2BAAgC;AAChC,+BAAuB;AACvB,2BAA6B;AAC7B,4BAA8B;AAC9B,gCAAkC;AAClC,8BAAgC;AAChC,qBAA+B;AAC/B,8BAA+B;AAC/B,2BAA4B;AAC5B,6BAAwD;AACxD,wBAAyB;AACzB,6BAA+B;AAI/B,MAAM,OAAO;AAAA,EACX,KAAK,EAAE,OAAO,aAAa,SAAS,0BAAqB,MAAM,eAAe,aAAa,4BAA4B;AAAA,EACvH,QAAQ,EAAE,OAAO,cAAc,SAAS,2BAAsB,MAAM,iBAAiB,aA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AAA,cAAI,gBAAgB;AAAA,UAAU;AAAA,WACjC;AAAA,QAED,CAAC,gBAAgB,4CAAC,OAAE,WAAU,4BAA2B,sEAAwD;AAAA,QAClH,4CAAC,OAAE,WAAU,iCAAgC,4GAE7C;AAAA,SACF,GACF;AAAA,OAEJ;AAAA,KACF;AAEJ;","names":["Image"]}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect, useState } from "react";
|
|
4
|
+
import { Handshake, ImageIcon, Loader2 } from "lucide-react";
|
|
5
|
+
import { formatAmount, getTokenByAddress, normalizeAddress } from "@medialane/sdk";
|
|
6
|
+
import { BackButton } from "./back-button.js";
|
|
7
|
+
import { Button } from "./button.js";
|
|
8
|
+
import Image from "./image.js";
|
|
9
|
+
import { Input } from "./input.js";
|
|
10
|
+
import { useMedialaneApp } from "./medialane-app.js";
|
|
11
|
+
import { FadeIn } from "./motion-primitives.js";
|
|
12
|
+
import { RewardEarned } from "./rewards/reward-earned.js";
|
|
13
|
+
import { ServiceHeader } from "./service-header.js";
|
|
14
|
+
import { TransactionDialog } from "./transaction-dialog.js";
|
|
15
|
+
import { TransactionDone } from "./transaction-done.js";
|
|
16
|
+
import { shortenAddress } from "../utils/address.js";
|
|
17
|
+
import { runIntentCalls } from "../utils/run-intent-calls.js";
|
|
18
|
+
import { useImageUrl } from "../utils/use-image-url.js";
|
|
19
|
+
import { useSponsorshipBids, useSponsorshipOffer } from "../utils/use-sponsorship.js";
|
|
20
|
+
import { useToken } from "../utils/use-tokens.js";
|
|
21
|
+
import { useTransaction } from "../utils/use-transaction.js";
|
|
22
|
+
const COPY = {
|
|
23
|
+
bid: { title: "Place bid", working: "Placing your bid\u2026", done: "Bid placed!", description: "Your bid is now on-chain." },
|
|
24
|
+
accept: { title: "Accept bid", working: "Accepting the bid\u2026", done: "Bid accepted!", description: "The license is minted to the sponsor." }
|
|
25
|
+
};
|
|
26
|
+
function SponsorshipOfferPage({ offerId }) {
|
|
27
|
+
const app = useMedialaneApp();
|
|
28
|
+
const walletAddress = app.walletAddress;
|
|
29
|
+
const resolveImage = useImageUrl();
|
|
30
|
+
const { offer, isLoading, mutate: mutateOffer } = useSponsorshipOffer(offerId);
|
|
31
|
+
const { bids, isLoading: bidsLoading, mutate: mutateBids } = useSponsorshipBids(offerId);
|
|
32
|
+
const { token } = useToken(offer?.nftContract ?? "", offer?.tokenId ?? "");
|
|
33
|
+
const tx = useTransaction();
|
|
34
|
+
const [action, setAction] = useState("bid");
|
|
35
|
+
const [amount, setAmount] = useState("");
|
|
36
|
+
const [activeSponsor, setActiveSponsor] = useState(null);
|
|
37
|
+
useEffect(() => {
|
|
38
|
+
if (tx.phase !== "success") return;
|
|
39
|
+
setAmount("");
|
|
40
|
+
void Promise.all([mutateOffer(), mutateBids()]);
|
|
41
|
+
}, [tx.phase, mutateOffer, mutateBids]);
|
|
42
|
+
if (isLoading) {
|
|
43
|
+
return /* @__PURE__ */ jsx("div", { className: "max-w-3xl mx-auto px-4 pt-24 pb-8 text-center text-sm text-muted-foreground", children: "Loading offer\u2026" });
|
|
44
|
+
}
|
|
45
|
+
if (!offer) {
|
|
46
|
+
return /* @__PURE__ */ jsx("div", { className: "max-w-3xl mx-auto px-4 pt-24 pb-8 text-center text-sm text-muted-foreground", children: "Offer not found." });
|
|
47
|
+
}
|
|
48
|
+
const isOwner = !!walletAddress && normalizeAddress("STARKNET", walletAddress) === normalizeAddress("STARKNET", offer.author);
|
|
49
|
+
const paymentToken = getTokenByAddress(offer.paymentToken);
|
|
50
|
+
const busy = tx.phase === "preparing" || tx.phase === "submitting" || tx.phase === "confirming";
|
|
51
|
+
const name = token?.metadata?.name ?? `Token #${offer.tokenId}`;
|
|
52
|
+
const imageUrl = resolveImage(token?.metadata?.image);
|
|
53
|
+
const minDisplay = paymentToken ? `${formatAmount(offer.minAmount, paymentToken.decimals)} ${paymentToken.symbol}` : offer.minAmount;
|
|
54
|
+
const format = (value) => paymentToken ? `${formatAmount(value, paymentToken.decimals)} ${paymentToken.symbol}` : value;
|
|
55
|
+
const placeBid = () => {
|
|
56
|
+
if (!walletAddress || !paymentToken) return;
|
|
57
|
+
setAction("bid");
|
|
58
|
+
void tx.run(async (signer) => {
|
|
59
|
+
const value = BigInt(Math.round(Number(amount) * 10 ** paymentToken.decimals));
|
|
60
|
+
await runIntentCalls(
|
|
61
|
+
signer,
|
|
62
|
+
() => app.getClient().api.intents.create("sponsorship-bid", { sponsor: walletAddress, offerId: offer.offerId, amount: value.toString(), paymentToken: offer.paymentToken })
|
|
63
|
+
);
|
|
64
|
+
});
|
|
65
|
+
};
|
|
66
|
+
const acceptBid = (sponsor) => {
|
|
67
|
+
if (!walletAddress) return;
|
|
68
|
+
setAction("accept");
|
|
69
|
+
setActiveSponsor(sponsor);
|
|
70
|
+
void tx.run(async (signer) => {
|
|
71
|
+
await runIntentCalls(
|
|
72
|
+
signer,
|
|
73
|
+
() => app.getClient().api.intents.create("sponsorship-bid-accept", { author: walletAddress, offerId: offer.offerId, sponsor })
|
|
74
|
+
);
|
|
75
|
+
}).finally(() => setActiveSponsor(null));
|
|
76
|
+
};
|
|
77
|
+
const copy = COPY[action];
|
|
78
|
+
return /* @__PURE__ */ jsxs("div", { className: "pb-16", children: [
|
|
79
|
+
/* @__PURE__ */ jsx(TransactionDialog, { tx, title: copy.title, workingLabel: copy.working, firstStepLabel: "Prepare", children: /* @__PURE__ */ jsx(
|
|
80
|
+
TransactionDone,
|
|
81
|
+
{
|
|
82
|
+
tx,
|
|
83
|
+
name,
|
|
84
|
+
title: copy.done,
|
|
85
|
+
description: copy.description,
|
|
86
|
+
footer: action === "bid" ? /* @__PURE__ */ jsx(RewardEarned, { actionType: "place_sponsorship_bid" }) : void 0
|
|
87
|
+
}
|
|
88
|
+
) }),
|
|
89
|
+
/* @__PURE__ */ jsxs("section", { className: "px-4 pt-10 max-w-3xl mx-auto space-y-6", children: [
|
|
90
|
+
/* @__PURE__ */ jsx(BackButton, { fallbackHref: "/launchpad/sponsorship" }),
|
|
91
|
+
/* @__PURE__ */ jsx(FadeIn, { children: /* @__PURE__ */ jsx(ServiceHeader, { plain: true, icon: /* @__PURE__ */ jsx(Handshake, { className: "h-4 w-4 text-white" }), title: name, subtitle: offer.open ? "Open for bids" : "Closed" }) }),
|
|
92
|
+
/* @__PURE__ */ jsx(FadeIn, { children: /* @__PURE__ */ jsxs("div", { className: "rounded-2xl border border-border/40 overflow-hidden", children: [
|
|
93
|
+
/* @__PURE__ */ jsx("div", { className: "relative aspect-square bg-muted/40", children: imageUrl ? /* @__PURE__ */ jsx(Image, { src: imageUrl, alt: name, fill: true, sizes: "(min-width: 768px) 768px, 100vw", className: "object-cover", unoptimized: true }) : /* @__PURE__ */ jsx("div", { className: "h-full w-full flex items-center justify-center", children: /* @__PURE__ */ jsx(ImageIcon, { className: "h-8 w-8 text-muted-foreground/40" }) }) }),
|
|
94
|
+
/* @__PURE__ */ jsxs("div", { className: "p-5 grid grid-cols-2 sm:grid-cols-4 gap-4 text-sm", children: [
|
|
95
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
96
|
+
/* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: "Minimum bid" }),
|
|
97
|
+
/* @__PURE__ */ jsx("p", { className: "font-semibold", children: minDisplay })
|
|
98
|
+
] }),
|
|
99
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
100
|
+
/* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: "License length" }),
|
|
101
|
+
/* @__PURE__ */ jsxs("p", { className: "font-semibold", children: [
|
|
102
|
+
Math.round(Number(offer.duration) / 86400),
|
|
103
|
+
" days"
|
|
104
|
+
] })
|
|
105
|
+
] }),
|
|
106
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
107
|
+
/* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: "Resale royalty" }),
|
|
108
|
+
/* @__PURE__ */ jsxs("p", { className: "font-semibold", children: [
|
|
109
|
+
(offer.royaltyBps / 100).toFixed(1),
|
|
110
|
+
"%"
|
|
111
|
+
] })
|
|
112
|
+
] }),
|
|
113
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
114
|
+
/* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: "Owner" }),
|
|
115
|
+
/* @__PURE__ */ jsx("p", { className: "font-semibold", children: shortenAddress(offer.author) })
|
|
116
|
+
] })
|
|
117
|
+
] })
|
|
118
|
+
] }) }),
|
|
119
|
+
!offer.open ? /* @__PURE__ */ jsx(FadeIn, { children: /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground text-center py-6", children: "This offer is no longer open." }) }) : isOwner ? /* @__PURE__ */ jsx(FadeIn, { children: /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
120
|
+
/* @__PURE__ */ jsx("p", { className: "text-sm font-semibold", children: "Bids" }),
|
|
121
|
+
bidsLoading ? /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: "Loading bids\u2026" }) : bids.length === 0 ? /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: "No bids yet." }) : /* @__PURE__ */ jsx("div", { className: "space-y-2", children: bids.map((bid) => /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-3 rounded-xl border border-border/30 p-3", children: [
|
|
122
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
123
|
+
/* @__PURE__ */ jsx("p", { className: "text-sm font-medium", children: shortenAddress(bid.sponsor) }),
|
|
124
|
+
/* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: format(bid.amount) })
|
|
125
|
+
] }),
|
|
126
|
+
/* @__PURE__ */ jsx(Button, { size: "sm", className: "bg-brand-rose hover:brightness-110 text-white", disabled: busy, onClick: () => acceptBid(bid.sponsor), children: busy && activeSponsor === bid.sponsor ? /* @__PURE__ */ jsx(Loader2, { className: "h-3.5 w-3.5 animate-spin" }) : "Accept" })
|
|
127
|
+
] }, bid.id)) })
|
|
128
|
+
] }) }) : /* @__PURE__ */ jsx(FadeIn, { children: /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
|
|
129
|
+
/* @__PURE__ */ jsx("p", { className: "text-sm font-semibold", children: "Place a bid" }),
|
|
130
|
+
/* @__PURE__ */ jsxs("div", { className: "flex gap-2", children: [
|
|
131
|
+
/* @__PURE__ */ jsx(Input, { type: "number", min: 0, step: "0.01", placeholder: "Your bid", value: amount, onChange: (e) => setAmount(e.target.value), disabled: busy }),
|
|
132
|
+
/* @__PURE__ */ jsx(Button, { className: "bg-brand-rose hover:brightness-110 text-white shrink-0", disabled: busy || !walletAddress || !paymentToken || !amount || Number(amount) <= 0, onClick: placeBid, children: busy ? /* @__PURE__ */ jsx(Loader2, { className: "h-4 w-4 animate-spin" }) : "Place bid" })
|
|
133
|
+
] }),
|
|
134
|
+
!walletAddress && /* @__PURE__ */ jsxs("button", { type: "button", className: "text-xs text-muted-foreground underline", onClick: app.onRequireWallet, children: [
|
|
135
|
+
app.connectLabel ?? "Connect",
|
|
136
|
+
" to place a bid"
|
|
137
|
+
] }),
|
|
138
|
+
!paymentToken && /* @__PURE__ */ jsx("p", { className: "text-xs text-destructive", children: "This offer uses a currency the app does not support yet." }),
|
|
139
|
+
/* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: "Placing a bid approves the offer's payment token \u2014 no funds move until the owner accepts." })
|
|
140
|
+
] }) })
|
|
141
|
+
] })
|
|
142
|
+
] });
|
|
143
|
+
}
|
|
144
|
+
export {
|
|
145
|
+
SponsorshipOfferPage
|
|
146
|
+
};
|
|
147
|
+
//# sourceMappingURL=sponsorship-offer-page.js.map
|