diff --git a/package.json b/package.json index 68c94522..3739d935 100644 --- a/package.json +++ b/package.json @@ -44,6 +44,7 @@ "light-bolt11-decoder": "^3.0.0", "nostr-fetch": "^0.12.1", "nostr-tools": "^1.13.0", + "qrcode.react": "^3.1.0", "react": "^18.2.0", "react-dom": "^18.2.0", "react-hook-form": "^7.45.2", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 81512acc..d35020c1 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -82,6 +82,9 @@ dependencies: nostr-tools: specifier: ^1.13.0 version: 1.13.0 + qrcode.react: + specifier: ^3.1.0 + version: 3.1.0(react@18.2.0) react: specifier: ^18.2.0 version: 18.2.0 @@ -6168,6 +6171,14 @@ packages: resolution: {integrity: sha512-rRV+zQD8tVFys26lAGR9WUuS4iUAngJScM+ZRSKtvl5tKeZ2t5bvdNFdNHBW9FWR4guGHlgmsZ1G7BSm2wTbuA==} engines: {node: '>=6'} + /qrcode.react@3.1.0(react@18.2.0): + resolution: {integrity: sha512-oyF+Urr3oAMUG/OiOuONL3HXM+53wvuH3mtIWQrYmsXoAq0DkvZp2RYUWFSMFtbdOpuS++9v+WAkzNVkMlNW6Q==} + peerDependencies: + react: ^16.8.0 || ^17.0.0 || ^18.0.0 + dependencies: + react: 18.2.0 + dev: false + /queue-microtask@1.2.3: resolution: {integrity: sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==} diff --git a/src/index.css b/src/index.css index b81750c8..d0e4cd23 100644 --- a/src/index.css +++ b/src/index.css @@ -18,7 +18,7 @@ button { -webkit-hyphens: auto; -moz-hyphens: auto; hyphens: auto; - @apply prose prose-zinc max-w-none select-text break-words dark:prose-invert prose-p:mb-2 prose-p:mt-0 prose-p:last:mb-0 prose-a:break-all prose-a:font-normal prose-a:leading-tight prose-a:text-fuchsia-400 hover:prose-a:text-fuchsia-500 prose-blockquote:m-0 prose-ol:m-0 prose-ol:mb-1 prose-ul:mb-1 prose-li:leading-tight prose-img:mb-2 prose-img:mt-3 prose-hr:mx-0 prose-hr:my-2; + @apply prose prose-zinc max-w-none select-text dark:prose-invert prose-p:mb-2 prose-p:mt-0 prose-p:break-words prose-p:[word-break:break-word] prose-p:last:mb-0 prose-a:break-words prose-a:break-all prose-a:font-normal prose-a:leading-tight prose-a:text-fuchsia-400 hover:prose-a:text-fuchsia-500 prose-blockquote:m-0 prose-ol:m-0 prose-ol:mb-1 prose-ul:mb-1 prose-li:leading-tight prose-img:mb-2 prose-img:mt-3 prose-hr:mx-0 prose-hr:my-2; } .ProseMirror p.is-empty::before { diff --git a/src/shared/notes/actions/zap.tsx b/src/shared/notes/actions/zap.tsx index c073d096..1f72120c 100644 --- a/src/shared/notes/actions/zap.tsx +++ b/src/shared/notes/actions/zap.tsx @@ -1,7 +1,11 @@ import { NostrEvent } from '@nostr-dev-kit/ndk'; -import * as Tooltip from '@radix-ui/react-tooltip'; +import * as Dialog from '@radix-ui/react-dialog'; +import { QRCodeSVG } from 'qrcode.react'; +import { useState } from 'react'; +import { twMerge } from 'tailwind-merge'; -import { ZapIcon } from '@shared/icons'; +import { Button } from '@shared/button'; +import { CancelIcon, ZapIcon } from '@shared/icons'; import { useEvent } from '@utils/hooks/useEvent'; import { usePublish } from '@utils/hooks/usePublish'; @@ -10,28 +14,185 @@ export function NoteZap({ id }: { id: string }) { const { createZap } = usePublish(); const { data: event } = useEvent(id); - const submit = async () => { - const res = await createZap(event as NostrEvent, 21000); - console.log(res); + const [amount, setAmount] = useState(null); + const [invoice, setInvoice] = useState(null); + + const selected = (num: number) => { + if (amount === num) return true; + return false; + }; + + const createZapRequest = async () => { + const res = await createZap(event as NostrEvent, amount); + if (res) setInvoice(res); }; return ( - - + + - - - - Tip - - - - + + + +
+ +
+
+ + Zap (Beta) + + + Send tip with Bitcoin via Lightning + +
+ + + +
+
+ {!invoice ? ( + <> +
+ + + + + + +
+
+ +
+ + ) : ( +
+
+ +
+
+

+ Scan to pay +

+ + You must use Bitcoin wallet which support Lightning +
+ such as: Blue Wallet, Bitkit, Phoenix,... +
+
+
+ )} +
+
+
+
+ ); }