From d3427991277661fa8aedb76514b07a4abaa7a44e Mon Sep 17 00:00:00 2001 From: matt Date: Mon, 25 Jul 2022 03:14:40 +0000 Subject: [PATCH] Added uploads section to single event page --- public/single.html | 5 +++++ public/single.js | 27 ++++++++++++++++++++++++++- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/public/single.html b/public/single.html index ca74371..cf47345 100644 --- a/public/single.html +++ b/public/single.html @@ -52,6 +52,11 @@

+
+

Uploads

+
+
+
diff --git a/public/single.js b/public/single.js index b3e2dfb..0c8308b 100644 --- a/public/single.js +++ b/public/single.js @@ -58,8 +58,33 @@ async function main() { if (event.location) $event.querySelector('.event-location').appendChild(getDirectionLink(event.location)); + else + $event.querySelector('.event-location').innerText = 'There is no location specified for this event'; - $event.querySelector('.event-notes').innerText = event.notes ?? ''; + $event.querySelector('.event-notes').innerText = event.notes ?? 'There are no notes for this event'; + + const uploads = $event.querySelector('.event-uploads'); + + if (event.uploads && event.uploads.length > 0) { + for (const { upload } of event.uploads) { + if (typeof upload === 'string') { + uploads.classList.add('text-red-600'); + uploads.innerText = 'Please log in to view uploads'; + break; + } + + const $elem = document.createElement('a'); + + $elem.setAttribute('href', upload.url); + $elem.innerText = upload.filename; + + $elem.classList.add('underline'); + + uploads.appendChild($elem); + } + } else { + uploads.innerText = 'There are no uploads for this event'; + } } main();