feat: Improve user experience after voting on proposals

- Redirect users to the proposal detail page with a success
  message after a successful vote, improving feedback.
- Automatically remove the success message from the URL after a
  short time to avoid URL clutter and maintain a clean browsing
  experience.
- Add a success alert message on the proposal detail page to
  provide immediate visual confirmation of a successful vote.
- Improve the visual presentation of the votes list on the
  proposal detail page by adding top margin for better spacing.
This commit is contained in:
Mahmoud-Emad
2025-05-22 17:05:26 +03:00
parent 52fbc77e3e
commit 3d8aca19cc
2 changed files with 31 additions and 13 deletions

View File

@@ -240,7 +240,7 @@
</div>
<!-- Votes List -->
<div class="row">
<div class="row mt-4">
<div class="col-12">
<div class="card shadow-sm">
<div class="card-header bg-light d-flex justify-content-between align-items-center flex-wrap">
@@ -338,6 +338,23 @@
{% block scripts %}
<script>
document.addEventListener('DOMContentLoaded', function () {
// Remove query parameters from URL without refreshing the page
if (window.location.search.includes('vote_success=true')) {
const newUrl = window.location.pathname;
window.history.replaceState({}, document.title, newUrl);
// Auto-hide the success alert after 5 seconds
const successAlert = document.querySelector('.alert-success');
if (successAlert) {
setTimeout(function() {
successAlert.classList.remove('show');
setTimeout(function() {
successAlert.remove();
}, 500);
}, 5000);
}
}
// Vote filtering using data-filter attributes
const filterButtons = document.querySelectorAll('[data-filter]');
const voteRows = document.querySelectorAll('.vote-row');