diff --git a/ui/src/adapters/api/credentials.ts b/ui/src/adapters/api/credentials.ts index a9c8d37b0..cf9fbc492 100644 --- a/ui/src/adapters/api/credentials.ts +++ b/ui/src/adapters/api/credentials.ts @@ -4,7 +4,7 @@ import { z } from "zod"; import { Response, buildErrorResponse, buildSuccessResponse } from "src/adapters"; import { ID, IDParser, Message, buildAuthorizationHeader, messageParser } from "src/adapters/api"; import { datetimeParser, getListParser, getStrictParser } from "src/adapters/parsers"; -import { Credential, Env, Json, Link, LinkStatus, ProofType } from "src/domain"; +import { Credential, Env, IssuedQRCode, Json, Link, LinkStatus, ProofType } from "src/domain"; import { API_VERSION, QUERY_SEARCH_PARAM, STATUS_SEARCH_PARAM } from "src/utils/constants"; import { List } from "src/utils/types"; @@ -418,6 +418,13 @@ export async function createAuthQRCode({ } } +const issuedQRCodeParser = getStrictParser()( + z.object({ + qrCodeLink: z.string(), + schemaType: z.string(), + }) +); + export async function getIssuedQRCode({ credentialID, env, @@ -426,7 +433,7 @@ export async function getIssuedQRCode({ credentialID: string; env: Env; signal: AbortSignal; -}): Promise> { +}): Promise> { try { const response = await axios({ baseURL: env.api.url, @@ -434,7 +441,7 @@ export async function getIssuedQRCode({ signal, url: `${API_VERSION}/credentials/${credentialID}/qrcode`, }); - return buildSuccessResponse(z.string().parse(response.data)); + return buildSuccessResponse(issuedQRCodeParser.parse(response.data)); } catch (error) { return buildErrorResponse(error); } diff --git a/ui/src/components/credentials/CredentialIssuedQR.tsx b/ui/src/components/credentials/CredentialIssuedQR.tsx index 36114e543..e929a8a98 100644 --- a/ui/src/components/credentials/CredentialIssuedQR.tsx +++ b/ui/src/components/credentials/CredentialIssuedQR.tsx @@ -6,14 +6,14 @@ import { CredentialQR } from "src/components/credentials/CredentialQR"; import { ErrorResult } from "src/components/shared/ErrorResult"; import { LoadingResult } from "src/components/shared/LoadingResult"; import { useEnvContext } from "src/contexts/Env"; -import { AppError } from "src/domain"; +import { AppError, IssuedQRCode } from "src/domain"; import { AsyncTask, hasAsyncTaskFailed, isAsyncTaskDataAvailable } from "src/utils/async"; import { isAbortedError, makeRequestAbortable } from "src/utils/browser"; export function CredentialIssuedQR() { const env = useEnvContext(); - const [issuedQRCode, setIssuedQRCode] = useState>({ + const [issuedQRCode, setIssuedQRCode] = useState>({ status: "pending", }); @@ -65,7 +65,8 @@ export function CredentialIssuedQR() { return ( ); diff --git a/ui/src/components/credentials/CredentialQR.tsx b/ui/src/components/credentials/CredentialQR.tsx index 006fcdf6d..003740740 100644 --- a/ui/src/components/credentials/CredentialQR.tsx +++ b/ui/src/components/credentials/CredentialQR.tsx @@ -11,7 +11,7 @@ export function CredentialQR({ subTitle, }: { qrCode: string; - schemaType?: string; + schemaType: string; subTitle: ReactNode; }) { const { issuer } = useEnvContext(); diff --git a/ui/src/domain/credential.ts b/ui/src/domain/credential.ts index 80d9ff916..090b58a88 100644 --- a/ui/src/domain/credential.ts +++ b/ui/src/domain/credential.ts @@ -18,7 +18,7 @@ export type Credential = { }; export type IssuedQRCode = { - qrCode: unknown; + qrCodeLink: string; schemaType: string; };