Skip to content

Commit

Permalink
add expired page
Browse files Browse the repository at this point in the history
  • Loading branch information
jchartrand committed Jan 22, 2024
1 parent 4c8171f commit 03428e9
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 9 deletions.
3 changes: 1 addition & 2 deletions packages/claim-page/src/pages/error.astro
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ import Modal from '../components/Modal.astro';
<h3 class="text-3xl">Credential Inaccessible</h3>

<p class="text-xl leading-6">
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.
</p>
</main>
</Modal>
Expand Down
18 changes: 18 additions & 0 deletions packages/claim-page/src/pages/expired.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
import Layout from '../layouts/Layout.astro';
import MainSection from '../layouts/MainSection.astro';
import Modal from '../components/Modal.astro';
---

<Layout title="Credential Inaccessible">
<MainSection />
<Modal id="main-modal" open={true} allowCancel={false}>
<main slot="main" class="pt-10 pb-12 px-10 flex flex-col gap-5 items-center">
<h3 class="text-3xl">Claim page expired</h3>

<p class="text-xl leading-6">
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.
</p>
</main>
</Modal>
</Layout>
16 changes: 9 additions & 7 deletions packages/claim-page/src/pages/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {
Expand Down

0 comments on commit 03428e9

Please sign in to comment.