Skip to content

Commit

Permalink
fix: remove download button and add react hook dependencies (#164)
Browse files Browse the repository at this point in the history
* chore: remove download button

* fix: missing dependency for react useEffect/useCallback hooks
  • Loading branch information
HJunyuan committed Jan 31, 2023
1 parent af4213a commit ca28c9b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 19 deletions.
20 changes: 2 additions & 18 deletions components/figure/Renderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
Template,
} from "@govtechsg/decentralized-renderer-react-components";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faPrint, faFileArrowDown } from "@fortawesome/free-solid-svg-icons";
import { faPrint } from "@fortawesome/free-solid-svg-icons";

import { getTemplateUrl } from "@utils/oa-details";
import { OpenAttestationDocument, WrappedDocument } from "@govtechsg/open-attestation";
Expand All @@ -39,7 +39,7 @@ const Renderer: React.FC<RendererProps> = ({ document, rawDocument }) => {
toFrame(renderDocument({ document, rawDocument }));
setToFrame(() => toFrame);
},
[document]
[document, rawDocument]
);

const fromFrame = useCallback((action: FrameActions) => {
Expand All @@ -50,14 +50,6 @@ const Renderer: React.FC<RendererProps> = ({ document, rawDocument }) => {
}
}, []);

const handleDownload = useCallback(() => {
const a = window.document.createElement("a");
a.href = `data:text/json;charset=utf-8,${encodeURIComponent(JSON.stringify(rawDocument, null, 2))}`;
a.download = `document.oa`;
a.click();
a.remove();
}, [rawDocument]);

const handlePrint = useCallback(() => {
if (
navigator.userAgent.includes("SamsungBrowser") ||
Expand Down Expand Up @@ -94,14 +86,6 @@ const Renderer: React.FC<RendererProps> = ({ document, rawDocument }) => {
))}
</ul>
<div className="ml-auto flex gap-2">
<button
className="w-14 h-14 my-2 p-4 rounded-lg shadow-lg bg-white print:ring-8 print:ring-orange-500 text-primary hover:bg-primary hover:text-white transition-colors"
title="Download document"
aria-label="document-utility-download-button"
onClick={handleDownload}
>
<FontAwesomeIcon icon={faFileArrowDown} className="text-xl" />
</button>
<button
className="w-14 h-14 my-2 p-4 rounded-lg shadow-lg bg-white print:ring-8 print:ring-orange-500 text-primary hover:bg-primary hover:text-white transition-colors"
title="Print document"
Expand Down
2 changes: 1 addition & 1 deletion pages/verify.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ const Verify: NextPage<InferGetServerSidePropsType<typeof getServerSideProps>> =
dispatch({ type: "STATUS_MESSAGE", status: verifyErrorHandler(e) });
}
})();
}, [router]);
}, [router, props.universalActionType]);

const handleDocumentDropped = useCallback((wrappedDocument) => {
dispatch({ type: "VERIFY_DOCUMENT", document: wrappedDocument });
Expand Down

0 comments on commit ca28c9b

Please sign in to comment.