Skip to content

Commit 8e3c8e3

Browse files
committed
feat: improve webhooks example
- DESC events sorting - Better table UX
1 parent 99cb3eb commit 8e3c8e3

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

examples/webhooks/index.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ app.get("/", (req, res) => {
4242
<script src="https://cdn.tailwindcss.com"></script>
4343
</head>
4444
<body class="font-sans bg-gray-100 min-h-screen p-4">
45-
<div class="max-w-4xl mx-auto">
45+
<div class="max-w-6xl mx-auto">
4646
<h3 class="text-xl font-semibold mb-4">
4747
Any PDF submitted through
4848
<a href="https://${companyIdentifier}.simplepdf.com/editor" target="_blank" class="text-blue-600 hover:text-blue-800 underline">https://${companyIdentifier}.simplepdf.com/editor</a> will appear below
@@ -51,7 +51,7 @@ app.get("/", (req, res) => {
5151
<table class="w-full text-left text-sm font-light">
5252
<thead class="border-b font-medium bg-gray-200">
5353
<tr>
54-
<th class="px-6 py-4">Submission URL</th>
54+
<th class="px-6 py-4">Submission</th>
5555
<th class="px-6 py-4">Document</th>
5656
<th class="px-6 py-4">Document ID</th>
5757
<th class="px-6 py-4">Submission ID</th>
@@ -61,10 +61,15 @@ app.get("/", (req, res) => {
6161
</thead>
6262
<tbody>
6363
${events
64+
.sort((eventA, eventB) => {
65+
const dateA = new Date(eventA.data.submission.submitted_at);
66+
const dateB = new Date(eventB.data.submission.submitted_at);
67+
return dateB.getTime() - dateA.getTime();
68+
})
6469
.map(
6570
(event) => `
6671
<tr class="bg-white border-b">
67-
<td class="px-6 py-4"><a href="/submissions/${event.data.submission.id}" class="text-blue-600 hover:text-blue-800 underline">URL</a></td>
72+
<td class="px-6 py-4"><a href="/submissions/${event.data.submission.id}" class="text-blue-600 hover:text-blue-800 underline">View submission</a></td>
6873
<td class="px-6 py-4">${event.data.document.name}</td>
6974
<td class="px-6 py-4">${event.data.document.id}</td>
7075
<td class="px-6 py-4">${event.data.submission.id}</td>
@@ -101,7 +106,7 @@ app.get("/submissions/:submissionId", (req, res) => {
101106
<script src="https://cdn.tailwindcss.com"></script>
102107
</head>
103108
<body class="font-sans bg-gray-100 min-h-screen p-4">
104-
<div class="max-w-4xl mx-auto">
109+
<div class="max-w-6xl mx-auto">
105110
<table class="w-full text-left text-sm font-light">
106111
<thead class="border-b font-medium bg-gray-200">
107112
<tr>

0 commit comments

Comments
 (0)