Add snackbar feedback, logout modal, profile pill nav, calendar styling, fix image paths and signup flow
This commit is contained in:
1 parent
221aa90649
commit
4b54c48311
11 files changed
+234
-26
No files matched your search
+19
-2
@@ -9,7 +9,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
const filterButtons = document.querySelectorAll('.category-item');
|
||||
const locationFilter = document.getElementById('location-filter');
|
||||
const dateFilter = document.getElementById('date-filter');
|
||||
const locationIconPath = 'assets/location-pin.svg';
|
||||
const locationIconPath = 'assets/icon_location-pin.svg';
|
||||
|
||||
// -------------------------------------------------------------
|
||||
// In-memory state for fetched events and currently active category.
|
||||
@@ -329,7 +329,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
<div class="empty-state">
|
||||
<p class="empty-state-kicker">Keine Treffer</p>
|
||||
<h3>Schade, aktuell gibt es hier keine Events.</h3>
|
||||
<p>Starte dein eigenes Dinner und bringe die Community an deinen Tisch.</p>
|
||||
<p>Starte dein eigenes Event und bringe die Community an deinen Tisch.</p>
|
||||
<a class="empty-state-link" href="event_create.html">
|
||||
<button class="empty-state-btn" type="button">Event erstellen</button>
|
||||
</a>
|
||||
@@ -435,12 +435,29 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
: [];
|
||||
const idSet = new Set(currentIds);
|
||||
|
||||
// Abmeldung: Benutzer vom Event entfernen und Snackbar anzeigen.
|
||||
if (action === 'unregister') {
|
||||
idSet.delete(Number(event.id));
|
||||
const snackbar = document.getElementById('snackbar');
|
||||
if (snackbar) {
|
||||
snackbar.textContent = 'Du wurdest erfolgreich abgemeldet.';
|
||||
snackbar.classList.add('snackbar--danger', 'snackbar--visible');
|
||||
setTimeout(() => {
|
||||
snackbar.classList.remove('snackbar--visible');
|
||||
setTimeout(() => snackbar.classList.remove('snackbar--danger'), 400);
|
||||
}, 3000);
|
||||
}
|
||||
}
|
||||
|
||||
// Anmeldung: Benutzer zum Event hinzufuegen und Snackbar anzeigen.
|
||||
if (action === 'register' && !isFull && !isRegistrationClosed) {
|
||||
idSet.add(Number(event.id));
|
||||
const snackbar = document.getElementById('snackbar');
|
||||
if (snackbar) {
|
||||
snackbar.textContent = 'Du wurdest erfolgreich angemeldet.';
|
||||
snackbar.classList.add('snackbar--visible');
|
||||
setTimeout(() => snackbar.classList.remove('snackbar--visible'), 3000);
|
||||
}
|
||||
}
|
||||
|
||||
nextRegistrationMap[currentUser.email] = Array.from(idSet);
|
||||
|
||||
+26
-2
@@ -148,11 +148,24 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
});
|
||||
|
||||
logoutButton.addEventListener('click', () => {
|
||||
localStorage.removeItem(CURRENT_USER_KEY);
|
||||
window.location.href = 'login.html';
|
||||
const logoutModal = document.getElementById('logoutModal');
|
||||
logoutModal.classList.add('show');
|
||||
document.body.style.overflow = 'hidden';
|
||||
});
|
||||
}
|
||||
|
||||
// Globale Funktionen fuer das Logout-Modal.
|
||||
window.closeLogoutModal = function() {
|
||||
const logoutModal = document.getElementById('logoutModal');
|
||||
logoutModal.classList.remove('show');
|
||||
document.body.style.overflow = 'auto';
|
||||
};
|
||||
|
||||
window.confirmLogout = function() {
|
||||
localStorage.removeItem(CURRENT_USER_KEY);
|
||||
window.location.href = 'index.html';
|
||||
};
|
||||
|
||||
// Reagiert auf Aktionen in der Liste "Meine Events" per Event Delegation.
|
||||
function handleHostedListClick(event) {
|
||||
const target = event.target;
|
||||
@@ -219,6 +232,17 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
}
|
||||
|
||||
unregisterFromEvent(eventId, currentUser.email);
|
||||
|
||||
// Snackbar: Feedback bei erfolgreicher Abmeldung.
|
||||
const snackbar = document.getElementById('snackbar');
|
||||
if (snackbar) {
|
||||
snackbar.textContent = 'Du wurdest erfolgreich abgemeldet.';
|
||||
snackbar.classList.add('snackbar--danger', 'snackbar--visible');
|
||||
setTimeout(() => {
|
||||
snackbar.classList.remove('snackbar--visible');
|
||||
setTimeout(() => snackbar.classList.remove('snackbar--danger'), 400);
|
||||
}, 3000);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
+11
-8
@@ -31,8 +31,8 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
const signupIsActive = currentPage === 'signup.html';
|
||||
const isIndex = currentPage === 'index.html' || currentPage === '';
|
||||
|
||||
// Auf der Startseite nur Login anzeigen.
|
||||
if (isIndex) {
|
||||
// Auf der Startseite, Login und Signup nur Login anzeigen.
|
||||
if (isIndex || loginIsActive || signupIsActive) {
|
||||
return `
|
||||
<a
|
||||
class="button-small"
|
||||
@@ -61,20 +61,23 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
>
|
||||
Signup
|
||||
</a>
|
||||
`;`;
|
||||
`;
|
||||
}
|
||||
|
||||
// Baut die Navigation fuer eingeloggte Benutzer.
|
||||
function buildLoggedInNavigation() {
|
||||
function buildLoggedInNavigation(user) {
|
||||
const initial = (user.vorname || 'U').charAt(0).toUpperCase();
|
||||
const isEventOverview = currentPage === 'event_overview.html';
|
||||
|
||||
return `
|
||||
<a class="nav-tab" href="event_overview.html">Event finden</a>
|
||||
<a class="nav-tab" href="event_create.html">Event erstellen</a>
|
||||
<a class="button-small" href="my_profil.html" aria-label="Mein Profil">Mein Profil</a>
|
||||
${isEventOverview ? '' : '<a class="nav-tab" href="event_overview.html">Event finden</a>'}
|
||||
<a class="button-small" href="event_create.html">Event erstellen</a>
|
||||
<a class="profile-pill" href="my_profil.html" aria-label="Mein Profil" title="${user.vorname || 'Profil'}">${initial}</a>
|
||||
`;
|
||||
}
|
||||
|
||||
const currentUser = getCurrentUser();
|
||||
const nextMarkup = currentUser ? buildLoggedInNavigation() : buildLoggedOutNavigation();
|
||||
const nextMarkup = currentUser ? buildLoggedInNavigation(currentUser) : buildLoggedOutNavigation();
|
||||
|
||||
// Wendet das passende Markup auf alle vorhandenen Kopf-Navigationen an.
|
||||
navContainers.forEach(container => {
|
||||
|
||||
+2
-4
@@ -46,6 +46,7 @@ function openWelcomeModal() {
|
||||
function closeWelcomeModal() {
|
||||
welcomeModal.classList.remove('show');
|
||||
document.body.style.overflow = 'auto';
|
||||
window.location.href = 'event_overview.html';
|
||||
}
|
||||
|
||||
// Hauptfunktion fuer Formularvalidierung und Speicherung.
|
||||
@@ -138,10 +139,7 @@ function validateForm(event) {
|
||||
setCurrentUser(newUser);
|
||||
|
||||
openWelcomeModal();
|
||||
// Hier koennte spaeter ein echter API-Call zum Backend stehen.
|
||||
|
||||
// Weiterleitung zur Event-Overview-Seite.
|
||||
window.location.href = 'event_overview.html';
|
||||
// Weiterleitung erfolgt beim Klick auf "Weiter zu den Events".
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user