// Shared functions function formatDate(dateString) { const options = { year: 'numeric', month: 'long', day: 'numeric' }; return new Date(dateString).toLocaleDateString('tr-TR', options); } function calculateAge(birthDate) { const today = new Date(); const birthDateObj = new Date(birthDate); let age = today.getFullYear() - birthDateObj.getFullYear(); const monthDiff = today.getMonth() - birthDateObj.getMonth(); if (monthDiff < 0 || (monthDiff === 0 && today.getDate() < birthDateObj.getDate())) { age--; } return age; } // Check authentication function checkAuth(requiredRole, redirectTo = 'index.html') { // In a real app, this would check server-side authentication const role = localStorage.getItem('role'); if (!role || (requiredRole && role !== requiredRole)) { window.location.href = redirectTo; } } // Initialize tooltips function initTooltips() { const tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]')); tooltipTriggerList.map(function (tooltipTriggerEl) { return new bootstrap.Tooltip(tooltipTriggerEl); }); } // Initialize after DOM is loaded document.addEventListener('DOMContentLoaded', function() { initTooltips(); feather.replace(); });