From 5812d8ed2ebde8557f8e09e1b9c038cfabdd3222 Mon Sep 17 00:00:00 2001 From: mantikoros Date: Fri, 29 Jul 2022 16:02:18 -0700 Subject: [PATCH] manalink qr code --- web/components/manalink-card.tsx | 18 +++++++++++++++++- .../manalinks/create-links-button.tsx | 11 +++++++---- web/components/qr-code.tsx | 16 ++++++++++++++++ 3 files changed, 40 insertions(+), 5 deletions(-) create mode 100644 web/components/qr-code.tsx diff --git a/web/components/manalink-card.tsx b/web/components/manalink-card.tsx index 51880f5d..c8529609 100644 --- a/web/components/manalink-card.tsx +++ b/web/components/manalink-card.tsx @@ -10,6 +10,7 @@ import { DotsHorizontalIcon } from '@heroicons/react/solid' import { contractDetailsButtonClassName } from './contract/contract-info-dialog' import { useUserById } from 'web/hooks/use-user' import getManalinkUrl from 'web/get-manalink-url' +import { QrcodeIcon } from '@heroicons/react/outline' export type ManalinkInfo = { expiresTime: number | null maxUses: number | null @@ -78,7 +79,9 @@ export function ManalinkCardFromView(props: { const { className, link, highlightedSlug } = props const { message, amount, expiresTime, maxUses, claims } = link const [showDetails, setShowDetails] = useState(false) - + const qrUrl = `https://api.qrserver.com/v1/create-qr-code/?size=${200}x${200}&data=${getManalinkUrl( + link.slug + )}` return ( {formatMoney(amount)} + + + {!finishedCreating && ( @@ -199,17 +202,17 @@ function CreateManalinkForm(props: { copyPressed ? 'bg-indigo-50 text-indigo-500 transition-none' : '' )} > -
- {getManalinkUrl(highlightedSlug)} -
+
{url}
{ - navigator.clipboard.writeText(getManalinkUrl(highlightedSlug)) + navigator.clipboard.writeText(url) setCopyPressed(true) }} className="my-auto ml-2 h-5 w-5 cursor-pointer transition hover:opacity-50" /> + + )} diff --git a/web/components/qr-code.tsx b/web/components/qr-code.tsx new file mode 100644 index 00000000..a10f8886 --- /dev/null +++ b/web/components/qr-code.tsx @@ -0,0 +1,16 @@ +export function QRCode(props: { + url: string + className?: string + width?: number + height?: number +}) { + const { url, className, width, height } = { + width: 200, + height: 200, + ...props, + } + + const qrUrl = `https://api.qrserver.com/v1/create-qr-code/?size=${width}x${height}&data=${url}` + + return +}