From 03428e947ae7e6f20d4f2121155b1ec73c8d921e Mon Sep 17 00:00:00 2001 From: James Chartrand Date: Mon, 22 Jan 2024 18:52:24 -0500 Subject: [PATCH] add expired page --- packages/claim-page/src/pages/error.astro | 3 +-- packages/claim-page/src/pages/expired.astro | 18 ++++++++++++++++++ packages/claim-page/src/pages/index.astro | 16 +++++++++------- 3 files changed, 28 insertions(+), 9 deletions(-) create mode 100644 packages/claim-page/src/pages/expired.astro diff --git a/packages/claim-page/src/pages/error.astro b/packages/claim-page/src/pages/error.astro index b5e887a..e396abf 100644 --- a/packages/claim-page/src/pages/error.astro +++ b/packages/claim-page/src/pages/error.astro @@ -11,8 +11,7 @@ import Modal from '../components/Modal.astro';

Credential Inaccessible

- This credential is currently inaccessible. For further assistance, please reach out - to our Registrar Office at +52 555 123 4567. + This credential isn't available. For further assistance, please contact your issuer.

diff --git a/packages/claim-page/src/pages/expired.astro b/packages/claim-page/src/pages/expired.astro new file mode 100644 index 0000000..dee3899 --- /dev/null +++ b/packages/claim-page/src/pages/expired.astro @@ -0,0 +1,18 @@ +--- +import Layout from '../layouts/Layout.astro'; +import MainSection from '../layouts/MainSection.astro'; +import Modal from '../components/Modal.astro'; +--- + + + + +
+

Claim page expired

+ +

+ Access to the credential claim page has expired. If you haven't yet collected your credential, please open a new page using the original link that was sent to you. +

+
+
+
diff --git a/packages/claim-page/src/pages/index.astro b/packages/claim-page/src/pages/index.astro index 7cb0d0b..ea39975 100644 --- a/packages/claim-page/src/pages/index.astro +++ b/packages/claim-page/src/pages/index.astro @@ -17,20 +17,14 @@ import Button from '../components/Button.astro'; import QRCode from 'qrcode'; import { format } from 'date-fns'; - const payloadUrl = import.meta.env.PUBLIC_PAYLOAD_URL || 'http://localhost:3000/api'; const urlSearchParams = new URLSearchParams(window.location.search); const params = Object.fromEntries(urlSearchParams.entries()); const { token } = params; - console.log("the token:") - console.log(token) if (!token) window.location.href = '/error'; - -console.log("after the error") - const title = document.getElementById('title') as HTMLHeadingElement; const info1 = document.getElementById('info-1') as HTMLParagraphElement; @@ -40,11 +34,19 @@ console.log("after the error") title.innerText = 'Gettingggg Credential...'; try { - console.log("about to try the fetch") + const res = await fetch(`${payloadUrl}/get-credential-links`, { headers: { Authorization: `Bearer ${token}` }, }); + console.log('setting the expiration timeout') + setTimeout(() => { + // We redirect nine minutes (540000 ms) after the page loads, + // since the exchange endpoint expires after ten minutes. + console.log("Redirecting...."); + window.location.replace("/expired"); + }, 540000); + if (res.status !== 200) window.location.href = '/error'; else { const {