Skip to content

Commit

Permalink
pull form out like in the other view
Browse files Browse the repository at this point in the history
  • Loading branch information
niklasmohrin committed Dec 11, 2023
1 parent 7ce7e02 commit 407d4a4
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions evap/rewards/templates/rewards_reward_point_redemption_events.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,28 @@
</div>
</div>

<form id="event-deletion-form" method="POST" action="{% url 'rewards:reward_point_redemption_event_delete' %}">
{% csrf_token %}
</form>

<script defer>
const form = document.getElementById("event-deletion-form");
form.addEventListener("submit", event => {
event.preventDefault();
const body = new FormData(form);
const request = fetch(
form.action,
{ method: form.method, body },
);
request.then(response => {
assert(response.ok);
fadeOutThenRemove(document.querySelector(`#event-row-${body.get("event_id")}`));
}).catch(error => {
window.alert("{% trans 'The server is not responding.' %}");
});;
});
</script>

<div class="card card-outline-primary mb-3">
{% trans 'Upcoming events' as title %}
{% include 'rewards_reward_point_redemption_event_list.html' with title=title events=upcoming_events %}
Expand Down

0 comments on commit 407d4a4

Please sign in to comment.