Skip to content

Commit

Permalink
update props and use utils from OA lib
Browse files Browse the repository at this point in the history
  • Loading branch information
lawwman committed Jan 22, 2024
1 parent e9000eb commit 5dc1881
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
10 changes: 4 additions & 6 deletions src/DefaultTemplate.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from "react";
import { TemplateProps, TemplateWithComponent } from "./types";
import { EmotionJSX } from "@emotion/react/types/jsx-namespace";
import { isRawV2Document, isRawV3Document } from "@govtechsg/open-attestation/dist/types/shared/utils";
import { utils } from "@govtechsg/open-attestation";

interface DefaultTemplateProps {
title: string;
Expand All @@ -24,14 +24,12 @@ const container = {
paddingLeft: "1rem",
};

const paddingBox = `.75rem 1.25rem`;

function extractTemplateInfo(document: TemplateProps["document"]) {
let name = "";
let type = "";
let url = "";

if (isRawV2Document(document)) {
if (utils.isRawV2Document(document)) {
// v2 document
const template = document.$template;

Expand All @@ -42,7 +40,7 @@ function extractTemplateInfo(document: TemplateProps["document"]) {
type = template.type;
url = template.url ?? "";
}
} else if (isRawV3Document(document)) {
} else if (utils.isRawV3Document(document)) {
// v3 document
const template = document.openAttestationMetadata.template;
if (template !== undefined) {
Expand Down Expand Up @@ -94,7 +92,7 @@ export const DefaultTemplate: React.FunctionComponent<DefaultTemplateProps> = (p
<pre
style={{
backgroundColor: "#f7f8fc",
padding: paddingBox,
padding: `.75rem 1.25rem`,
whiteSpace: "pre-wrap",
wordWrap: "break-word",
}}
Expand Down
4 changes: 2 additions & 2 deletions src/components/frame/FrameConnector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ interface BaseFrameConnectorProps {
*/
onConnected: (toFrame: HostActionsHandler & LegacyHostActions) => void;

onConnectionFailure?: (setDocumentToRender: React.Dispatch<React.SetStateAction<undefined>>) => void;
onConnectionFailure?: (renderDocumentWithJSONRenderer: (document: any) => void) => void;
/**
* style to apply to the frame
*/
Expand Down Expand Up @@ -121,7 +121,7 @@ export const FrameConnector: FunctionComponent<FrameConnectorProps> = ({
useEffect(() => {
if (timeout) {
dispatch(timeoutAction());
if (onConnectionFailure) onConnectionFailure(setDocumentToRenderOnConnectionFailure);
if (onConnectionFailure) onConnectionFailure((document) => setDocumentToRenderOnConnectionFailure(document));
}
}, [timeout, dispatch, onConnectionFailure]);

Expand Down

0 comments on commit 5dc1881

Please sign in to comment.