summaryrefslogtreecommitdiff
path: root/views
diff options
context:
space:
mode:
authorJannick <[email protected]>2024-05-02 11:00:53 +0200
committerJannick <[email protected]>2024-05-02 11:00:53 +0200
commit8862f3319d8804a36fa3b62e7a1c4f714e42efb0 (patch)
treef074361243614d4377b759d491679c79f378a52a /views
parente407f10fefa8159520b9e782dde97f2f053649c0 (diff)
parenta1fa1ebf6e390d9705da13eb23e6b3fd3802d1f1 (diff)
Merge branch 'main' of github.com:linnnus/blind-guild
Diffstat (limited to 'views')
-rw-r--r--views/base.html5
-rw-r--r--views/manage.html55
2 files changed, 58 insertions, 2 deletions
diff --git a/views/base.html b/views/base.html
index 556a777..294cfd1 100644
--- a/views/base.html
+++ b/views/base.html
@@ -14,8 +14,9 @@
<ul class="navbar__links" role="navigation" aria-label="Main">
<li><a class="navbar__location" href="/index.html">About us</a></li>
<li><a class="navbar__location" href="/history.html">History</a></li>
- <li><a class="navbar__location" href="/leaderboards.html">Leaderboards</a></li>
- {% if not logged_in %}
+ {% if logged_in %}
+ <li><a class="navbar__location" href="/manage.html">Manage</a></li>
+ {% else %}
<li><a class="navbar__location" href="/login">Log in</a></li>
<li><a class="navbar__location" href="/join_intro.html">Join</a></li>
{% endif %}
diff --git a/views/manage.html b/views/manage.html
new file mode 100644
index 0000000..d7e2b65
--- /dev/null
+++ b/views/manage.html
@@ -0,0 +1,55 @@
+{% extends "base.html" %}
+
+{% block head %}
+ <link rel="stylesheet" href="/styles/manage.css">
+ <script type="module">
+ // Progressive enhancement – perform form requests without leaving page.
+
+ for (const application of document.querySelectorAll(".applications__item")) {
+ for (const form of application.querySelectorAll("form.action")) {
+ form.addEventListener("submit", async (event) => {
+ event.preventDefault();
+
+ if (!confirm("Are you sure?")) {
+ return;
+ }
+
+ let ok;
+ try {
+ const response = await fetch(form.action, {
+ method: "POST",
+ data: new FormData(form),
+ });
+ ok = response.ok;
+ } catch {
+ ok = false;
+ }
+
+ if (ok) {
+ application.remove();
+ } else {
+ alert("Something went wrong >w<");
+ }
+ });
+ }
+ }
+ </script>
+{% endblock %}
+
+{% block content %}
+ <h1>Manage applications</h1>
+ <div class="applications">
+ {% for application in applications %}
+ <section class="applications__item">
+ <span class="application__username">{{ application.username | e }}</span>
+ <p>{{ application.motivation | e }}</p>
+ <form class="action" method="POST" action="/manage/reject/{{ application.userId | e }}">
+ <button class="action__button action__button--reject">Reject</button>
+ </form>
+ <form class="action" method="POST" action="/manage/accept/{{ application.userId | e }}">
+ <button class="action__button action__button--accept">Accept</button>
+ </form>
+ </section>
+ {% endfor %}
+ </div>
+{% endblock %}