import { CircleAlertIcon, CopyIcon, RefreshCwIcon } from "lucide-react"; import React from "react"; import { toast } from "sonner"; import AppHeader from "src/components/AppHeader"; import QRCode from "src/components/QRCode"; import { Alert, AlertDescription, AlertTitle, } from "src/components/ui/alert.tsx"; import { Button } from "src/components/ui/button"; import { Card, CardContent, CardFooter, CardHeader, CardTitle, } from "src/components/ui/card"; import { LoadingButton } from "src/components/ui/custom/loading-button"; import { Input } from "src/components/ui/input"; import { Label } from "src/components/ui/label"; import { copyToClipboard } from "src/lib/clipboard"; import { CreateOfferRequest } from "src/types"; import { request } from "src/utils/request"; export default function ReceiveOffer() { const [isLoading, setLoading] = React.useState(false); const [description, setDescription] = React.useState(""); const [offer, setOffer] = React.useState(null); const handleSubmit = async (event: React.FormEvent) => { event.preventDefault(); try { setLoading(true); const offer = await request("/api/offers", { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify({ description, } as CreateOfferRequest), }); if (offer) { setOffer(offer); toast("Successfully created BOLT-12 offer"); } } catch (e) { toast.error("Failed to create offer", { description: "" + e, }); console.error(e); } finally { setLoading(false); } }; const copy = () => { copyToClipboard(offer as string); }; return (
{!offer && ( BOLT-12 Offers are in beta BOLT-12 is not supported by all wallets and nodes in the lightning network. This feature will work only if you have a channel with a node that supports onion message forwarding, and are paid by a lightning wallet that supports paying BOLT-12 offers. )} {offer ? ( Lightning Offer {description && (

{description}

)}
) : (
{ setDescription(e.target.value); }} />
Create Offer
)}
); }