nordabiz/templates/base.html
Maciej Pienczyn 6d589407be Sync local repo with production state
- Add MembershipFee and MembershipFeeConfig models
- Add /health endpoint for monitoring
- Add Microsoft Fluent Design CSS
- Update templates with new CSS structure
- Add Announcement model
- Update .gitignore to exclude analysis files

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-06 22:23:28 +01:00

884 lines
39 KiB
HTML

<!DOCTYPE html>
<html lang="pl">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Norda Biznes Hub - katalog firm członkowskich stowarzyszenia Norda Biznes">
<meta name="author" content="Norda Biznes">
<meta name="robots" content="index, follow">
<title>{% block title %}Norda Biznes Hub{% endblock %}</title>
<!-- Favicon -->
<link rel="icon" type="image/x-icon" href="{{ url_for('static', filename='img/favicon.ico') }}">
<!-- Fonts -->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap" rel="stylesheet">
<!-- Microsoft Fluent Design CSS (from MTBtracker) -->
<link rel="stylesheet" href="{{ url_for('static', filename='css/microsoft-fluent.css') }}">
<!-- NordaBiz-specific Fluent extensions -->
<link rel="stylesheet" href="{{ url_for('static', filename='css/fluent-nordabiz.css') }}">
<!-- Styles -->
<style>
/* ============================================================
* RESET & BASE STYLES
* ============================================================ */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
:root {
/* Colors - Professional blue palette */
--primary: #2563eb;
--primary-dark: #1e40af;
--primary-light: #3b82f6;
--secondary: #64748b;
--success: #10b981;
--warning: #f59e0b;
--error: #ef4444;
--background: #f8fafc;
--surface: #ffffff;
--text-primary: #1e293b;
--text-secondary: #64748b;
--border: #e2e8f0;
/* Spacing */
--spacing-xs: 0.25rem;
--spacing-sm: 0.5rem;
--spacing-md: 1rem;
--spacing-lg: 1.5rem;
--spacing-xl: 2rem;
--spacing-2xl: 3rem;
/* Typography */
--font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
--font-size-sm: 0.875rem;
--font-size-base: 1rem;
--font-size-lg: 1.125rem;
--font-size-xl: 1.25rem;
--font-size-2xl: 1.5rem;
--font-size-3xl: 1.875rem;
/* Shadows */
--shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
--shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
--shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
--shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
/* Border radius */
--radius-sm: 0.25rem;
--radius: 0.5rem;
--radius-lg: 0.75rem;
--radius-xl: 1rem;
/* Transitions */
--transition: all 0.2s ease-in-out;
}
body {
font-family: var(--font-family);
font-size: var(--font-size-base);
line-height: 1.6;
color: var(--text-primary);
background-color: var(--background);
min-height: 100vh;
display: flex;
flex-direction: column;
}
/* ============================================================
* LAYOUT
* ============================================================ */
.container {
width: 100%;
max-width: 1280px;
margin: 0 auto;
padding: 0 var(--spacing-md);
}
.container-narrow {
max-width: 768px;
}
main {
flex: 1;
padding: var(--spacing-xl) 0;
}
/* ============================================================
* BUTTONS
* ============================================================ */
.btn {
display: inline-flex;
align-items: center;
justify-content: center;
gap: var(--spacing-sm);
padding: var(--spacing-sm) var(--spacing-lg);
font-size: var(--font-size-base);
font-weight: 500;
text-decoration: none;
border-radius: var(--radius);
border: none;
cursor: pointer;
transition: var(--transition);
white-space: nowrap;
}
.btn-primary {
background-color: var(--primary);
color: white;
}
.btn-primary:hover {
background-color: var(--primary-dark);
}
.btn-secondary {
background-color: var(--secondary);
color: white;
}
.btn-secondary:hover {
background-color: #475569;
}
.btn-outline {
background-color: transparent;
color: var(--primary);
border: 2px solid var(--primary);
}
.btn-outline:hover {
background-color: var(--primary);
color: white;
}
.btn-sm {
padding: var(--spacing-xs) var(--spacing-md);
font-size: var(--font-size-sm);
}
.btn-lg {
padding: var(--spacing-md) var(--spacing-xl);
font-size: var(--font-size-lg);
}
/* ============================================================
* FLASH MESSAGES
* ============================================================ */
.flash-messages {
position: fixed;
top: var(--spacing-xl);
right: var(--spacing-xl);
z-index: 1000;
max-width: 400px;
}
.flash {
padding: var(--spacing-md);
margin-bottom: var(--spacing-md);
border-radius: var(--radius);
box-shadow: var(--shadow-lg);
display: flex;
align-items: start;
gap: var(--spacing-md);
animation: slideIn 0.3s ease-out;
}
@keyframes slideIn {
from {
transform: translateX(100%);
opacity: 0;
}
to {
transform: translateX(0);
opacity: 1;
}
}
.flash-success {
background-color: var(--success);
color: white;
}
.flash-error {
background-color: var(--error);
color: white;
}
.flash-warning {
background-color: var(--warning);
color: white;
}
.flash-info {
background-color: var(--primary);
color: white;
}
.flash-close {
background: none;
border: none;
color: inherit;
font-size: var(--font-size-xl);
cursor: pointer;
margin-left: auto;
opacity: 0.8;
}
.flash-close:hover {
opacity: 1;
}
/* ============================================================
* DEVELOPMENT NOTICE BANNER
* ============================================================ */
.dev-notice {
background: linear-gradient(135deg, #fef3c7, #fde68a);
border-bottom: 2px solid #f59e0b;
padding: var(--spacing-sm) var(--spacing-md);
text-align: center;
font-size: var(--font-size-sm);
color: #92400e;
display: flex;
align-items: center;
justify-content: center;
gap: var(--spacing-sm);
}
.dev-notice-icon {
font-size: 1.2em;
}
.dev-notice-text {
font-weight: 500;
}
.dev-notice-close {
background: none;
border: none;
color: #92400e;
font-size: 1.2em;
cursor: pointer;
padding: 0 var(--spacing-sm);
opacity: 0.6;
transition: var(--transition);
margin-left: var(--spacing-md);
}
.dev-notice-close:hover {
opacity: 1;
}
/* ============================================================
* FOOTER
* ============================================================ */
footer {
background-color: var(--text-primary);
color: white;
padding: var(--spacing-xl) 0;
margin-top: auto;
}
.footer-content {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
gap: var(--spacing-xl);
}
.footer-section h3 {
margin-bottom: var(--spacing-md);
font-size: var(--font-size-lg);
}
.footer-section p,
.footer-section a {
color: #94a3b8;
text-decoration: none;
display: block;
margin-bottom: var(--spacing-sm);
}
.footer-section a:hover {
color: white;
}
.footer-bottom {
border-top: 1px solid #334155;
margin-top: var(--spacing-xl);
padding-top: var(--spacing-md);
text-align: center;
color: #94a3b8;
font-size: var(--font-size-sm);
}
/* ============================================================
* UTILITIES
* ============================================================ */
.text-center { text-align: center; }
.text-muted { color: var(--text-secondary); }
.mt-1 { margin-top: var(--spacing-md); }
.mt-2 { margin-top: var(--spacing-lg); }
.mt-3 { margin-top: var(--spacing-xl); }
.mb-1 { margin-bottom: var(--spacing-md); }
.mb-2 { margin-bottom: var(--spacing-lg); }
.mb-3 { margin-bottom: var(--spacing-xl); }
{% block extra_css %}{% endblock %}
</style>
</head>
<body>
<!-- Fluent Command Bar Navigation -->
<nav class="fluent-command-bar" role="navigation" aria-label="Main navigation">
<a href="{{ url_for('index') }}" class="fluent-command-bar-brand" aria-label="Norda Biznes Home">
<svg width="28" height="28" viewBox="0 0 32 32" fill="currentColor">
<path d="M16 2L2 9v14l14 7 14-7V9L16 2zm0 3.5L25.5 10 16 14.5 6.5 10 16 5.5zm-11 6.8l10 5v9.4l-10-5v-9.4zm12 14.4v-9.4l10-5v9.4l-10 5z"/>
</svg>
<span>Norda Biznes</span>
</a>
<button class="fluent-mobile-toggle" aria-label="Toggle navigation" onclick="toggleMobileMenu()">
<svg width="24" height="24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M3 12h18M3 6h18M3 18h18"/>
</svg>
</button>
<div class="fluent-command-bar-nav" id="navMenu">
<!-- Main links (always visible) -->
<a href="{{ url_for('index') }}" class="fluent-command-bar-item {% if request.endpoint == 'index' %}active{% endif %}">Firmy</a>
{% if current_user.is_authenticated %}
<!-- Dropdown: Spolecznosc -->
<div class="fluent-dropdown" id="communityDropdown">
<button class="fluent-command-bar-item fluent-dropdown-trigger {% if request.endpoint in ['events', 'calendar_index', 'forum_index', 'classifieds_index'] or (request.endpoint and ('calendar' in request.endpoint or 'forum' in request.endpoint or 'classifieds' in request.endpoint)) %}active{% endif %}" onclick="toggleDropdown('communityDropdown')">
<svg width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M17 20h5v-2a3 3 0 00-5.356-1.857M17 20H7m10 0v-2c0-.656-.126-1.283-.356-1.857M7 20H2v-2a3 3 0 015.356-1.857M7 20v-2c0-.656.126-1.283.356-1.857m0 0a5.002 5.002 0 019.288 0M15 7a3 3 0 11-6 0 3 3 0 016 0z"/>
</svg>
Spolecznosc
<svg width="12" height="12" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7"/>
</svg>
</button>
<div class="fluent-dropdown-menu">
<a href="{{ url_for('calendar_index') }}" class="fluent-dropdown-item">
<svg width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"/>
</svg>
Kalendarz
</a>
<a href="{{ url_for('forum_index') }}" class="fluent-dropdown-item">
<svg width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M17 8h2a2 2 0 012 2v6a2 2 0 01-2 2h-2v4l-4-4H9a1.994 1.994 0 01-1.414-.586m0 0L11 14h4a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2v4l.586-.586z"/>
</svg>
Forum
</a>
<a href="{{ url_for('classifieds_index') }}" class="fluent-dropdown-item">
<svg width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"/>
</svg>
Tablica B2B
</a>
</div>
</div>
<!-- Chat AI -->
<a href="{{ url_for('chat') }}" class="fluent-command-bar-item {% if request.endpoint == 'chat' %}active{% endif %}">
<svg width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 10h.01M12 10h.01M16 10h.01M9 16H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-5l-5 5v-5z"/>
</svg>
Chat AI
</a>
<!-- Dropdown: Panel uzytkownika -->
<div class="fluent-dropdown" id="userDropdown">
<button class="fluent-command-bar-item fluent-dropdown-trigger" onclick="toggleDropdown('userDropdown')" style="position: relative;">
<svg width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z"/>
</svg>
Panel
{% set total_unread = (unread_notifications_count|default(0)) %}
{% if total_unread > 0 %}
<span class="fluent-badge" id="totalBadge">{{ total_unread if total_unread <= 99 else '99+' }}</span>
{% endif %}
<svg width="12" height="12" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7"/>
</svg>
</button>
<div class="fluent-dropdown-menu" style="min-width: 320px;">
<!-- User info -->
<div class="fluent-user-panel">
<div class="fluent-user-avatar">{{ current_user.name[:1]|upper if current_user.name else 'U' }}</div>
<div class="fluent-user-info">
<div class="fluent-user-name">{{ current_user.name or 'Uzytkownik' }}</div>
<div class="fluent-user-email">{{ current_user.email }}</div>
</div>
</div>
<!-- Notifications section -->
<div class="fluent-notifications-header">
<span class="fluent-notifications-title">
Powiadomienia
{% if unread_notifications_count > 0 %}
<span class="fluent-badge fluent-badge-inline" id="notificationBadge">{{ unread_notifications_count if unread_notifications_count <= 99 else '99+' }}</span>
{% else %}
<span class="fluent-badge fluent-badge-inline" id="notificationBadge" style="display: none;">0</span>
{% endif %}
</span>
<button class="fluent-notifications-action" onclick="markAllNotificationsRead()">Oznacz wszystkie</button>
</div>
<div id="notificationsList" style="max-height: 200px; overflow-y: auto;">
<div class="fluent-notifications-empty">Ladowanie...</div>
</div>
<div class="fluent-dropdown-divider"></div>
<!-- Messages -->
<a href="{{ url_for('messages_inbox') }}" class="fluent-dropdown-item">
<svg width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 8l7.89 5.26a2 2 0 002.22 0L21 8M5 19h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"/>
</svg>
Wiadomosci
<span class="fluent-badge fluent-badge-inline" id="unreadBadge" style="display: none;">0</span>
</a>
<!-- Dashboard -->
<a href="{{ url_for('dashboard') }}" class="fluent-dropdown-item">
<svg width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 5a1 1 0 011-1h14a1 1 0 011 1v2a1 1 0 01-1 1H5a1 1 0 01-1-1V5zM4 13a1 1 0 011-1h6a1 1 0 011 1v6a1 1 0 01-1 1H5a1 1 0 01-1-1v-6zM16 13a1 1 0 011-1h2a1 1 0 011 1v6a1 1 0 01-1 1h-2a1 1 0 01-1-1v-6z"/>
</svg>
Moj Panel
</a>
{% if current_user.is_admin %}
<div class="fluent-dropdown-divider"></div>
<div class="fluent-dropdown-header">Administracja</div>
<a href="{{ url_for('admin_calendar') }}" class="fluent-dropdown-item">
<svg width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"/>
</svg>
Admin Kalendarz
</a>
<a href="{{ url_for('admin_social_media') }}" class="fluent-dropdown-item">
<svg width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 4v16M17 4v16M3 8h4m10 0h4M3 12h18M3 16h4m10 0h4M4 20h16a1 1 0 001-1V5a1 1 0 00-1-1H4a1 1 0 00-1 1v14a1 1 0 001 1z"/>
</svg>
Social Media
</a>
<a href="{{ url_for('chat_analytics') }}" class="fluent-dropdown-item">
<svg width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z"/>
</svg>
Analityka Chatu
</a>
<a href="{{ url_for('debug_panel') }}" class="fluent-dropdown-item">
<svg width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 20l4-16m4 4l4 4-4 4M6 16l-4-4 4-4"/>
</svg>
Debug Panel
</a>
<a href="{{ url_for('admin_fees') }}" class="fluent-dropdown-item">
<svg width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8c-1.657 0-3 .895-3 2s1.343 2 3 2 3 .895 3 2-1.343 2-3 2m0-8c1.11 0 2.08.402 2.599 1M12 8V7m0 1v8m0 0v1m0-1c-1.11 0-2.08-.402-2.599-1M21 12a9 9 0 11-18 0 9 9 0 0118 0z"/>
</svg>
Skladki
</a>
<a href="{{ url_for('admin_announcements') }}" class="fluent-dropdown-item">
<svg width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M11 5.882V19.24a1.76 1.76 0 01-3.417.592l-2.147-6.15M18 13a3 3 0 100-6M5.436 13.683A4.001 4.001 0 017 6h1.832c4.1 0 7.625-1.234 9.168-3v14c-1.543-1.766-5.067-3-9.168-3H7a3.988 3.988 0 01-1.564-.317z"/>
</svg>
Ogloszenia
</a>
{% endif %}
<div class="fluent-dropdown-divider"></div>
<a href="{{ url_for('release_notes') }}" class="fluent-dropdown-item">
<svg width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"/>
</svg>
Historia zmian
</a>
<a href="{{ url_for('logout') }}" class="fluent-dropdown-item">
<svg width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M17 16l4-4m0 0l-4-4m4 4H7m6 4v1a3 3 0 01-3 3H6a3 3 0 01-3-3V7a3 3 0 013-3h4a3 3 0 013 3v1"/>
</svg>
Wyloguj
</a>
</div>
</div>
{% else %}
<a href="{{ url_for('login') }}" class="fluent-btn fluent-btn-outline fluent-btn-sm">Zaloguj</a>
<a href="{{ url_for('register') }}" class="fluent-btn fluent-btn-primary fluent-btn-sm">Rejestracja</a>
{% endif %}
</div>
</nav>
<!-- Development Notice Banner -->
<div class="dev-notice" id="devNotice">
<span class="dev-notice-icon">🚧</span>
<span class="dev-notice-text">
Serwis w fazie rozwoju. Oficjalne uruchomienie po akceptacji Zarządu Norda Biznes.
</span>
<button class="dev-notice-close" onclick="dismissDevNotice()" aria-label="Zamknij">&times;</button>
</div>
<!-- Flash Messages -->
{% with messages = get_flashed_messages(with_categories=true) %}
{% if messages %}
<div class="flash-messages" role="alert" aria-live="polite">
{% for category, message in messages %}
<div class="flash flash-{{ category }}">
<span>{{ message }}</span>
<button class="flash-close" onclick="this.parentElement.remove()" aria-label="Close">&times;</button>
</div>
{% endfor %}
</div>
{% endif %}
{% endwith %}
<!-- Main Content -->
<main role="main">
<div class="container {% block container_class %}{% endblock %}">
{% block content %}{% endblock %}
</div>
</main>
<!-- Footer -->
<footer>
<div class="container">
<div class="footer-content">
<div class="footer-section">
<h3>Norda Biznes Hub</h3>
<p>Katalog firm członkowskich stowarzyszenia Norda Biznes - networking i współpraca biznesowa.</p>
</div>
<div class="footer-section">
<h3>Linki</h3>
<a href="{{ url_for('index') }}">Katalog firm</a>
{% if current_user.is_authenticated %}
<a href="{{ url_for('calendar_index') }}">Kalendarz</a>
<a href="{{ url_for('classifieds_index') }}">Tablica B2B</a>
<a href="{{ url_for('new_members') }}">Nowi czlonkowie</a>
<a href="{{ url_for('chat') }}">Chat AI</a>
{% endif %}
</div>
<div class="footer-section">
<h3>Kontakt</h3>
<p>Email: biuro@inpi.pl</p>
<p>Telefon: +48 785 337 754</p>
<p>Adres: ul. Tomasza Rogali 11, 84-200 Wejherowo</p>
</div>
</div>
<div class="footer-bottom">
<p>&copy; {{ current_year }} Norda Biznes. Wszelkie prawa zastrzeżone.</p>
</div>
</div>
</footer>
<!-- Scripts -->
<script>
// ============================================================
// FLUENT NAVIGATION SYSTEM
// ============================================================
// Mobile menu toggle
function toggleMobileMenu() {
document.getElementById('navMenu').classList.toggle('open');
}
// Dropdown toggle
function toggleDropdown(dropdownId) {
const dropdown = document.getElementById(dropdownId);
const wasOpen = dropdown.classList.contains('open');
// Close all dropdowns first
document.querySelectorAll('.fluent-dropdown.open').forEach(d => {
d.classList.remove('open');
});
// Toggle the clicked one
if (!wasOpen) {
dropdown.classList.add('open');
// Load notifications if opening user dropdown
if (dropdownId === 'userDropdown' && !notificationsLoaded) {
loadNotifications();
}
}
}
// Close dropdowns and mobile menu when clicking outside
document.addEventListener('click', function(event) {
// Close dropdowns
if (!event.target.closest('.fluent-dropdown')) {
document.querySelectorAll('.fluent-dropdown.open').forEach(d => {
d.classList.remove('open');
});
}
// Close mobile menu
const navMenu = document.getElementById('navMenu');
const navToggle = document.querySelector('.fluent-mobile-toggle');
if (navMenu && navToggle && !navMenu.contains(event.target) && !navToggle.contains(event.target)) {
navMenu.classList.remove('open');
}
});
// Auto-dismiss flash messages after 5 seconds
document.addEventListener('DOMContentLoaded', function() {
const flashes = document.querySelectorAll('.flash');
flashes.forEach(flash => {
setTimeout(() => {
flash.style.opacity = '0';
flash.style.transform = 'translateX(100%)';
setTimeout(() => flash.remove(), 300);
}, 5000);
});
});
// Development notice banner
function dismissDevNotice() {
const notice = document.getElementById('devNotice');
if (notice) {
notice.style.display = 'none';
// Remember dismissal for this session
sessionStorage.setItem('devNoticeDismissed', 'true');
}
}
// Check if notice was dismissed in this session
document.addEventListener('DOMContentLoaded', function() {
if (sessionStorage.getItem('devNoticeDismissed') === 'true') {
const notice = document.getElementById('devNotice');
if (notice) notice.style.display = 'none';
}
});
// Fetch unread message count (for authenticated users)
{% if current_user.is_authenticated %}
async function updateUnreadBadge() {
try {
const response = await fetch('{{ url_for("api_unread_count") }}');
const data = await response.json();
const badge = document.getElementById('unreadBadge');
if (badge && data.count > 0) {
badge.textContent = data.count > 99 ? '99+' : data.count;
badge.style.display = 'flex';
} else if (badge) {
badge.style.display = 'none';
}
} catch (error) {
console.log('Could not fetch unread count');
}
}
// Check unread on page load and every 60 seconds
document.addEventListener('DOMContentLoaded', updateUnreadBadge);
setInterval(updateUnreadBadge, 60000);
// ============================================================
// NOTIFICATIONS SYSTEM
// ============================================================
let notificationsLoaded = false;
function toggleNotifications(event) {
event.stopPropagation();
const menu = document.getElementById('notificationsMenu');
const isOpen = menu.classList.contains('show');
// Close any other open dropdowns
document.querySelectorAll('.notifications-menu.show').forEach(m => m.classList.remove('show'));
if (!isOpen) {
menu.classList.add('show');
if (!notificationsLoaded) {
loadNotifications();
}
}
}
async function loadNotifications() {
const listEl = document.getElementById('notificationsList');
try {
const response = await fetch('{{ url_for("api_notifications") }}?limit=10');
const data = await response.json();
if (!data.success) {
listEl.innerHTML = '<div class="fluent-notifications-empty">Blad ladowania</div>';
return;
}
if (data.notifications.length === 0) {
listEl.innerHTML = '<div class="fluent-notifications-empty">Brak powiadomien</div>';
return;
}
let html = '';
data.notifications.forEach(n => {
const timeAgo = formatTimeAgo(new Date(n.created_at));
const unreadClass = n.is_read ? '' : 'unread';
const dotHtml = n.is_read ? '' : '<span class="fluent-notification-dot"></span>';
html += `
<a href="${n.action_url || '#'}" class="fluent-notification-item ${unreadClass}"
onclick="markNotificationRead(event, ${n.id})" data-id="${n.id}">
<div class="fluent-notification-title">${dotHtml}${escapeHtml(n.title)}</div>
<div class="fluent-notification-message">${escapeHtml(n.message || '')}</div>
<div class="fluent-notification-time">${timeAgo}</div>
</a>
`;
});
listEl.innerHTML = html;
notificationsLoaded = true;
// Update badge
updateNotificationBadge(data.unread_count);
} catch (error) {
console.error('Error loading notifications:', error);
listEl.innerHTML = '<div class="fluent-notifications-empty">Blad ladowania</div>';
}
}
function getNotificationIcon(type) {
const icons = {
'news': '<svg class="notification-type-icon" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 20H5a2 2 0 01-2-2V6a2 2 0 012-2h10a2 2 0 012 2v1m2 13a2 2 0 01-2-2V7m2 13a2 2 0 002-2V9a2 2 0 00-2-2h-2m-4-3H9M7 16h6M7 8h6v4H7V8z"></path></svg>',
'event': '<svg class="notification-type-icon" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"></path></svg>',
'message': '<svg class="notification-type-icon" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 10h.01M12 10h.01M16 10h.01M9 16H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-5l-5 5v-5z"></path></svg>',
'system': '<svg class="notification-type-icon" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path></svg>',
'alert': '<svg class="notification-type-icon" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"></path></svg>'
};
return icons[type] || icons['system'];
}
async function markNotificationRead(event, notificationId) {
// Don't prevent default - we want to navigate
try {
const csrfToken = document.querySelector('meta[name="csrf-token"]')?.content ||
document.querySelector('input[name="csrf_token"]')?.value || '';
await fetch(`/api/notifications/${notificationId}/read`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-CSRFToken': csrfToken
}
});
// Update UI
const item = document.querySelector(`.fluent-notification-item[data-id="${notificationId}"]`);
if (item) {
item.classList.remove('unread');
const dot = item.querySelector('.fluent-notification-dot');
if (dot) dot.remove();
}
// Refresh badge count
updateNotificationBadgeFromAPI();
} catch (error) {
console.error('Error marking notification as read:', error);
}
}
async function markAllNotificationsRead() {
try {
const csrfToken = document.querySelector('meta[name="csrf-token"]')?.content ||
document.querySelector('input[name="csrf_token"]')?.value || '';
const response = await fetch('/api/notifications/read-all', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-CSRFToken': csrfToken
}
});
const data = await response.json();
if (data.success) {
// Update all items in UI
document.querySelectorAll('.fluent-notification-item.unread').forEach(item => {
item.classList.remove('unread');
const dot = item.querySelector('.fluent-notification-dot');
if (dot) dot.remove();
});
// Update badge
updateNotificationBadge(0);
}
} catch (error) {
console.error('Error marking all notifications as read:', error);
}
}
async function updateNotificationBadgeFromAPI() {
try {
const response = await fetch('/api/notifications/unread-count');
const data = await response.json();
updateNotificationBadge(data.count);
} catch (error) {
console.error('Error fetching notification count:', error);
}
}
function updateNotificationBadge(count) {
const badge = document.getElementById('notificationBadge');
if (badge) {
if (count > 0) {
badge.textContent = count > 99 ? '99+' : count;
badge.style.display = 'flex';
} else {
badge.style.display = 'none';
}
}
}
function formatTimeAgo(date) {
const now = new Date();
const diff = now - date;
const seconds = Math.floor(diff / 1000);
const minutes = Math.floor(seconds / 60);
const hours = Math.floor(minutes / 60);
const days = Math.floor(hours / 24);
if (days > 7) {
return date.toLocaleDateString('pl-PL');
} else if (days > 0) {
return `${days} ${days === 1 ? 'dzien' : 'dni'} temu`;
} else if (hours > 0) {
return `${hours} ${hours === 1 ? 'godzine' : 'godzin'} temu`;
} else if (minutes > 0) {
return `${minutes} min temu`;
} else {
return 'przed chwila';
}
}
function escapeHtml(text) {
const div = document.createElement('div');
div.textContent = text;
return div.innerHTML;
}
// Close notifications menu when clicking outside
document.addEventListener('click', function(event) {
const menu = document.getElementById('notificationsMenu');
const dropdown = document.querySelector('.notifications-dropdown');
if (menu && dropdown && !dropdown.contains(event.target)) {
menu.classList.remove('show');
}
});
// Check notification count periodically
setInterval(updateNotificationBadgeFromAPI, 60000);
{% endif %}
{% block extra_js %}{% endblock %}
</script>
</body>
</html>