Skip to content

Commit 545aa38

Browse files
feat: add reference to which credential you need for presentation during issuance (#144)
Signed-off-by: Berend Sliedrecht <berend@animo.id>
1 parent dabdeec commit 545aa38

1 file changed

Lines changed: 25 additions & 1 deletion

File tree

app/components/IssueTab.tsx

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { RadioGroup } from '@radix-ui/react-radio-group'
33
import Image from 'next/image'
44
import Link from 'next/link'
55
import { type ReadonlyURLSearchParams, useRouter } from 'next/navigation'
6-
import { type FormEvent, useEffect, useState } from 'react'
6+
import { type FormEvent, useEffect, useRef, useState } from 'react'
77
import QRCode from 'react-qr-code'
88
import { Button } from '@/components/ui/button'
99
import { Card } from '@/components/ui/card'
@@ -44,6 +44,8 @@ export function IssueTab({
4444

4545
const selectedIssuer = issuers?.find((i) => i.id === selectedIssuerId)
4646
const router = useRouter()
47+
const issueButtonRef = useRef<HTMLButtonElement>(null)
48+
const hasScrolledToIssueRef = useRef(false)
4749
const [isCopyingTimeout, setIsCopyingTimeout] = useState<ReturnType<typeof setTimeout>>()
4850
const copyConfigurationText = isCopyingTimeout ? 'Configuration copied!' : 'Copy configuration'
4951

@@ -71,6 +73,13 @@ export function IssueTab({
7173
})
7274
}, [issuers, searchParams])
7375

76+
// Scroll to the Issue Credential button when opened via a shared config link
77+
useEffect(() => {
78+
if (!issuers || hasScrolledToIssueRef.current || !searchParams.get('scrollToIssue')) return
79+
hasScrolledToIssueRef.current = true
80+
issueButtonRef.current?.scrollIntoView({ behavior: 'smooth', block: 'center' })
81+
}, [issuers, searchParams])
82+
7483
// Update URL when state changes
7584
useEffect(() => {
7685
if (!issuers) return
@@ -274,6 +283,20 @@ export function IssueTab({
274283
<MiniRadioItem value="browser" label="Sign in" />
275284
<MiniRadioItem value="pin" label="Transaction code" />
276285
</RadioGroup>
286+
{selectedAuthorization === 'presentation' && (
287+
<p className="text-gray-500 text-sm">
288+
You first need to obtain the credential that will be presented during issuance. The configuration is
289+
already selected for you.{' '}
290+
<a
291+
href="/?authorization=presentation&credentialType=1&deferBy=none&dpop=false&format=dc%2Bsd-jwt&issuerId=188e2459-6da8-4431-9062-2fcdac274f41&keyAttestation=false&tab=issue&walletAttestation=false&scrollToIssue=true"
292+
target="_blank"
293+
rel="noopener noreferrer"
294+
className="text-accent underline"
295+
>
296+
Issue that credential here.
297+
</a>
298+
</p>
299+
)}
277300
</div>
278301
<div className="space-y-2">
279302
<div>
@@ -373,6 +396,7 @@ export function IssueTab({
373396
)}
374397
</div>
375398
<Button
399+
ref={issueButtonRef}
376400
onClick={onSubmitIssueCredential}
377401
disabled={disabled}
378402
className="w-full"

0 commit comments

Comments
 (0)