diff --git a/frontend/src/screens/internal-apps/ZapPlanner.tsx b/frontend/src/screens/internal-apps/ZapPlanner.tsx index ea574951..895ca126 100644 --- a/frontend/src/screens/internal-apps/ZapPlanner.tsx +++ b/frontend/src/screens/internal-apps/ZapPlanner.tsx @@ -70,19 +70,19 @@ export function ZapPlanner() { const [open, setOpen] = React.useState(false); const [isSubmitting, setSubmitting] = React.useState(false); - const [customName, setCustomName] = React.useState(""); - const [customLightningAddress, setCustomLightningAddress] = - React.useState(""); + const [name, setName] = React.useState(""); + const [lightningAddress, setLightningAddress] = React.useState(""); + const [amount, setAmount] = React.useState(5000); + const [comment, setComment] = React.useState(""); const handleSubmit = async () => { setSubmitting(true); try { - if (apps?.some((existingApp) => existingApp.name === customName)) { + if (apps?.some((existingApp) => existingApp.name === name)) { throw new Error("A connection with the same name already exists."); } - const amountSats = 5000; - const maxAmount = Math.floor(amountSats * 1.01) + 10; // with fee reserve + const maxAmount = Math.floor(amount * 1.01) + 10; // with fee reserve const isolated = false; const createAppRequest: CreateAppRequest = { @@ -93,7 +93,7 @@ export function ZapPlanner() { isolated, metadata: { app_store_app_id: "zapplanner", - recipient_lightning_address: customLightningAddress, + recipient_lightning_address: lightningAddress, }, }; @@ -108,8 +108,8 @@ export function ZapPlanner() { "Content-Type": "application/json", }, body: JSON.stringify({ - recipientLightningAddress: customLightningAddress, - amount: amountSats, + recipientLightningAddress: lightningAddress, + amount: amount, message: "ZapPlanner payment from Alby Hub", // TODO: allow customization payerData: JSON.stringify({}), nostrWalletConnectUrl: createAppResponse.pairingUri, @@ -160,6 +160,7 @@ export function ZapPlanner() { handleRequestError(toast, "Failed to create app", error); } finally { setSubmitting(false); + setOpen(false); } }; @@ -202,7 +203,8 @@ export function ZapPlanner() { setName(e.target.value)} className="col-span-3" /> @@ -212,21 +214,33 @@ export function ZapPlanner() { setLightningAddress(e.target.value)} className="col-span-3" />