Show QR codes are toasts

This commit is contained in:
Ananth Venkatesh 2024-02-16 21:44:32 +00:00
parent bcf0a38b4e
commit 0205590b9f
3 changed files with 20 additions and 17 deletions

View file

@ -14,7 +14,6 @@ import generateHash from '@/app/utils/hash'
import { Suspense } from 'react'
import { loadDocument } from '@/app/db/loaders'
import { useSuspenseQuery } from '@tanstack/react-query'
import QRCode from 'qrcode.react'
const zillaSlab = Zilla_Slab({ subsets: ['latin'], weight: ['500'] })
@ -49,10 +48,6 @@ const DocumentViewer = ({ slug }: Readonly<{ slug: string }>) => {
return (
<div className='max-w-4xl lg:max-w-6xl mx-auto'>
<div>
<div className='mr-8 mb-4 mt-4 hidden md:inline'>
<QRCode value={citation ?? `eeXiv:${generateHash(slug)}`} />
</div>
<h1
className={`
text-slate-800 text-5xl mb-4
@ -62,7 +57,6 @@ const DocumentViewer = ({ slug }: Readonly<{ slug: string }>) => {
>
{title}
</h1>
</div>
<p className={`text-slate-800 mt-2`}>
<Authors authors={authors} />
</p>

View file

@ -7,6 +7,7 @@ import { useSuspenseQuery } from '@tanstack/react-query'
import { epoch2date } from '@/app/utils/epoch2datestring'
import { toast } from 'react-toastify'
import generateHash from '@/app/utils/hash'
import QRCode from 'qrcode.react'
const VersionChooser = ({
doc,
@ -51,9 +52,17 @@ const VersionChooser = ({
}
const handleCopy = () => {
const id = doc.citation ? doc.citation : generateHash(slug)
const id = doc.citation ? doc.citation.slice(6) : generateHash(slug)
navigator.clipboard.writeText(`eeXiv:${id}`)
notifyCopied('Citation')
toast.info((
<div className='p-4'>
<QRCode value={doc.citation ?? `eeXiv:${generateHash(slug)}`} />
</div>
), {
autoClose: false,
closeOnClick: true,
})
}
return (

View file

@ -77,7 +77,7 @@ export default function Page() {
let invalid = false
if (search.toLowerCase().startsWith('eexiv')) {
if (search.toLowerCase().startsWith('eexiv:')) {
const id = search.slice(6)
if (id.length !== 12) {