Merge branch 'master' of github.com:waku-org/lab.waku.org into feat/buddychain

This commit is contained in:
Danish Arora 2024-10-28 18:22:29 +05:30
commit 30d734f27c
No known key found for this signature in database
GPG Key ID: 1C6EF37CDAE1426E
4 changed files with 18 additions and 11 deletions

View File

@ -7,7 +7,7 @@ import { Button } from "@/components/ui/button"
import { type LightNode } from "@waku/sdk"
import { useWaku } from "@waku/react"
import { Loader2 } from "lucide-react"
import { Routes, Route, Navigate, Link } from 'react-router-dom'
import { Routes, Route, Navigate, Link, useParams } from 'react-router-dom'
import { BlockPayload, getMessagesFromStore, subscribeToFilter } from './lib/waku'
import TelemetryOptIn from './components/TelemetryOptIn';
import TelemetryPage from './components/TelemetryPage';

View File

@ -139,7 +139,7 @@ const SignChain: React.FC<SignChainProps> = ({ block, chainsData, onSuccess }) =
<p className="text-sm text-muted-foreground">{block.title}</p>
<p className="text-sm text-muted-foreground">{block.description}</p>
</div>
<QRCode data={block} />
<QRCode text={`${window.location.origin}/sign/${block.chainUUID}/${block.blockUUID}`} />
</div>
{error && <p className="text-sm text-destructive">{error}</p>}
<DialogFooter>

View File

@ -23,7 +23,7 @@ const ChainList: React.FC<ChainListProps> = ({ chainsData, onChainUpdate, isLoad
const childBlocks = chainsData.filter(b => b.parentBlockUUID === block.blockUUID);
const totalSignatures = block.signatures.length + childBlocks.reduce((acc, child) => acc + child.signatures.length, 0);
const shareUrl = `${window.location.origin}/sign/${block.chainUUID}/${block.blockUUID}`;
const shareUrl = `${window.location.origin}/sign/${block.chainUUID ?? block.blockUUID}/${block.blockUUID}`;
return (
<li key={`${block.blockUUID}-${depth}`} className="mb-4">
@ -66,7 +66,16 @@ const ChainList: React.FC<ChainListProps> = ({ chainsData, onChainUpdate, isLoad
Share this chain with others to collect their signatures.
</DialogDescription>
</DialogHeader>
<QRCode text={shareUrl} />
<div className="flex flex-col items-center space-y-4">
<QRCode text={shareUrl} width={200} height={200} />
<p className="text-sm text-center break-all">{shareUrl}</p>
<Button
onClick={() => navigator.clipboard.writeText(shareUrl)}
variant="outline"
>
Copy Link
</Button>
</div>
</DialogContent>
</Dialog>
</div>

View File

@ -4,29 +4,27 @@ import { Button } from "@/components/ui/button";
import { Check, Copy } from "lucide-react";
interface QRCodeProps {
data?: any;
text?: string;
text: string;
width?: number;
height?: number;
}
const QRCode: React.FC<QRCodeProps> = ({ data, text, width = 256, height = 256 }) => {
const QRCode: React.FC<QRCodeProps> = ({ text, width = 256, height = 256 }) => {
const [copied, setCopied] = useState(false);
const shareUrl = text || (data ? `${window.location.origin}/sign/${data.chainUUID}/${data.blockUUID}` : '');
const handleCopy = async () => {
await navigator.clipboard.writeText(shareUrl);
await navigator.clipboard.writeText(text);
setCopied(true);
setTimeout(() => setCopied(false), 2000);
};
return (
<div className="flex flex-col items-center space-y-4">
<QRCodeSVG value={shareUrl} size={Math.min(width, height)} />
<QRCodeSVG value={text} size={Math.min(width, height)} />
<div className="flex items-center space-x-2">
<input
type="text"
value={shareUrl}
value={text}
readOnly
className="flex-1 px-3 py-2 text-sm border rounded-md bg-muted"
/>